docubend
Documentation

Diagrams

A diagram here is boxes joined by connectors that route around what is in the way — the same object the editor draws, made from text.

What you can send#

FieldTypeWhat it is
mermaidstringA mermaid flowchart or graph. Laid out on arrival, because mermaid carries no coordinates.
svgstringAn SVG, read into real shapes.
drawiostringA .drawio file's XML.
vsdxbase64 stringA Visio .vsdx file.
modelobjectA document model of your own — the same shape .json gives back.
Flowcharts only. mermaid's sequenceDiagram, classDiagram, stateDiagram, gantt, pie, journey and mindmap are detected and refused by name with a 422. They are not boxes and arrows, and turning one into loose rectangles would produce something that looks like a diagram and means nothing.

mermaid carries no coordinates — it declares a direction and lets a layout engine decide — so importing lays the diagram out and exporting throws the positions away. A round trip keeps the structure and not the arrangement, and the response headers say how much could not be said.

Make a diagram#

POST /api/v1/diagrams documents:write

From mermaid, an SVG, a .drawio or a Visio file, or a model of your own. What comes back is an editable diagram — boxes, connectors that stay attached, and text you can search — not a picture of one.

Mermaid carries no coordinates, so it is laid out on arrival: ranked so the arrows travel one way down the page, with subgraphs kept together. flowchart and graph only; sequence, class, state, gantt and the rest are refused by name with 422, because loose rectangles that mean nothing are worse than an honest refusal.

Body fields
titleoptionalDefaults to Untitled diagram.
mermaid / svg / drawio / vsdx / modelone requiredThe source.
curl
curl -s https://docubend.com/api/v1/diagrams \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Release pipeline",
    "mermaid": "flowchart LR\n  A[Build] --> B{Tests pass?}\n  B -->|yes| C[(Ship)]\n  B -->|no| D[Fix]\n  D --> A"
  }'
JavaScript
const mermaid = `flowchart LR
  A[Build] --> B{Tests pass?}
  B -->|yes| C[(Ship)]
  B -->|no| D[Fix]
  D --> A`;

const r = await fetch(`${BASE}/api/v1/diagrams`, {
  method: "POST",
  headers: { Authorization: `Bearer ${TOKEN}`,
             "Content-Type": "application/json" },
  body: JSON.stringify({ title: "Release pipeline", mermaid }),
});
const { document: doc } = await r.json();
Python
mermaid = """flowchart LR
  A[Build] --> B{Tests pass?}
  B -->|yes| C[(Ship)]
  B -->|no| D[Fix]
  D --> A"""

doc = requests.post(f"{BASE}/api/v1/diagrams",
    headers={"Authorization": f"Bearer {TOKEN}"},
    json={"title": "Release pipeline", "mermaid": mermaid},
    timeout=60).json()["document"]

Response

201
{
  "ok": true,
  "document": {
    "id": "6b35e4159e2e4b0e80ebae85f41cd6fd",
    "title": "Release pipeline",
    "kind": "diagram",
    "pages": 1,
    "shapes": 4,
    "version": 2,
    "your_role": "owner",
    "links": {
      "…": "as above"
    }
  }
}