Apply a canvas changeset
Apply a canvas changeset with the FLORA API: POST /workspaces/{workspaceId}/projects/{projectId}/canvas/changeset.
Edits a project canvas: add, update, connect, disconnect and remove operations validate together before writes begin. Invalid operations reject the request, and every cause is reported with a machine-readable code in the error's fields array. Authored content lives in document: an add of type timeline or deck may carry one, and an update replaces a timeline or deck document wholesale, guarded by base_revision so a write based on a stale read is rejected with revision_conflict instead of overwriting someone else's edit. Documents are validated against their authoring limits. Deck updates require base_revision and use observed Liveblocks revisions; simultaneous collaborators and undo retain the editor's existing semantics. Deck content and Timeline drafts use separate storage, so a mixed changeset is not a cross-store transaction. Deck writes do not render or export a presentation. Operations apply in the order add, update, connect, disconnect, remove, with groups created before their members — so one call can create a group, fill it, wire the new nodes to existing ones by the ref names it chose, and delete something else. An update can move an existing node into a group frame or out to the top level (group) without moving it on the canvas, and can replace a static image, video, or audio node's media in place (content_url or asset_id) while keeping its id and edges; a media replacement overwrites what the node showed. Nodes are addressed by the short id or node UUID the project graph endpoint reports, or by a ref declared by an add operation in the same request. REMOVE IS IMMEDIATE AND IRREVERSIBLE through the API: there is no confirmation step and no undo, deleting a node also deletes its edges and any group members, so confirm destructive changesets with your user before sending them. The revision returned is the same change-detection marker the project graph endpoint reports, so it can be compared directly against a later read. Mutating public API requests support an optional Idempotency-Key header for client retries; duplicate keys within two hours return idempotency_duplicate.
POST https://app.flora.ai/api/v1/workspaces/{workspaceId}/projects/{projectId}/canvas/changesetAuth: API key as a bearer token,
Authorization: Bearer $FLORA_API_KEY. See Authentication.TypeScript SDK:
client.projects.canvas.applyChangeset().Idempotency: optional
Idempotency-Keyheader. See Idempotency.Operation ID:
applyCanvasChangeset.
Example
curl -X POST 'https://app.flora.ai/api/v1/workspaces/ws_abc123/projects/prj_abc123/canvas/changeset' \
-H "Authorization: Bearer $FLORA_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"add": [
{
"ref": "hero",
"type": "image"
}
]
}'import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const canvas = await client.projects.canvas.applyChangeset({
workspaceId: 'ws_abc123',
projectId: 'prj_abc123',
add: [
{
ref: 'hero',
type: 'image',
},
],
});
console.log(canvas);Path parameters
workspaceId
string
Yes
Workspace identifier. Pattern: ^ws_\S+$. Example: ws_abc123.
projectId
string
Yes
Project identifier. Pattern: ^prj_\S+$. Example: prj_abc123.
Request body
Optional.
add
array of objects
No
Nodes to create. Groups are created before their members. At most 200 items.
add[].ref
string
Yes
Caller-chosen handle for the new node, echoed back in created with its real ids. Usable as a connect or group target inside this same changeset. Must not collide with a live node id. 1 to 64 characters. Example: hero.
add[].type
string
Yes
Node type to create, in the agent vocabulary the graph read reports. One of: image, video, text, audio, timeline, deck, notes, group, static_image, layer_editor.
add[].label
string
No
Display label pinned on the node. At most 500 characters.
add[].prompt
string
No
Generation prompt, stored in the node's model parameters. Mutually exclusive with content_url.
add[].model
string
No
Model name or endpoint id, as the graph read reports them. Omit to take the default model for the node's modality.
add[].params
object
No
Model parameters, validated against the model's schema. Invalid values reject the whole changeset rather than being coerced.
add[].position
object
No
Absolute canvas position. Omit to place the node automatically below the existing canvas content.
add[].position.x
number
Yes
Absolute horizontal canvas coordinate
add[].position.y
number
Yes
Absolute vertical canvas coordinate
add[].group
string
No
Group to parent this node into: an existing group's short id or UUID, or the ref of a group created by this same changeset. Not accepted on notes nodes (a note documents the canvas and always stays at the top level — place it beside the frame with position) or on group nodes (frames do not nest); either rejects the whole changeset.
add[].content_url
string (uri)
No
HTTPS URL of existing image, video, or audio to place instead of generating. The media is copied onto Flora's CDN and the node becomes a static block. Mutually exclusive with prompt, model, and params.
add[].document
object
No
Authored content for a timeline or deck node: the whole document, validated with the workspace's own limits before anything is written. document.kind must match the node type ("timeline" or "deck"). Rejected on every other node type. A timeline created without a document has nothing to render until one is written with an update. See the add[].document shapes below.
add[].text
string
No
Body of a notes node: plain text, newlines significant, at most 20000 characters. Notes are canvas documentation — they generate nothing and spend nothing. Rejected on every other node type, which take prompt instead. At most 20000 characters.
add[].size
object
No
Box of a notes node in canvas pixels. Either or both of width/height; an omitted side keeps its current (or default 320x240) value. Clamped range width 200–1024, height 120–1024; values outside reject the changeset. Rejected on every other node type.
add[].size.width
number
No
Note width in canvas pixels. At least 0.
add[].size.height
number
No
Note height in canvas pixels. At least 0.
add[].fit_text
boolean
No
Notes only: size the height so the whole text body is visible without internal scrolling at the note's width (the width from size, else its current width). Computed from the note's text after any text in this same operation is applied; capped at the maximum height, with a warning when the text still overflows. Rejected on every other node type.
update
array of objects
No
Existing nodes to modify. One operation per node. At most 200 items.
update[].id
string
Yes
Node to modify: its short id or UUID. 1 to 200 characters. Example: n7.
update[].label
string
No
Replacement display label. At most 500 characters.
update[].prompt
string
No
Replacement generation prompt
update[].model
string
No
Replacement model name or endpoint id
update[].params
object
No
Model parameters, merged key by key into the node's stored parameters. Omitted keys survive; a named key is overwritten. On an action node these are the action's own parameter values.
update[].position
object
No
New absolute canvas position
update[].position.x
number
Yes
Absolute horizontal canvas coordinate
update[].position.y
number
Yes
Absolute vertical canvas coordinate
update[].document
object
No
Replacement document for a timeline or deck node, whole-document: read it, modify it, write it back. Validated with the workspace's own limits before anything is applied. Deck replacements require base_revision. Rejected on nodes that carry no document. Mutually exclusive with commands. Same shape as add[].document.
update[].commands
array of objects
No
Scoped edits to a Deck node, applied in order to the slides and layers they name — a single layer or slide changes without resending the whole document. Deck nodes only; requires base_revision like a document replacement, and mutually exclusive with document. A command that cannot apply (unknown slide or layer, duplicate layer id, last-slide removal, limits) rejects the whole changeset naming the command by index. 1 to 201 items. See the update[].commands[] shapes below.
update[].base_revision
integer
No
The document revision read before editing. Required for Deck replacements and command batches. A differing observed revision returns revision_conflict; read again and reapply the intended edit. Deck revisions follow Liveblocks collaboration and undo and do not serialize simultaneous writers. Only meaningful alongside document or commands; 0 is an empty Deck's initial revision or a Timeline with no document yet. At least 0.
update[].text
string
No
Replacement body for a notes node, whole-body: at most 20000 characters. Rejected on nodes that carry no annotation body. At most 20000 characters.
update[].size
object
No
Box of a notes node in canvas pixels. Either or both of width/height; an omitted side keeps its current (or default 320x240) value. Clamped range width 200–1024, height 120–1024; values outside reject the changeset. Rejected on every other node type.
update[].size.width
number
No
Note width in canvas pixels. At least 0.
update[].size.height
number
No
Note height in canvas pixels. At least 0.
update[].fit_text
boolean
No
Notes only: size the height so the whole text body is visible without internal scrolling at the note's width (the width from size, else its current width). Computed from the note's text after any text in this same operation is applied; capped at the maximum height, with a warning when the text still overflows. Rejected on every other node type.
update[].group
string or null
No
Group frame to move this node into, by an existing group's short id or UUID, or null to move it out of its group to the top level. Omit to leave membership unchanged. The node keeps its canvas spot unless position is also given (absolute), and a frame it joins grows to wrap it. Rejected on group nodes (frames do not nest), on a notes node joining a group, on a node attached to another node (a pinned label follows its host), and for a group this same changeset creates or removes. 1 to 200 characters.
update[].content_url
string (uri)
No
HTTPS URL of an image, video, or audio file that replaces the media of a static image, video, or audio node in place; the node keeps its id, edges, group, and label (unless group or label is also given). The file is copied onto Flora's CDN as on an add. Mutually exclusive with asset_id, prompt, model, params, document, text, size, and fit_text.
update[].asset_id
string
No
A ready asset in this project's workspace that replaces the media of a static image, video, or audio node in place, keeping the node's id, edges, group, and label (unless group or label is also given). Its kind must match the node's. The asset is referenced, not copied or deleted. Mutually exclusive with content_url, prompt, model, params, document, text, size, and fit_text. Pattern: ^asset_\S+$. Example: asset_abc123.
connect
array of objects
No
Edges to create. Either endpoint may be a ref created by this same changeset. The canvas carries one edge per pair, so a duplicate pair is skipped with a warning. At most 500 items.
connect[].from
string
Yes
Source node reference. 1 to 200 characters. Example: n7.
connect[].to
string
Yes
Target node reference. 1 to 200 characters. Example: n7.
connect[].in
string
No
Target input slot, in the vocabulary the graph read reports: a modality word such as "image", a named action or technique input, or "enabled" for the boolean gate. Omit to let the target take the edge by modality.
disconnect
array of objects
No
Edges to remove, addressed by their endpoints as the graph read reports them. At most 500 items.
disconnect[].from
string
Yes
Source node reference. 1 to 200 characters. Example: n7.
disconnect[].to
string
Yes
Target node reference. 1 to 200 characters. Example: n7.
disconnect[].in
string
No
Input slot of the edge to remove; omit to remove every edge between the pair
remove
array of objects
No
Nodes to delete. Their edges and any group members go too. Removal is immediate and cannot be undone through the API. At most 200 items.
remove[].id
string
Yes
Node to delete: its short id or UUID. 1 to 200 characters. Example: n7.
Responses
200: Changeset applied.
project_id
string
Yes
Project identifier. Pattern: ^prj_\S+$. Example: prj_abc123.
canvas_url
string (uri)
Yes
Project canvas URL
created
map of object
Yes
Each add operation's ref mapped to the ids of the node it created
created.{key}.id
string
Yes
Short id the created node answers to from now on. At least 1 character. Example: n9.
created.{key}.node_id
string
Yes
Created node UUID. At least 1 character. Example: 7f6ae6da-4a0e-4a2f-9c6a-2c1c6b8d1f21.
applied
object
Yes
What the transaction actually did
applied.added
integer
Yes
Nodes created. At least 0.
applied.updated
integer
Yes
Update operations that changed at least one field. At least 0.
applied.connected
integer
Yes
Edges created. At least 0.
applied.disconnected
integer
Yes
Edges removed. At least 0.
applied.removed
integer
Yes
Nodes deleted, including group members deleted with their frame. At least 0.
revision
string
Yes
Change-detection marker of the canvas after this changeset, identical to the value the project graph endpoint reports. At least 1 character. Example: 4f2c8ab19e3d7c05.
warnings
array of string
Yes
Operations that resolved but did not change what the caller may have expected, such as an update matching current state or a duplicate connect
Errors
Every error has the same body: error.code, error.message, and error.fields on validation errors. See Errors for how to recover from each code.
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.
Last updated
Was this helpful?