All paths are relative to https://api.diagrams.so/api/v2 and require a bearer key.

Generate a diagram

Create a diagram from a prompt. Generation is AI-backed and can take 30 seconds or more; for live progress use streaming, and set a generous client timeout.
Response (Paid)
New diagrams start private (is_public: false) on every plan. Make one public with PATCH /diagrams/{id}. The usage block is kept for compatibility. Nothing is metered: credits_remaining is always -1, and credits_charged is an internal cost figure, not a charge. See Plans & pricing.

Free plan replies

On Free, every reply that would carry the draw.io XML carries xml: null and four extra fields. This applies to generate, the stream’s complete event, get, get version, edit, fix and the re-layout result.
Response (Free)
The four extra fields appear only when the XML is withheld. A Paid reply has none of them, so it is the same as before. Test for xml_withheld, and do not treat xml: null as an error. Free keeps everything else: the diagram is stored, you can edit and fix it by id, and you can import a .drawio file. Idempotent replays follow the same rule, so a key replayed after a move to Free gets xml: null.

Generate with streaming

takes the same inputs as generate and streams server-sent events: progress events with stage, progress and message, then one complete event with the same body as POST /diagrams, or an error event. Progress events never carry XML. On Free the complete body has xml: null and the fields above. When you don’t need progress, use POST /diagrams.

Get a diagram

Read a diagram by id. On Free, xml is null (why).

List diagrams

List your diagrams, newest first. Supports pagination via limit and cursor.

Update a diagram

updates title, is_public, or the diagram xml. Diagrams are private until you set is_public to true.

Edit a diagram

Apply a natural-language edit. Typically takes 10 to 20 seconds.
The response returns the updated xml (null on Free), a refreshed score and warnings, and usage.

Fix a warning

Apply a fix for a specific Well-Architected finding. Typically takes 10 to 20 seconds. The reply has the same shape as edit. See Warnings & score.

Re-layout a diagram

Re-arrange the diagram for readability. Runs as an async job and needs ?confirm=true. See Async operations for polling.

Import a draw.io file

Bring an existing draw.io diagram in so you can edit and export it. Works on both plans. The reply is a summary (id, title, is_public and so on) with no XML.

Delete a diagram

Delete a diagram you own.
Versions: every edit/fix creates a version. List, read, and revert via the versions endpoints, documented in the Async & versions section.