Validate a batch before applying
Goal. Add a contained group of nodes to an existing canvas — and delete one obsolete node — without moving, breaking, or overwriting anything else, and without losing a concurrent edit made by someone else while you were working.
Tools used. canvas_get, canvas_validate, canvas_apply_batch, and optionally guide_get. All listed by default.
Requires. A full-access connection with canvas:read and canvas:write. No provider cost at any step: a batch never starts generation.
You finish holding. A new revision, the exact handles of everything created, a post-write validation summary, and a review link.
The sequence
Read the canvas and keep the revision
{ "name": "canvas_get", "arguments": { "canvasId": "canvas:abc123:brand-refresh" } }Check: you have the full node list, a revision (say rev_00291), and a url. On a large canvas a detail: "summary" page helps you find things, but it is not the whole graph: compute placement from a full read, and let canvas_validate check it against the server’s complete copy.
Compute the current bounding box from the node positions. You need it in the next step.
Know the layout and preservation rules
They are in the guide topics sections-layout and existing-canvases if you want the source:
{ "name": "guide_get", "arguments": { "guideId": "sections-layout" } }The rules this recipe follows:
- Place a new Section to the right of the existing bounding box with at least 160 units of outer spacing. If that makes the canvas excessively wide, place it below with the same spacing.
- 48 units of inner Section padding, 32 between sibling nodes, at least 80 between major clusters.
- A Section is a
textnode withmetadata.isSection: true, at least 200 × 160. Every child’s full frame must sit inside the Section; the server records membership itself after every batch. - One task, one Section: group the nodes you add in a titled Section of your own.
- “Add” never means “reorganise”. Do not move, resize, retitle, or reconnect an existing node.
Build the batch
Related creates and their connections belong in one batch. Use clientId and client: references to connect nodes that do not exist yet:
{
"canvasId": "canvas:abc123:brand-refresh",
"baseRevision": "rev_00291",
"idempotencyKey": "objections-section-2026-10-05-01",
"operations": [
{
"type": "node.create",
"clientId": "objections-section",
"node": {
"type": "text",
"title": "Customer objections",
"position": { "x": 3200, "y": 200 },
"width": 856,
"height": 344,
"metadata": { "isSection": true }
}
},
{
"type": "node.create",
"clientId": "objection-price",
"node": {
"type": "sticky",
"title": "Price",
"position": { "x": 3248, "y": 296 },
"width": 280,
"height": 200,
"metadata": { "content": "Too expensive versus the incumbent." }
}
},
{
"type": "node.create",
"clientId": "synthesis",
"node": {
"type": "text",
"title": "What this means",
"position": { "x": 3560, "y": 296 },
"width": 448,
"height": 200,
"metadata": { "content": "Lead with total cost of ownership, not unit price." }
}
},
{
"type": "connection.create",
"clientId": "price-to-synthesis",
"from": "client:objection-price",
"to": "client:synthesis"
},
{
"type": "node.delete",
"nodeId": "node:old4x5"
}
]
}Note the geometry: the Section starts at x: 3200, 160 units clear of the existing bounding box. Its children sit 48 units inside its left, right, and bottom edges, 32 units apart, and both frames lie entirely within it (3,248 to 4,008 across a Section that ends at 4,056; 296 to 496 down a Section that ends at 544), leaving room under the Section’s title.
Dry-run it
Send the same canvasId, baseRevision, and operations to canvas_validate — no idempotencyKey, because validation never consumes one:
{
"name": "canvas_validate",
"arguments": {
"canvasId": "canvas:abc123:brand-refresh",
"baseRevision": "rev_00291",
"operations": [ "…the same array…" ]
}
}The server runs the real operation engine without saving, builds the graph that would exist, and lints that.
Check, in this order:
-
destructiveImpact. This is the part to show a person.{ "deletedNodeHandles": ["node:old4x5"], "deletedConnectionHandles": ["connection:z1z2"], "mediaNodeHandles": [], "generatedNodeHandles": [], "findings": [ { "code": "proposed_destructive_change", "severity": "warning", "message": "The proposed batch deletes node:old4x5 and 1 attached connection(s). Apply only after explicit user intent." } ] }Deleting a node takes its connections with it — the message says how many. A non-empty
generatedNodeHandlesmeans you are about to delete work that cost money to produce; that needs an explicit confirmation, not a summary line. -
Findings marked
blocksWrite. Your batch would make new nodes overlap, or push a frame out of its Section.canvas_apply_batchwill refuse it. Move your nodes; do not move existing ones out of the way. -
summary.errors. Must be zero for the write to be safe. -
summary.warnings. Read every one. Warnings about work that was already on the canvas stay advisory and do not block your batch. -
proposalversuscurrentCanvas. Diffing node counts is a cheap check that you are adding what you think you are adding.
A 409 at this step means someone edited the canvas after you read it. Do not “fix” it by dropping baseRevision — that only removes the detection. Go back to the first step.
Get explicit intent for the deletion
The batch deletes a node. That needs the person to say so in the current turn, in response to the specific impact you just read:
This batch adds a “Customer objections” Section with 2 nodes and 1 connection, to the right of your existing work — nothing existing moves. It also deletes
node:old4x5and the 1 connection attached to it. No generated media is affected. Apply?
If the answer is no to the deletion but yes to the addition, that is a different payload and needs a new idempotency key.
Apply
{
"name": "canvas_apply_batch",
"arguments": {
"canvasId": "canvas:abc123:brand-refresh",
"baseRevision": "rev_00291",
"idempotencyKey": "objections-section-2026-10-05-01",
"operations": [ "…the same array you validated…" ]
}
}Atomic: if any operation is rejected, nothing is applied.
Check: the response is a receipt. wrote: true (or replayed: true if this key had already applied this payload); canvas.revision is the new revision; resolvedIds maps each clientId to the handle it became; changedNodeIds, deletedNodeIds, changedConnectionIds, and deletedConnectionIds list exactly what moved; and validation reviews the nodes and connections this batch changed. You do not need a separate canvas_validate call to see the outcome.
If the result is 422 “The batch was not applied”, read details.blockingFindings, fix those operations, and validate again. force: true exists for the case where the person has seen the listed findings and explicitly accepts them — not as a way past a finding you have not shown anyone.
Report and link
Applied at revision
rev_00292. Created Sectionnode:s5t6withnode:u7v8andnode:w9x0inside it, connectednode:u7v8→node:w9x0. Deletednode:old4x5andconnection:z1z2. Post-write validation: no errors, no warnings. Review it here:https://app.gavana.ai/…
Exact handles are the audit trail. “I added a section” is not. Use the url from your canvas_get.
Handling a 409 properly
A 409 is not an error to retry past. It means a person did something while you were working, and their change is now in the graph.
Re-read
{ "name": "canvas_get", "arguments": { "canvasId": "canvas:abc123:brand-refresh" } }You now have rev_00293 and a graph that has changed.
Look at what changed
If someone added a Section where yours was going, your coordinates now collide. If someone deleted the node your batch wanted to delete, that operation will fail.
Rebase, preserving their change
Recompute the bounding box. Move your new nodes; never move theirs. Drop any operation that no longer makes sense.
Decide about the idempotency key
- Payload byte-identical after rebasing? Reuse the same key.
- Anything changed — one coordinate, one dropped operation? New key.
Re-validate against the new revision
{
"name": "canvas_validate",
"arguments": {
"canvasId": "canvas:abc123:brand-refresh",
"baseRevision": "rev_00293",
"operations": [ "…rebased…" ]
}
}Then apply. If you hit a second 409, someone is actively working in that canvas — say so and stop rather than racing them.
The eight operation types
type | Required | Optional |
|---|---|---|
canvas.update | — | title, backgroundMode (dots | lines | blank), showImageInfo, viewport |
node.create | node | clientId |
node.update | nodeId, patch | — |
node.move | nodeId, position | — |
node.resize | nodeId, width, height | — |
node.delete | nodeId | — |
connection.create | connection, or both from and to | clientId, mode |
connection.delete | connectionId | — |
Nodes are image, video, text, or sticky, sized 40–10,000 on each axis. Connection modes are list, reference, first-frame, last-frame, prompt, or omitted for a plain dependency flow. Maximum 200 operations per batch, minimum 1. On an MCP connection with ?profile=advanced, canvas_apply_batch publishes these shapes as a typed schema, so a malformed operation fails before it reaches the engine.
Full field schemas are on the Canvases API resource.
Things the engine will reject
| Attempt | Result |
|---|---|
Writing image or video content into metadata.content | Rejected. Media is server-owned — use save_image_to_canvas or a generation tool. |
| New nodes overlapping each other or existing nodes | 422, batch not applied, unless the person accepts it with force: true. |
| A node whose frame escapes its Section | 422, batch not applied, unless forced. |
| Marking a non-text node as a Section, or one smaller than 200 × 160 | malformed_section error. |
| A width or height outside 40–10,000 | Rejected. |
A first-frame connection that is not image → video | unclear_connection error. |
| More than 200 operations | Validation error. Split the batch. |
Common mistakes
| Mistake | Why it hurts |
|---|---|
| Skipping the dry-run on a delete | You find out what a deletion takes with it after it is gone. destructiveImpact tells you first, for free. |
Omitting baseRevision to avoid 409s | You have not avoided the conflict, only the detection. Someone’s work gets overwritten. |
| Creating nodes in one batch and connecting them in another | The first batch leaves disconnected nodes, and the second can fail. |
| Placing children by their centre point | Membership is full-frame. A child that pokes out of its Section blocks the write. |
Reaching for force: true to get past a 422 | The findings are real. Fix your operations, or show them to the person first. |
| Reusing an idempotency key after rebasing | Different payload, same key. Unpredictable. |
| Moving existing nodes to make room | “Add” is not “reorganise”. Place your work clear of theirs. |