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, emphasis, 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 participant 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.moved 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 a layered family, a new node in a frame without a layout goes inside it; when no place there keeps the frames round it clear of what lies beside them, the frame grows the same way (Layout engine: Positions are kept). 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.moved 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 }.
In a Google Cloud diagram, a node with frame set to a tier stands in the column of the zone whose spans lists it, so send updateFrame with that zone’s whole spans in the same edit; with no zone it goes last in its row. One in a Region, in the boundary or outside it takes the free place in its row, which opens when the place is too small. What lies past the growth moves, and the save’s changed.moved lists it (Layout engine: Google Cloud architecture diagrams).
In a stack of layers, a card with frame set to a layer stands in that layer’s row, and a layer that grows moves what lies after it along by the growth. A card with no layer is placed next to its neighbors by the general rules, not in the stack: list it in a layer (Layout engine: Layers).
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, and a node with a gcp:* icon draws Google’s product card whatever its shape (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 participants 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 an image as a data: URI (Element types: Icons).
emphasis: true marks the node as part of the one path a reader should follow. To mark a path, mark its edges: each marks its two end nodes. Mark a node itself only where no marked edge ends at it (Element types: Emphasis).
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 participant 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.
A card moved into a layer of a stack follows Layout engine: Layers.
emphasis: null or false removes the node’s own mark. It stays marked while a marked edge ends at it.
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.moved 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 or highlight band’s rows stay in the fragment or band 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.moved lists them (Making room). A smaller one pulls nothing back. The size is a minimum for a node whose label doesn’t wrap: one that needs more than the size you send is drawn bigger, and the save stores the size it is drawn at (Element types: Node size and wrapped text lists what stores none). A label set to word or character keeps the width you send.
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: emphasis: true marks the edge, and the node at each end, as part of the one path a reader should follow (Element types: Emphasis).
Optional: textStyle, with wrap alone ("auto", "none", "word", "character"): how a label wider than 200 px wraps. Send "auto" to undo "none" (Element types: Label wrapping).
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 column an end names, and follows it when it changes. An end that names no column needs cardinality unless the other end names a foreign key.
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, the open arrow in a diagram with AWS or Google Cloud groups or a node with an aws:* or gcp:* 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).
A line between two nodes that already have a position can leave its label with no room on its line. The engine then moves the nodes past the line’s two nodes just far enough to open it, in the cases Layout engine: Room for a label on an edit lists. Where it declines, the save’s warnings carry LABEL_ROOM_NOT_OPENED.
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.
emphasis: null or false removes the edge’s mark. Its end nodes stay marked only where they set emphasis themselves or another marked edge ends at them.
textStyle changes only the fields you give.
A change to what the label needs opens room the same way (Layout engine: Room for a label on an edit lists them). Any other change, such as a color, moves no node for a label.
Order in a sequence diagram
A sequence diagram draws its participants 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 participant 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 participant (a lifeline, an actor or any other participant type) goes next to another participant:
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). - A highlight band takes rows as a fragment does: a row placed next to one of its rows joins it, and a row given the band’s ID goes outside it. A participant box doesn’t take lifelines this way. A lifeline placed between two of a box’s lifelines stays out of its
children(FAMILY_SEQ_BOX_SPLIT), so givecreateNodeorupdateNodethe box asframetoo (Rendering: Participant boxes and highlight bands). - 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 given a new place in the order is a change, not a move: it is under
updatedin the edit’schangedandchangedin the compare, and counted as changed in the history. So is each fragment or highlight band it joined, left or moved within. A visual diff draws the element amber and rings each such fragment or band amber. A fragment or band left with no rows isn’t drawn (FAMILY_SEQ_EMPTY_FRAGMENT): move a row into it, or delete it. - The outline from
diagram_getlists messages and notes in this order, each fragment and highlight band before its first row, so read it to choose the ID.
A fragment or a highlight band is laid out with its rows wherever they move, and a participant box with its lifelines. Their own layout is ignored. A fragment’s 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"): how the text wraps;"auto"is a node’s default and"none"a text element’s (Text style, where lines break).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 takes wrap alone, a label being centered on its line; align and verticalAlign are ignored (Element types: Label wrapping).
A character the images can’t draw, such as a letter of Arabic, Hebrew or Thai, is drawn as an empty box, and the edit returns a CHARACTER_NOT_DRAWN warning (Rendering: Text and scripts).
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.moved 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, icon (a family:id key or image URL drawn in the frame’s header), laneDirection ("horizontal", "vertical"), frame, extensions
containerType is "generic", "pool", "lane", "subprocess", "partition", "package", "boundary", "fragment", "layer" or a cloud group (Element types: Container types):
- an AWS group,
"aws.cloud","aws.region","aws.vpc","aws.az","aws.subnet.public","aws.subnet.private","aws.securityGroup","aws.autoScalingGroup","aws.account"or"aws.corporateDataCenter", drawn as AWS draws the group, the first six also placing their members as AWS does; - a Google Cloud group,
"gcp.cloud","gcp.project","gcp.region","gcp.vpc","gcp.zone","gcp.subnet","gcp.tier","gcp.instanceGroup"or"gcp.onPremises", drawn as Google draws the group, the boundary, Region and subnet also placing their members as Google does.
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. Each element the new frame lists in children leaves that frame’s children, so it stays in one frame. It is refused when:
childrenlists an element a different frame holds, which would then be in two frames:MULTIPLE_FRAME_MEMBERSHIP.framenames a group, a node or any other element that isn’t a frame:OP_TARGET_KIND_MISMATCH.framenames an ID nothing has yet:OP_TARGET_NOT_FOUND. Create the outer frame in an earlier op, or list the new frame in itscreateFramechildreninstead.
{
"op": "createFrame",
"id": "az_b",
"containerType": "aws.az",
"title": "Availability Zone B",
"children": ["pub_b", "app_b"],
"frame": "vpc"
}
In an architecture diagram with zones as columns, 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. With zones as rows (layoutStrategy.direction LR), it becomes a row below the last, its subnets in the columns the other AZs share, and what lies below moves down. 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.
In a Google Cloud diagram, a Region created with frame set to the boundary goes right of the last Region, its rows level with theirs, and the boundary widens. A tier created with frame set to a subnet goes in at its place in the subnet’s flow, and the rows after it move down in every Region. A whole boundary an edit creates in a saved diagram, with its Regions, is laid out as on a new diagram, and so is a Region with no boundary round it. It goes next to the saved nodes it connects to, which keep their places (Layout engine: Google Cloud architecture diagrams).
In a stack of layers, a layer you create goes after the others, which keep their places. When a frame lists the stack’s layers, set frame to it, or the new layer isn’t part of the stack (Layout engine: Layers).
To put a layer between two others, send one edit:
deleteElementeach of the stack’s layers.createFrameeach again in the new order, with its cards and sub-groups inchildrenand, when a frame lists the layers,frameset to it.autoLayoutwithoutelements, which moves every node.
Without step 3 the saved cards keep their places and the layers draw in the old order. A line that ends on a layer is deleted with the layer, so create the line again.
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"]
}
In an AWS diagram, when its targets are subnets of one VPC or sit in them, the VPC makes room for its header, and what lies below moves down, listed in changed.moved. Otherwise it is drawn in the room its targets have, and SPAN_COVERS_NODE names a node its box covers.
A gcp.vpc or gcp.zone is a spanning frame too: a VPC spans its subnets, and a zone the nodes of one zone in one Region (Element types: Container types):
{
"op": "createFrame",
"id": "zone_b",
"containerType": "gcp.zone",
"title": "Zone b",
"spans": ["web_2", "app_2", "db_primary"]
}
A zone an edit adds comes after its Region’s other zones, so in Google’s arrangement its nodes make the Region’s last column. Either one written with children, or a zone spanning nodes of two Regions, gets GCP_GROUP_NESTING, which says what to change (Validation rules: Groups and frames).
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.
To change a nested fragment, delete it and create it again in one edit, with the same id, its rows in children, and frame naming the fragment that held it. Its rows leave the outer fragment’s children, and the new fragment goes back round them.
{
"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, and so does a Google Cloud group without its own style.
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 or Google Cloud 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). One exception: a longer title that widens a Google Cloud group moves what lies past the growth (Layout engine: Google Cloud architecture diagrams). 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. To change a frame’s box, send moveElement, which moves a frame with its cards, or resizeElement; updateFrame takes neither.
Google Cloud’s boundary, Region, subnet and tier presets work the same way: send the updateFrame ops and an autoLayout in the same edit to have the diagram arranged as Google draws it. Until autoLayout, nodes an edit adds to such a diagram are placed inside their frames, next to their neighbors, but outside Google’s rows and columns.
A frame with children that becomes a gcp.vpc or gcp.zone isn’t drawn as Google draws one, since those take spans. It gets GCP_GROUP_NESTING, whose fix says how to draw it again (Validation rules: Groups and frames).
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, fontFamily; Text and scripts), 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 most viewers don’t load, and is left out of PNGs. An icon given as such a URI gets the same warning.
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. In an AWS diagram they trade places in their row or column, and in a Google Cloud diagram in their row, where their places fit (Layout engine: AWS architecture diagrams, Google Cloud architecture diagrams). 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)
- an edit adds a line, or changes what its label needs, and the label has no room on its line, or
autoLayoutnames the line (createEdge, Layout engine: Room for a label on an edit) - 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 layer in a stack of layers grows for a card an edit adds to it or moves into it, or an edit adds a layer, and what lies after it moves along by the growth (Layout engine: Layers)
- 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
- a node an edit adds to a frame without a
layouthas no place there that keeps the frames round it clear of what lies beside them (createNode) - a node, tier or Region an edit adds to a Google Cloud diagram, or a group’s title it widens, needs its row, zone column, Region or project’s box to grow, or a line an edit adds opens a gap between two Regions, two projects or two zone columns, crosses an item in a row or moves an item under it (Layout engine: Google Cloud architecture diagrams)
- an edit finds the boxes of sibling projects in a Google Cloud diagram saved overlapping, and the node is in the project listed later or right of it
- 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
layoutStrategy,diagramFamilyorextensions.layoutHints
So autoLayout is how to get a fresh arrangement.
{ "op": "autoLayout", "elements": ["node-a"] }
Optional: elements, a list of node IDs and edge 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 (a card of a stack of layers, in its layer’s row) and clear of the other nodes, which stay where they are. That is the fix for NODE_OVERLAP_DETECTED. Listing a frame, group, text, image or guide element is an error.
An edge ID asks for room for that edge’s label: the nodes past the line’s two nodes move just far enough that the label stands on its line, as Layout engine: Room for a label on an edit describes. That is the fix for EDGE_LABEL_OVER_NODE where its fix names autoLayout. A call can list several edges. Sending the same call again changes nothing. A label that already has room leaves the edit unchanged (noop). Where the layout declines, the edit’s warnings carry LABEL_ROOM_NOT_OPENED for the edge, with the reason.
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, diagramFamily or extensions.layoutHints with updateScene places every node again too, the same way.
updateScene
Update scene-level metadata (title, brief, lang, theme, palette, styles registry, assets, layoutStrategy, diagramFamily, canvas, and four document settings in extensions) on an existing scene. A field takes null only where its row below says so.
{
"op": "updateScene",
"title": "Updated Architecture",
"theme": "dark",
"palette": { "nodeFill": "#003366", "edgeStroke": "#004488" },
"styles": { "highlight": { "fill": "#ffcc00", "stroke": "#cc9900" } },
"layoutStrategy": { "direction": "LR" },
"diagramFamily": "architecture",
"canvas": { "width": 1400, "height": 800 }
}
All fields are optional: send only what changes, and the rest is kept.
| Field | Sets |
|---|---|
title | The title |
brief | Up to 1,000 characters; null removes it |
lang | The language the text is in, a BCP 47 tag such as ja or zh-Hant; null removes it, and the language is inferred from the text (Scene schema) |
theme | clean (the default), dark, blueprint or sketch; clean removes the field, and null is refused |
palette | Merged color by color; null removes it |
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 | Replaced; null removes it |
diagramFamily | Replaced; null removes it |
canvas | Merged: omitted fields keep their values, and "background": null removes the canvas color |
extensions | Below |
A new layoutStrategy, diagramFamily or extensions.layoutHints, 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 then drops its own layout, except in org charts and networks. Only the members of a frame that keeps its layout stay where they are.
The other fields leave the elements where they are. A new theme keeps the layout and draws the new version in that theme (Rendering: Render themes).
extensions sets keys of the document’s top-level extensions, the ones the engine reads, and no others:
| Key | Sets |
|---|---|
autonumber | A sequence diagram numbers every message: true, or { "start": 10, "increment": 10 } with whole numbers from 1 (Layout engine: Numbered messages) |
showLifelineFeet | false draws no foot under a sequence diagram’s lifelines |
autoGroup | "byNodeType" draws a band behind each node type’s nodes in an architecture diagram or one without a family |
layoutHints | { "primaryDirection": "LR" }, with TB, BT, LR or RL: the direction of an org chart’s tree and of the layered layout, winning over layoutStrategy.direction. Network and sequence layouts don’t read it |
{ "op": "updateScene", "extensions": { "autonumber": true, "showLifelineFeet": false } }
Each key given replaces its value whole, and null removes it. The document’s other keys stay, and any other key is refused.
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), a note on a <br> saved as a line break, which can name an element the edit didn’t touch (LABEL_BREAK_TAG_CONVERTED), 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, and every element it only moved or resized. 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.