Skip to Content
aiMermaid
API

Layout, groups and text

Move and resize steps, put them in groups, set the line style, copy steps and format labels through the API.

These operations go into a batch, like every change to a diagram:

POST /v1/projects/{id}/batch
{ "ops": [ { "op": "set_line_style", "style": "curved" } ] }

A batch is all or nothing. Ids such as n1 (steps), e1 (arrows) and g1 (groups) come from the brief, or from the as names you give in the same batch. Each operation costs 5. The full schema of every operation is on change a project with a batch.

Move a step or group

move puts a step or a group somewhere else. A group takes its contents along. Groups that hold the item grow so it stays inside.

Next to another item of the same level, with below, above, right_of or left_of:

{ "op": "move", "id": "offer", "below": "qualify" }

gap sets the space in pixels (default 40).

Or at an exact place with x and y, as in the project JSON: the centre of a step, or the top-left corner of a group.

Resize

  • Steps: update_step with width_steps and height_steps. Each is 0 to 20 extra grid steps of 20 px. 0 means automatic.
  • Groups: update_group with width and height in pixels. The top-left corner stays where it is.

Groups

group on update_step or update_group moves an item into a group (a group id of the same level) or out of it (null), like dragging in the editor. A group moves with its contents.

Line style

{ "op": "set_line_style", "style": "curved" }

straight (the default), curved or angled (right angles). It is one setting for the whole project and the Mermaid export keeps it. Same as line style in the editor.

Turn an arrow around

{ "op": "reverse_connection", "id": "e1" }

The arrow keeps its id and label.

Copy steps

{ "op": "duplicate_step", "ids": ["qualify"], "as": "qualify_copy" }

Copies steps of one level, with the arrows between them, below the originals. with_content (default true) also copies the label, notes, files and the level below. With false you get blank steps of the same type, color and group. as names the copy of the first step.

rich on update_step is a list of text runs. Their texts joined together become the label.

FieldMeaning
tThe text (required)
b, i, u, s, mtrue for bold, italic, underline, strike-through, monospace
zSize step, from -2 to 6
hrefA link (https or mailto)

Sending only label (or rich: null) makes the text plain again.

Rename a file or set its language

{ "op": "update_attachment", "on": "qualify", "id": "0b1c…", "name": "Budget rules" }

Renames a note or file. The file type ending stays. A name already used there gets a number. lang sets the language of a voice recording: a two-letter code such as pl or en, "other", or "" to clear it.

On this page