Operations
DSP changes a diagram with typed operations. Send them as ops, in one batch, to diagram_edit or POST /v1/diagrams/{id}/revisions, with the baseRevision you read and a one-line message (Sending operations). An edit that changes the diagram makes its next revision. Field names match ops.schema.json, and examples elsewhere in the docs follow this page.
Node operations
createNode
Create a new node element.
{
"op": "createNode",
"id": "my-node",
"nodeType": "service",
"shape": "roundedRect",
"label": "API Gateway"
}
Required: id, nodeType
Optional: layout, shape, label, textStyle, name, style, icon, zIndex, locked, visible, metadata, and extensions (an ER entity’s columns go here). Instead of layout, the shorthand x, y, width and height gives the node an absolute layout at those values. In a sequence diagram, after or before puts a lifeline, actor or note in its place (Order in a sequence diagram). frame, the ID of a frame that exists when the op runs (a pool, a lane, a boundary or any other frame), appends the node to that frame’s children, such as a new task in a lane that’s already there. It takes a frame’s ID only: naming a group, a node or any other element is the error OP_TARGET_KIND_MISMATCH, and an ID nothing has yet is OP_TARGET_NOT_FOUND, so create the frame in an earlier op, or list the node in its createFrame children instead.
Without layout, the engine places the new node next to its neighbors, clear of the other nodes, and keeps that position. The other nodes stay where they are, unless the new node’s edge label needs more room than the column it joins: then that column and everything past it along the flow move just far enough, and the save’s changed lists them (Layout engine: Positions are kept). A node an edit inserts in a flowchart, between two placed nodes, goes on the first one’s line, and what lies past it moves along the flow. A new node on a decision’s no exit goes beside the decision instead. In a flowchart with a frame that has no layout, new nodes are placed as in other families. A new task in a lane takes a free place in its column inside the lane; when there is none, the lane grows and what lies past it moves across the flow, and a task between two placed columns of a pool opens a column (Layout engine: Pools and lanes). In an AWS diagram, a node with frame set to a subnet takes a free place in its row, else the row grows and what lies right of it moves right; one with frame set to a Region or to AWS Cloud, or outside every AWS group, takes a free place in the Region’s column, the cloud’s row or the outside column, which opens there when the place is too small; a gateway with frame set to a VPC goes on its border on the side it faces, or on the top when it serves several AZs or the load balancer between two, as a fresh layout docks it (Layout engine: AWS architecture diagrams). When a labeled line from a VPC into the Region’s column then has too little clear run, the column moves right as one, with what lies right of the Region. The save’s changed lists those moves too. With a layout that puts it on another node, both stay where they are, and the save’s warnings include NODE_OVERLAP_DETECTED. To place it yourself, give layout, such as { "mode": "absolute", "x": 50, "y": 100, "width": 180, "height": 70 }.
shape is optional and defaults per nodeType, such as database → cylinder; give one only for a different glyph (Element types: Shapes). A node with an aws:* icon draws its icon alone whatever its shape, unless its style sets a fill other than white or it is an externalSystem (Element types: Icons), so leave shape out there.
zIndex is optional: by default containers paint behind nodes, edges between and overlays on top. Set it only to change the paint order. A frame inside another frame always paints after it, whatever their zIndex. In a sequence diagram, messages paint over the lifelines, actors and activation bars, whatever their zIndex; it still orders notes and the other elements.
icon takes a built-in key, such as lucide:database, or a URL (Element types: Icons).
updateNode
Update properties of an existing node.
{
"op": "updateNode",
"id": "my-node",
"label": "Updated Label",
"shape": "ellipse"
}
Required: id. At least one of the mutable properties (see Optional) must also be present.
Optional: any property from createNode except id and the x, y, width and height shorthand. icon: null removes the node’s icon. after or before moves a sequence diagram’s lifeline, actor or note (Order in a sequence diagram). textStyle is merged into the node’s: only the fields you give change, as with setText. frame moves the node into that frame, such as a task to another lane: the node leaves the children of every other frame and group that lists it, a group inside the new frame included, and is appended to the frame’s children unless it’s there already. A node already that frame’s direct child, and in no other frame or group, stays as it is. frame takes a frame’s ID only, never null, so it can’t take a node out of every frame; to do that, delete the frames that hold the node and create them again without it, in one edit.
style, layout, metadata and extensions are replaced whole, not merged; only textStyle is merged. To add a column to an er.entity, read its extensions.columns, add the column, and send the complete array with updateNode; there is no column operation.
deleteElement
Remove any element from the scene.
{ "op": "deleteElement", "id": "my-node" }
Required: id
Deleting an element also deletes the edges with an end at it, and leaves nothing pointing at what went: the IDs leave every group’s and frame’s children; a constraint that names the element as its container, source or target is removed, and so is one left with fewer elements than it needs (two, or one for contain and centerIn), while any other constraint just loses it; and an element placed relative to it gets an absolute layout at the box it was last drawn with, so it stays where it is. The edit’s warnings list each constraint removed (CONSTRAINT_REMOVED) and each layout made absolute (RELATIVE_LAYOUT_FIXED). The members of a deleted group or frame stay where they are, unless one would then lie inside another frame that doesn’t hold it. The engine places that one again, clear of it, and the edit’s changed lists it.
A deleted element’s ID leaves every spanning frame’s spans as well. A spanning frame left spanning nothing is deleted too, with its edges, and the edit’s warnings note it (SPAN_REMOVED). Deleting a spanning frame leaves its targets as they are.
In a sequence diagram, what names a deleted message or note moves off it. An operand that starts at it starts at its next row; one left with no rows is removed (FRAGMENT_OPERAND_REMOVED), and when that is the fragment’s first, the next opens the fragment with its guard as the frame’s title. An activation bar that starts at it starts at the next message, up to its last, that arrives at its lifeline, and one that ends at it ends at the message before, to or from its lifeline, or is one row tall when there is none; a bar left with nothing to start at is deleted too (ACTIVATION_REMOVED). A deleted fragment’s rows stay in the fragment around it.
moveElement
Move an element by a relative delta.
{ "op": "moveElement", "id": "my-node", "delta": { "dx": 50, "dy": -20 } }
Required: id, delta (with dx and dy)
Moving a frame or a group moves its members with it, and the members of frames and groups inside it, as containers move in other diagram tools. A member at x 0, y 0 isn’t placed yet and stays for the engine to place. A frame written without a layout is fitted around its moved members. A guide moves along the axis it marks.
moveElement refuses an edge, which the engine routes between its ends, and the nodes and frames of a sequence diagram, which it lays out from the messages (MOVE_NOT_SUPPORTED), and an element placed relative to another (MOVE_NOT_ALLOWED_FOR_RELATIVE_LAYOUT): change its layout with updateNode instead.
resizeElement
Change an element’s dimensions.
{ "op": "resizeElement", "id": "my-node", "size": { "width": 250, "height": 100 } }
Required: id, size (with width and height)
Optional: anchor ("top", "right", "bottom", "left") - the side that stays put. The element grows or shrinks away from that side and stays centered along it: with "bottom", the bottom edge keeps its place and the element grows upward. Without anchor, the top-left corner stays put.
To make a placed node bigger where it stands, name the side its flow enters: "left" in a left-to-right diagram, the default outside flowcharts and org charts, and "top" in a top-to-bottom one, the flowchart and org chart default ("right" and "bottom" for the reverses). The node then grows along the flow and keeps its center across it, so edges that ran straight into it still do. Without anchor it grows right and down from its top-left corner, its center moves by half the growth, and the engine doesn’t move it back. An edge that ran straight into it then takes a step where its end is held to the center: into a diamond’s corner, or a BPMN sequence flow or UI-flow transition 16 px or more off center (Where an edge enters its target). For example, a decision widened from 250 to 290 px without an anchor moves its center 20 px, and a start event’s flow into it then takes a step. To center nodes that have already moved, send autoLayout.
A placed node made bigger pushes the nodes in its way, keeping the gap they had, at most the node spacing, and the edit’s changed lists them (Making room). A smaller one pulls nothing back.
Resizing a frame written without a layout gives it one: the box it was last drawn with, at the new size. From then on it keeps that box instead of fitting its members, except a pool or lane, whose layout is a minimum: it still grows to hold its members, and a lane’s position comes from its pool. An element placed relative to another keeps its placement and takes the new size as its preferredSize; leave anchor out for it.
Some resizes are refused, because the engine would undo them. A node at x 0, y 0 isn’t placed yet: the engine gives it the size its content needs when it places it, so resize it in a later edit, or create it with a layout that has a position. A frame written without a layout and created in the same edit hasn’t been drawn yet, so resize it in a later edit or create it with a layout (both RESIZE_NOT_PLACED). The engine sizes a sequence diagram’s nodes and frames from the messages, and edges, groups and guides have no size (RESIZE_NOT_SUPPORTED).
Edge operations
createEdge
Create a connection between two elements, usually nodes. A frame or group can be an end: an edge to a frame ends at its border.
{
"op": "createEdge",
"id": "e1",
"from": { "elementId": "node-a" },
"to": { "elementId": "node-b" },
"label": "connects to"
}
Required: id, from, to
Optional: label, router ("straight", "orthogonal", "curved", "polyline"), style, endpoints, waypoints. The engine routes every edge itself: waypoints are kept with the edge but not drawn through, and polyline draws like orthogonal.
Optional: step (1 to 99), a numbered badge at the start of the line, and stepText, the edge’s line in the step list beside the drawing, which needs step (Element types: Numbered steps).
Optional: edgeType - family-specific edge type (e.g. "workflow.sequenceFlow", "er.relationship"). An endpoint’s anchor, and an ER edge’s column and cardinality, work as they do in a scene: an omitted cardinality is inferred from the columns, and follows them when they change.
Without endpoints, the edge gets the arrowheads of its edgeType, as an edge in a scene does: a filled triangle at the target for default, AWS’s open arrow in a diagram with AWS groups or a node with an aws:* icon. See Element Types: Edge types.
In a sequence diagram, a new message is added at the bottom; after or before puts it between two others (Order in a sequence diagram).
updateEdge
Update properties of an existing edge.
{
"op": "updateEdge",
"id": "e1",
"label": "new label",
"router": "orthogonal"
}
Required: id
Optional: any property from createEdge except id. from and to are replaced whole: an end sent without its anchor, column or cardinality loses them. A new edgeType brings its own arrowheads, apart from any the edge’s endpoints set that differ from its old type’s; endpoints is replaced whole too. after or before moves a sequence diagram’s message (Order in a sequence diagram).
step and stepText each change on their own. null removes one, and step: null removes both, since stepText needs a step.
Order in a sequence diagram
A sequence diagram draws its lifelines and actors left to right, and its messages and notes top to bottom, in the order of the scene’s elements. A new one is added last: a lifeline on the right, a message or note at the bottom. To put it somewhere else, give createNode or createEdge after or before, the ID of the element it goes next to; to move one that exists, give the same to updateNode or updateEdge.
{
"op": "createEdge",
"id": "m_cache_get",
"edgeType": "sequence.message",
"from": { "elementId": "checkout" },
"to": { "elementId": "cache" },
"label": "GET cart",
"after": "m_verify_ok"
}
- A lifeline or actor goes next to another lifeline or actor:
afterputs it on the right,beforeon the left. - A message or note goes next to another message or note, below it with
afteror above it withbefore, and joins that one’s fragment, leaving any other. Given a fragment’s ID, it goes below the fragment’s last row or above its first, outside the fragment (and inside the fragment that holds it, if any). So to add a message after a fragment rather than as its last row, name the fragment. - It joins that one’s operand too, so a row placed
beforean operand’s first row becomes its first. An operand whose first row moves away starts at its next row, and one left with no rows is removed (FRAGMENT_OPERAND_REMOVED). - The element named must exist when the operation runs: an earlier operation in the same edit can create it, a later one can’t (
ORDER_TARGET_NOT_FOUND). Give one of the two, not both. - No other element is drawn by its order, so other elements refuse both fields, and so does a message placed next to a lifeline, or a lifeline next to a message (
ORDER_NOT_SUPPORTED). - Moving an element to where it already is changes nothing. An element moved in the order is listed as changed in the edit’s
changed, the history and the compare, and so is each fragment it joined, left or moved within. A visual diff draws the element amber and rings each such fragment amber. A fragment left with no messages getsFAMILY_SEQ_EMPTY_FRAGMENT. - The outline from
diagram_getlists messages and notes in this order, each fragment before its first row, so read it to choose the ID.
A fragment is laid out with its rows wherever they move, and its own layout is ignored. Its operands start at rows (extensions.operands[].startsAt), so a divider stays between the same two rows whatever is added above or inside it (Rendering: Combined fragments). moveElement refuses a sequence diagram’s nodes and frames, whose positions follow from this order (MOVE_NOT_SUPPORTED).
Style and text
setStyle
Apply a named style or inline style overrides to an element.
{ "op": "setStyle", "id": "my-node", "style": "highlight" }
Or with inline overrides:
{ "op": "setStyle", "id": "my-node", "styleOverride": { "fill": "#ff0000", "strokeWidth": 2 } }
Required: id
Optional: style (named style token), styleOverride (inline StyleValue object)
Send one of the two. style replaces the element’s style. styleOverride merges onto the element’s current look: if the element uses a named style, its values from scene.styles are copied in first, so only the properties you send change.
setText
Set the label of a node or an edge, or the text of a text element. Optionally update text styling at the same time.
{ "op": "setText", "id": "my-node", "text": "New Label" }
With textStyle:
{
"op": "setText",
"id": "my-node",
"text": "Centered Label",
"textStyle": { "wrap": "word", "align": "center", "verticalAlign": "middle" }
}
Required: id, text
Optional: textStyle - an object with any combination of:
wrap("auto","none","word","character") -"auto", a node’s default, keeps its label on one line up to 250 px and wraps a longer one there, the node growing taller; on a text element it wraps by word when the text is wider than the element."none", a text element’s default, breaks lines only at\n."word"wraps the text at spaces to fit the element’s width, and a word wider than that runs past it;"character"wraps at spaces too and breaks such a word between its characters.align("left","center","right") - horizontal text alignmentverticalAlign("top","middle","bottom") - vertical text alignment
When textStyle is provided, it is merged with the element’s existing textStyle. Only the fields you include are updated; omitted fields keep their current values. This works on nodes and text elements; an edge has no textStyle, and ignores one.
Grouping
groupElements
Group multiple elements together.
{
"op": "groupElements",
"id": "group-1",
"children": ["node-a", "node-b", "e1"]
}
Required: id, children (at least one element ID)
Optional: title, style, layout, name, zIndex, metadata, extensions
A group draws nothing. Its title isn’t drawn: it is written into the SVG as the group’s <title> (Element types: Group). For a visible titled box, use createFrame.
ungroupElements
Dissolve a group, releasing its children.
{ "op": "ungroupElements", "id": "group-1" }
Required: id, which names a group. Naming any other kind is the error OP_TARGET_KIND_MISMATCH; remove other elements with deleteElement.
createFrame
Create a visual frame container.
{
"op": "createFrame",
"id": "frame-1",
"title": "Backend Services",
"children": ["api", "db"]
}
Required: id, and children (at least one element ID) or spans
Optional: title, style, layout. Without layout, the engine sizes the frame around its children on every save. Children already placed keep their positions, unless the frame fitted round them would overlap another frame or take in a node that isn’t its child. Then the engine places them again, together, clear of the other frames and nodes, and the edit’s changed lists them. Children without a position are placed inside it. Give layout ({ "mode": "absolute", "x": 20, "y": 20, "width": 500, "height": 300 }) to fix its position and size yourself; a pool’s or lane’s layout is only a minimum (below).
Optional: containerType ("generic", "pool", "lane", "subprocess", "partition", "package", "boundary", "fragment", or an AWS group: "aws.cloud", "aws.region", "aws.vpc", "aws.az", "aws.subnet.public", "aws.subnet.private", "aws.securityGroup", "aws.autoScalingGroup", "aws.account", "aws.corporateDataCenter", drawn as AWS draws the group, the first six also placing their members as AWS does: Element types: Container types), icon (a family:id key or image URL drawn in the frame’s header), laneDirection ("horizontal", "vertical"), frame, extensions
frame, the ID of a frame that exists when the op runs, appends the new frame to that frame’s children: a new lane goes after the pool’s other lanes, and a new Availability Zone after the VPC’s others. It takes a frame’s ID only: naming a group, a node or any other element is the error OP_TARGET_KIND_MISMATCH, and an ID nothing has yet is OP_TARGET_NOT_FOUND, so create the outer frame in an earlier op, or list the new frame in its createFrame children instead.
{
"op": "createFrame",
"id": "az_b",
"containerType": "aws.az",
"title": "Availability Zone B",
"children": ["pub_b", "app_b"],
"frame": "vpc"
}
In an architecture diagram the new Availability Zone becomes a column right of the VPC’s last, its subnets in the rows they share with the other AZs, and what lies right of the VPC moves right to make room; the AZs before it keep their places (Layout engine: AWS architecture diagrams). Its subnets and their nodes can be created in the same edit, each subnet listing its nodes in children.
spans, instead of children, makes a spanning frame, drawn round the nodes and frames it lists outside the containment tree, such as an Auto Scaling group across two Availability Zones (Element types: Spanning frames). It takes neither children nor frame: either one is SPAN_INVALID. Its targets may be elements the same edit creates; one that nothing creates is OP_TARGET_NOT_FOUND.
{
"op": "createFrame",
"id": "asg",
"containerType": "aws.autoScalingGroup",
"title": "Auto Scaling group",
"spans": ["private_a", "private_b"]
}
When its targets sit in a VPC’s rows in an AWS diagram, the rows make room for its header, and what lies below moves down, listed in changed. Elsewhere it is drawn in the room its targets have, and SPAN_COVERS_NODE names a node its box covers.
A process with lanes is a frame with containerType: "pool" whose children are frames with containerType: "lane", each listing its tasks, events and gateways. Leave layout off all of them and off their nodes: the engine stacks the lanes across the flow in the order the pool’s children list them, places every node a lane lists inside that lane, fits each lane to its contents and shares columns across lanes and pools. A pool’s or lane’s layout is a minimum, so a pool grows right and down from its corner to hold its lanes and members. laneDirection: "vertical" stacks the lanes top to bottom and the flow runs left to right; "horizontal" puts them side by side and the flow runs top to bottom. To add a task to a lane later, send createNode with frame set to the lane’s ID; to move a placed task to another lane, send updateNode with frame. The engine places the task in its lane, in its column, and grows the lane when the column has no room (Layout engine: Pools and lanes).
To add a lane to a saved pool, send createFrame with frame set to the pool’s ID and the lane’s first task in children: the lane goes after the pool’s other lanes. No operation changes the order of a saved pool’s lanes: updateNode’s frame moves nodes only, and updateFrame doesn’t change children. To reorder them, in one edit, deleteElement the pool and createFrame it again with the same id, its title, laneDirection and any style or layout, and its lanes in children in their new order: an existing lane, or a new one created in the same edit. The members of a deleted frame stay where they are (deleteElement), so the lanes and their tasks stay. Edges with an end at the pool itself, such as a message flow to a pool with no members, are deleted with it, and a constraint that names it is removed or loses it, so create those again in the same edit. createFrame needs at least one child, so create a new lane with its first task in children. Placed tasks keep their positions and lanes are never pulled back, so lanes the new order moves later are pushed past the lanes now before them; send autoLayout for a compact picture.
A sequence diagram’s combined fragment is a frame with containerType: "fragment", its messages and notes (and any fragments nested in it) as children, and extensions: operator (alt, opt, loop, par and so on, drawn as written) and, for each operand after the first, operands: [{ "startsAt": "<message or note ID>", "guard": "card declined" }]. The frame’s title is the first operand’s guard, drawn as written, so write its brackets ("[charge succeeded]"); the renderer adds the brackets round each operand’s guard, so write it without them. The engine lays a fragment out with its rows, so leave layout out; it is ignored. An operand with a y (written before 8.0.0) is refused. updateFrame doesn’t change extensions, so to change a fragment’s operands, delete the frame and create it again in one edit.
{
"op": "createFrame",
"id": "frag_charge",
"containerType": "fragment",
"title": "[charge succeeded]",
"children": ["m_charge", "m_charge_ok", "m_charge_retry", "m_charge_retry_ok"],
"extensions": { "operator": "alt", "operands": [{ "startsAt": "m_charge_retry", "guard": "retry on 5xx" }] }
}
updateFrame
Change a saved frame’s title, style, icon, containerType or laneDirection, such as renaming a VPC or making a generic frame an AWS group, or a spanning frame’s spans.
{ "op": "updateFrame", "id": "vpc", "title": "VPC 10.0.0.0/16", "containerType": "aws.vpc" }
Required: id, which names a frame, and at least one of the fields below. Naming any other kind is the error OP_TARGET_KIND_MISMATCH.
Optional: title, style (a named style or an inline style, replacing the frame’s whole), icon, containerType and laneDirection, as on createFrame. null removes the style, the icon, the container type (the frame becomes generic) or the lane direction; an AWS group without its own style or icon draws its preset’s.
Optional: spans, on a spanning frame only, replaces its whole list of targets and lists at least one. On a frame written with children it is SPAN_INVALID: create a spanning frame with createFrame instead.
The frame keeps its members, its position and its size, and its nodes stay where they are: a frame that becomes an AWS group is drawn as one where it is, and a renamed frame changes only its title (a frame without a layout widens for a longer title). To make a saved diagram’s frames AWS Cloud, Region, VPC, Availability Zone and subnet groups and have it arranged as AWS draws it (Availability Zones as columns, subnets as rows), send the updateFrame ops and an autoLayout in the same edit; it lays out every node again, hand-placed ones too. It doesn’t change children: createNode or updateNode with frame puts a node in a frame, and createFrame with frame a new frame. moveElement and resizeElement move and resize a frame, and setStyle changes its style too. A fragment’s operands are its extensions, which updateFrame doesn’t change.
Text and images
createText
Add a standalone text element: a caption, legend, title or note, outside any node. It is the same element a scene holds as { "kind": "text" }, so setText (its words and textStyle), setStyle, moveElement, resizeElement and deleteElement change it afterwards.
{
"op": "createText",
"id": "caption",
"text": "Figure 1: the checkout path",
"layout": { "mode": "absolute", "x": 40, "y": 20, "width": 320, "height": 24 },
"textStyle": { "align": "left" },
"style": { "fontSize": 13, "textColor": "#334155" }
}
Required: id, text, layout (a text element is placed where its layout says; the engine doesn’t place it)
Optional: textStyle (wrap, align, verticalAlign; without them the text is one line per \n, at the box’s top left), style (fontSize, fontWeight, textColor; text is drawn in Inter whatever fontFamily says), name, zIndex, locked, visible, metadata, extensions
A node with a label is still the way to put text in a shape. createNode with kind: "text" is refused and points here.
createImage
Add an image element: a logo or screenshot, showing one of the scene’s assets. Add the asset with updateScene first, in the same edit or an earlier one.
[
{ "op": "updateScene", "assets": { "logo": { "kind": "image", "mimeType": "image/png", "uri": "data:image/png;base64,iVBORw0..." } } },
{ "op": "createImage", "id": "logo-img", "assetRef": "logo", "layout": { "mode": "absolute", "x": 600, "y": 20, "width": 80, "height": 40 }, "fit": "contain" }
]
Required: id, assetRef (an asset ID in the scene’s assets), layout
Optional: fit ("contain", "cover", "stretch" or "original"), style, name, zIndex, locked, visible, metadata, extensions
An image whose asset isn’t there is refused (ASSET_NOT_FOUND). Use data: URIs: a remote http or https URI gets the warning ASSET_URI_POLICY_VIOLATION, stays a link that a viewer’s browser loads when it shows the SVG, and is left out of PNGs.
To show a different picture, replace the asset under the same ID with updateScene. moveElement, resizeElement and setStyle change an image or text element; nothing else changes its name, zIndex, visible, locked, metadata, or an image’s fit or assetRef. To change those, delete it and create it again in the same edit.
Constraints
addConstraint
Add a spatial constraint.
{
"op": "addConstraint",
"constraint": {
"type": "align",
"axis": "y",
"elements": ["node-a", "node-b", "node-c"]
}
}
Required: constraint (object with type and type-specific fields)
Axis values: "x", "y"
Constraints has every type and its fields. An order constraint added to a saved diagram takes effect in the same edit: when its two nodes don’t already stand in that order, the engine places both again, in order, around the nodes that keep their positions; nodes already in order stay where they are. The other types apply on every save.
removeConstraint
Remove a constraint by its ID.
{ "op": "removeConstraint", "id": "c1" }
Required: id
Layout
autoLayout
Have the engine place nodes again, and keep where it puts them. Nodes keep their positions after the first save, even when nodes around them are added or deleted. They move only when:
- a node that grows needs the room
- a new node’s edge label needs more room than the column it joins (createNode)
- a task an edit adds to a pool, or moves to another lane, needs room in its lane or a column of its own (createFrame)
- a node an edit inserts in a flowchart, between two placed nodes, needs room along the flow (createNode)
- a node or a spanning frame’s header an edit adds to an AWS diagram, or the room round a tier frame, needs its row or column to grow (createNode, createFrame)
- an edit that places nodes in or joined to an AWS Region’s column, or adds an edge into it, leaves a labeled line into it too little room, and the column moves right
- an edit adds or deletes a frame around them, and keeping them would leave frames overlapping or a frame holding a node that isn’t its member (createFrame, deleteElement)
- an
orderconstraint you add finds its two nodes the wrong way around (addConstraint) - updateScene changes or removes
layoutStrategyordiagramFamily
So autoLayout is how to get a fresh arrangement.
{ "op": "autoLayout", "elements": ["node-a"] }
Optional: elements, a list of node IDs. Without it, the engine lays the diagram out again, as a new diagram, and sizes the canvas to fit. With it, the engine places only the listed nodes again, next to their neighbors and clear of the other nodes, which stay where they are. That is the fix for NODE_OVERLAP_DETECTED. elements names nodes only: frames and edges are redrawn from the nodes on every save, so listing one is an error.
Without elements, in architecture, workflow, entity-relationship, UI flow and flowchart diagrams and diagrams without a family, every frame but a pool, lane or fragment drops its own layout and is laid out with its members, fitted round them. A pool, lane or fragment with its own layout keeps it (for a pool or lane, as a minimum), and its members stay where they are; so does every frame with its own layout in an org chart or network, whose layouts place nodes without regard to frames. The engine then places the other nodes around them without resizing the canvas. With elements, a frame with its own layout keeps it, and its listed members are placed again inside it. A lane grows to hold a listed member when the member’s column has no room; in any other frame, one that doesn’t fit lands outside, and the edit’s warnings include NODE_OUTSIDE_FRAME.
Nodes with a relative layout follow the node they’re placed against, and the engine lays sequence diagrams out from their messages on every save, so autoLayout doesn’t move either. An edit that lands every node where it already was makes no new revision (noop). To move a node yourself, send updateNode with a new layout. Changing or removing layoutStrategy or diagramFamily with updateScene places every node again too, the same way.
updateScene
Update scene-level metadata (title, brief, palette, styles registry, assets, layoutStrategy, diagramFamily, canvas) on an existing scene. Fields set to null are removed; unspecified fields are left unchanged. Styles and assets are merged additively; canvas is partially merged.
{
"op": "updateScene",
"title": "Updated Architecture",
"palette": { "nodeFill": "#003366", "edgeStroke": "#004488" },
"styles": { "highlight": { "fill": "#ffcc00", "stroke": "#cc9900" } },
"layoutStrategy": { "direction": "LR" },
"diagramFamily": "architecture",
"canvas": { "width": 1400, "height": 800 }
}
Optional: title, brief (up to 1,000 characters, or null to remove), palette (or null to remove), styles (merged additively with the existing registry), assets (entries added or replaced by ID, for createImage; an entry set to null is removed, refused while an image still shows it), layoutStrategy (or null to remove), diagramFamily (or null to remove), canvas (partially merged - omitted fields keep current values).
All fields are optional - include only the metadata you want to change. Omitted fields are preserved. Use this operation to modify scene-wide settings without recreating the scene. A new layoutStrategy or diagramFamily, or removing one, lays the diagram out again as autoLayout without elements does, under the new value: every frame but a pool, lane or fragment drops its own layout, except in org charts and networks, and only the members of a frame that keeps its layout stay where they are. The other fields leave the elements as they are.
History
restoreRevision
Make the next revision equal to an earlier one. History is never rewritten: the old content becomes a new revision, and every revision in between stays readable.
{ "op": "restoreRevision", "revision": 3 }
Required: one of revision and asOf. restoreRevision must be the only operation in its edit. Restoring the content the diagram already has makes no new revision (noop: true).
To restore by date, give the edit a restoreRevision argument instead of ops: { "restoreRevision": { "asOf": "2026-09-26" } } on diagram_edit or POST /v1/diagrams/{id}/revisions restores the revision that was current at that instant. asOf is a date (the end of that day in UTC) or an ISO 8601 timestamp with an offset, such as 2026-09-26T14:00:00Z. restoreRevision: 3 works there too. The operation takes asOf as well, in place of revision: { "op": "restoreRevision", "asOf": "2026-09-26" } restores the same revision.
Sending operations
An edit looks like this:
{
"baseRevision": 1,
"message": "Add the cache in front of the database",
"requestId": "6f1c2e7a-4b0d-4c55-9a51-2f1f8f7c9d10",
"ops": [{ "op": "createNode", "id": "cache", "nodeType": "database", "label": "Cache" }]
}
Send it as the arguments of diagram_edit, with the diagram’s id beside them, or as the body of POST /v1/diagrams/{id}/revisions, which takes the diagram’s ID or key from the path.
Fields:
baseRevision(required) - the revision you planned the edit against. If another write got there first, the call returns 409REVISION_CONFLICTwith the currentrevisionandchanges, what changed since yours. Re-plan against the current revision and send the edit again.message- one line saying what the edit does, kept with the revision like a commit message.diagram_editrequires it; the REST API saves an edit without one.requestId(optional) - your ID for this edit, unique per diagram (a UUID works). A retry with the samerequestIdreturns the revision the first attempt made, withreplayed: true, instead of making a second one. Reusing it for a different edit returns 422REQUEST_ID_REUSED.ops- the operations, applied in order: up to 500 in one edit. Split a larger change into several edits.
Every edit is all or nothing. If any operation has an error, or the revision the edit would make breaks a rule the diagram didn’t break before, such as an edge to an element that isn’t there, the call returns 422 VALIDATION_FAILED with the errors and saves nothing. Operations run in order, but their order only matters for the element an operation changes, which must exist by then: an edge, a group, a frame, a style, a relative layout or a constraint can name an element that a later operation in the same edit creates. The element after or before names, and the frame a createNode or updateNode frame names, are the exceptions: they must exist when the operation runs. A saved edit returns warnings for the new revision: the diagram family’s rules it breaks, what drawing it noticed, notes on fields the API dropped from what it was sent (PORTS_REMOVED), and notes on what a deleteElement changed besides the element it named (a constraint it removed, or an element placed relative to the deleted one), each with a code, the element when there is one, and a one-line fix. Other changes an edit makes on its own get no note; changed lists every element it added, updated or removed. Validation rules lists the codes.
An edit that leaves the diagram unchanged makes no revision: the response has noop: true and the current revision. A retry without a requestId is also safe in the common case: if the diagram already equals what the edit asked for, the call returns noop: true instead of a conflict.
ops.schema.json also lists schemaVersion and sceneId. The API sets them itself and ignores them in a request: the diagram comes from the path or id.