Apply a canvas changeset
import { FloraClient } from '@flora-ai/flora';
const client = new FloraClient({ apiKey: process.env['FLORA_API_KEY'] });
const canva = await client.projects.canvas.applyChangeset({ workspaceId: '<workspaceId>', projectId: '<projectId>', add: [ { ref: 'hero', type: 'image', }, ], update: [ { id: 'n7', }, ], connect: [ { from: 'n7', to: 'n7', }, ], disconnect: [ { from: 'n7', to: 'n7', }, ], remove: [ { id: 'n7', }, ],});console.log(canva);curl -X POST 'https://app.flora.ai/api/v1/workspaces/<workspaceId>/projects/<projectId>/canvas/changeset' \ -H 'Authorization: Bearer $FLORA_API_KEY' \ -H 'Content-Type: application/json' \ -d '{ "add": [ { "ref": "hero", "type": "image" } ], "update": [ { "id": "n7" } ], "connect": [ { "from": "n7", "to": "n7" } ], "disconnect": [ { "from": "n7", "to": "n7" } ], "remove": [ { "id": "n7" } ]}'Edits a project canvas: add, update, connect, disconnect and remove operations validate together and apply as ONE atomic transaction. Nothing applies if any operation is invalid, and every cause is reported with a machine-readable code in the error’s fields array. 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. 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.
Error responses use the standard error body.
Authorizations
Section titled “Authorizations ”Parameters
Section titled “ Parameters ”Path Parameters
Section titled “Path Parameters ”Workspace identifier
Workspace identifier
Project identifier
Project identifier
Request Body
Section titled “Request Body ”object
Nodes to create. Groups are created before their members.
object
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.
Node type to create, in the agent vocabulary the graph read reports
Display label pinned on the node
Generation prompt, stored in the node’s model parameters. Mutually exclusive with content_url.
Model name or endpoint id, as the graph read reports them. Omit to take the default model for the node’s modality.
Model parameters, validated against the model’s schema. Invalid values reject the whole changeset rather than being coerced.
object
Absolute canvas position. Omit to place the node automatically below the existing canvas content.
object
Absolute horizontal canvas coordinate
Absolute vertical canvas coordinate
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.
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.
Existing nodes to modify. One operation per node.
object
Node to modify: its short id or UUID
Replacement display label
Replacement generation prompt
Replacement model name or endpoint id
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.
object
New absolute canvas position
object
Absolute horizontal canvas coordinate
Absolute vertical canvas coordinate
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.
object
Source node reference
Target node reference
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.
Edges to remove, addressed by their endpoints as the graph read reports them
object
Source node reference
Target node reference
Input slot of the edge to remove; omit to remove every edge between the pair
Nodes to delete. Their edges and any group members go too. Removal is immediate and cannot be undone through the API.
object
Node to delete: its short id or UUID
Responses
Section titled “ Responses ”Changeset applied.
object
Project identifier
Project canvas URL
Each add operation’s ref mapped to the ids of the node it created
object
object
Short id the created node answers to from now on
Created node UUID
What the transaction actually did
object
Nodes created
Update operations that changed at least one field
Edges created
Edges removed
Nodes deleted, including group members deleted with their frame
Change-detection marker of the canvas after this changeset, identical to the value the project graph endpoint reports
Operations that resolved but did not change what the caller may have expected, such as an update matching current state or a duplicate connect
Example
{ "project_id": "prj_abc123", "created": { "additionalProperty": { "id": "n9", "node_id": "7f6ae6da-4a0e-4a2f-9c6a-2c1c6b8d1f21" } }, "revision": "4f2c8ab19e3d7c05"}