Create a canvas action
import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const action = await client.projects.actions.create({ projectId: '<projectId>', action_id: 'color-grade-image-browser', code: '<code>', language: 'javascript', runtime: 'node', label: '<label>', params: {},});console.log(action);curl -X POST 'https://app.flora.ai/api/v1/projects/<projectId>/actions' \ -H 'Authorization: Bearer $FLORA_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "action_id": "color-grade-image-browser", "code": "<code>", "language": "javascript", "runtime": "node", "label": "<label>", "params": {}}'Creates an action node on a project canvas: a prebuilt action by slug (action_id), or a custom action from source (code + language). A custom action’s inputs, outputs and parameters come from the annotations in its code; read them back with GET /projects/{projectId}/actions/{nodeId}.
Error responses use the standard error body.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Project identifier
Project identifier
Request Body
Section titled “Request Body ”object
Prebuilt action identifier. Required unless code is given.
Source of a custom action, in place of action_id. Declare its contract in comment annotations the way prebuilt actions do: @flora-name, @flora-description, @flora-inputs (JSON array of {name, type}), @flora-outputs (required, same shape) and @flora-params (JSON array of {key, label, type, default, min, max, step, options, visibleIf}). Read a prebuilt action’s code conventions from GET /actions/{actionId}. Requires the workspace plan to include custom actions. Limits: at most 1048576 bytes of UTF-8 source; each @flora-inputs, @flora-outputs and @flora-params JSON array at most 131072 bytes, with up to 64 inputs, 64 outputs, 128 params and 256 options per select. A multiple bounds object takes nonnegative integer min and max with min (1 when absent) at most max, and each declared default must be a value its param accepts.
Language of code. Required with code; ignored with action_id.
Where custom code runs. python code runs on python; javascript runs on node (the harness with getInput/getParam/writeOutput) or browser (an ES module exporting execute and optionally preview, which hosts can mount live). Defaults to browser for JavaScript that exports execute, otherwise the language’s sandbox. Ignored with action_id.
Node label on the canvas. Defaults to the action’s declared name.
Action parameters (snake_case keys). For a prebuilt action the accepted keys depend on action_id; see GET /actions/{actionId} or POST /runs/action for the per-action schema. For a custom action they are the keys its @flora-params annotation declares, as GET /projects/{projectId}/actions/{nodeId} lists them, in at most 262144 bytes of JSON.
object
Responses
Section titled “ Responses ”Canvas action created.
object
Example
{ "project_id": "prj_abc123", "node_id": "node_abc123", "action_id": "color-grade-image-browser"}