> For the complete documentation index, see [llms.txt](https://docs.flora.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flora.ai/api/reference/canvas/createcanvasaction.md).

# Create a canvas action

Create a canvas action with the FLORA API: POST /projects/{projectId}/actions.

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}.

```http
POST https://app.flora.ai/api/v1/projects/{projectId}/actions
```

* **Auth:** API key as a bearer token, `Authorization: Bearer $FLORA_API_KEY`. See [Authentication](https://docs.flora.ai/api/platform/authentication.md).
* **TypeScript SDK:** `client.projects.actions.create()`.
* **Operation ID:** `createCanvasAction`.

## Example

{% tabs %}
{% tab title="cURL" %}

```bash
curl -X POST 'https://app.flora.ai/api/v1/projects/prj_abc123/actions' \
  -H "Authorization: Bearer $FLORA_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "action_id": "color-grade-image-browser"
}'
```

{% endtab %}

{% tab title="TypeScript SDK" %}

```typescript
import { FloraClient } from '@flora-ai/flora';

const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });

const action = await client.projects.actions.create({
  projectId: 'prj_abc123',
  action_id: 'color-grade-image-browser',
});
console.log(action);
```

{% endtab %}
{% endtabs %}

## Path parameters

| Name        | Type   | Required | Description                                                      |
| ----------- | ------ | -------- | ---------------------------------------------------------------- |
| `projectId` | string | Yes      | Project identifier. Pattern: `^prj_\S+$`. Example: `prj_abc123`. |

## Request body

Optional.

| Field       | Type   | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| ----------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `action_id` | string | No       | Prebuilt action identifier. Required unless `code` is given. One of: `color-grade-image-browser`, `overlay-image-browser`, `draw-image-browser`, `pixel-remover-image-browser`, `magic-eraser-image-browser`, `crop-image-browser`, `scene-3d-image-browser`, `blur-image-browser`, `change-image-ar-browser`, `rotate-image-browser`, `color-filter-image-browser`, `color-tint-image-browser`, `filter-color-image-browser`, `duplicate-image-browser`, `side-by-side-composite-browser`, `add-shape-to-image-browser`, `add-text-to-image-browser`, `qr-code-generator-browser`, `resize-image-browser`, `shader-effect-browser`, `split-text-browser`, `find-and-replace-text-browser`, `concat-text-browser`, `ken-burns-video`, `stitch-videos`, `split-video`, `extract-video-frames`, `color-grade-video`, `video-to-frame-grid`, `boomerang-video`, `reverse-video`, `video-to-long-exposure`, `video-effect`, `color-filter-video`, `speed-up-video`, `slow-down-video`, `duplicate-video`, `greenscreen-video`, `resize-video`, `change-video-ar`, and 2 more. |
| `code`      | string | No       | 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. At least 1 character.                                                                                                                                                                        |
| `language`  | string | No       | Language of `code`. Required with `code`; ignored with `action_id`. One of: `javascript`, `python`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `runtime`   | string | No       | 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. One of: `node`, `python`, `browser`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `label`     | string | No       | Node label on the canvas. Defaults to the action's declared name. 1 to 120 characters.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `params`    | object | No       | 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## Responses

### 201: Canvas action created.

| Field        | Type           | Required | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| ------------ | -------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `project_id` | string         | Yes      | Project identifier. Pattern: `^prj_\S+$`. Example: `prj_abc123`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| `node_id`    | string         | Yes      | Canvas action node identifier. At least 1 character. Example: `node_abc123`.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| `action_id`  | string or null | Yes      | Prebuilt action identifier, or null for a custom action created from code. One of: `color-grade-image-browser`, `overlay-image-browser`, `draw-image-browser`, `pixel-remover-image-browser`, `magic-eraser-image-browser`, `crop-image-browser`, `scene-3d-image-browser`, `blur-image-browser`, `change-image-ar-browser`, `rotate-image-browser`, `color-filter-image-browser`, `color-tint-image-browser`, `filter-color-image-browser`, `duplicate-image-browser`, `side-by-side-composite-browser`, `add-shape-to-image-browser`, `add-text-to-image-browser`, `qr-code-generator-browser`, `resize-image-browser`, `shader-effect-browser`, `split-text-browser`, `find-and-replace-text-browser`, `concat-text-browser`, `ken-burns-video`, `stitch-videos`, `split-video`, `extract-video-frames`, `color-grade-video`, `video-to-frame-grid`, `boomerang-video`, `reverse-video`, `video-to-long-exposure`, `video-effect`, `color-filter-video`, `speed-up-video`, `slow-down-video`, `duplicate-video`, `greenscreen-video`, `resize-video`, `change-video-ar`, and 2 more. |
| `canvas_url` | string (uri)   | Yes      | Project canvas URL                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

## Errors

Every error has the same body: `error.code`, `error.message`, and `error.fields` on validation errors. See [Errors](https://docs.flora.ai/api/platform/errors.md) for how to recover from each code.

| Status | Code                                         | Meaning                                                                             |
| ------ | -------------------------------------------- | ----------------------------------------------------------------------------------- |
| 400    | `invalid_json`, `input_validation_error`     | The body isn't valid JSON, or an input failed validation (`fields` lists each one). |
| 401    | `unauthorized`, `invalid_api_key`            | The API key is missing, invalid or revoked.                                         |
| 402    | `insufficient_credits`                       | The workspace balance is too low for this request.                                  |
| 403    | `forbidden`, `paid_plan_required`            | The key can't do this, or the workspace plan doesn't include it.                    |
| 404    | `not_found`                                  | The resource doesn't exist or isn't visible to this key.                            |
| 409    | `idempotency_duplicate`, `revision_conflict` | Duplicate `Idempotency-Key` or a stale `base_revision`.                             |
| 429    | `rate_limited`                               | Too many requests. Back off and retry.                                              |
| 500    | `unknown_error`, `internal_error`            | Something failed on FLORA's side. Retry with backoff.                               |
| 503    | `temporarily_unavailable`                    | Authorization is temporarily unavailable. Retry later.                              |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.flora.ai/api/reference/canvas/createcanvasaction.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
