draft1 API documentation

Turn plain English, Terraform, docker-compose, or a SQL schema into an editable draw.io diagram. Everything the dashboard does that matters, the API does too.

Built for agents

Machine-readable spec: https://www.draft1.ai/openapi.json · Site summary for LLMs: https://www.draft1.ai/llms.txt · Agent integrations: draft1.ai/agents

Quickstart

Create a key at app.draft1.ai/settings/api, then:

curl -X POST https://api.app.draft1.ai/api/v1/diagrams \
  -H "X-API-Key: $DRAFT1_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "A 3-tier web app: load balancer, two app servers, one Postgres database"}'

Returns JSON with id, shareUrl, pngUrl and xml (a draw.io editor link). Generation takes roughly 20 to 60 seconds, so allow a generous client timeout.

Authentication

Every request needs the header X-API-Key: <your key>. Keys are created and revoked in Settings → API Access. A missing or revoked key returns 401.

Endpoints

EndpointWhat it does
GET/meAccount and remaining quota
GET/diagramsList diagrams created with this key
POST/diagramsGenerate a diagram
GET/diagrams/{id}Retrieve one diagram
PATCH/diagrams/{id}Iterate on an existing diagram in plain English

Check quota before you spend a turn

curl -H "X-API-Key: $DRAFT1_API_KEY" https://api.app.draft1.ai/api/v1/me
{"userId":"...","plan":"basic",
 "usage":{"used":3,"limit":null,"remaining":null,"unlimited":true}}

remaining is null when the plan is unlimited. If remaining is 0 a generation returns 402, so agents should check first rather than burning a turn.

Iterate on a diagram

curl -X PATCH https://api.app.draft1.ai/api/v1/diagrams/$ID \
  -H "X-API-Key: $DRAFT1_API_KEY" -H "Content-Type: application/json" \
  -d '{"instruction": "add a Redis cache between the API and the database"}'

List what you have made

curl -H "X-API-Key: $DRAFT1_API_KEY" \
  "https://api.app.draft1.ai/api/v1/diagrams?limit=20"

Paginate by passing the returned nextCursor back as ?cursor=. It is null on the last page.

Status codes

CodeMeaning
200Success
400Body missing a required string field
401Missing, invalid, or revoked API key
402Out of credits: upgrade the plan or buy a credit pack
404Diagram id not found for this key

Integrations

See draft1.ai/agents for the MCP server, the GitHub Action, and copy-paste setup for Claude, Cursor, and Codex.