Developers

DrawX API & MCP

Generate draw.io diagrams and full architecture designs from your own code, scripts, or AI agents. Use the HTTP API directly, or drop the MCP server into Claude, Cursor, or VS Code.

Authentication

All API requests are authenticated with a Bearer API key. Create one in your profile → API keys. Keys start with drawx_live_ and are shown once — store them securely.

Authorization: Bearer drawx_live_your_key_here

Base URL: https://getdrawx.com/api/v1

Quotas & rate limits

  • API usage is metered on a separate monthly tier from in-app usage.
  • Free — API access requires a paid plan.
  • Pro — 20 API calls / month included (bundled with the $9/mo plan), then pay-as-you-go.
  • Rate limit: 60 requests / minute. Exceeding returns 429 with retryAfterSeconds.

Endpoints

POST/api/v1/diagram/generate

One-shot: a natural-language prompt → a complete, valid draw.io mxfile document. Pass previousXml to modify an existing diagram.

curl -X POST https://getdrawx.com/api/v1/diagram/generate \
  -H "Authorization: Bearer $DRAWX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A checkout flow: gateway, order service, payment service, Postgres",
    "mode": "flash"
  }'

Response: { xml, valid, warnings, model, tokensIn, tokensOut, costUsd, latencyMs }

POST/api/v1/repo/generate

Analyzes a GitHub repository and returns a rich architecture diagram (2-pass: explain → graph). Built for CI automation — the DrawX GitHub Action uses this endpoint to regenerate + commit your diagram on every push. Blocks until generation completes (typically 40–90s).

curl -X POST https://getdrawx.com/api/v1/repo/generate \
  -H "Authorization: Bearer $DRAWX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "repo_url": "https://github.com/tiangolo/fastapi",
    "type": "auto",
    "mode": "ultra"
  }'

Response: { xml, explanation, diagramType, repo, model, mode, latencyMs }

For private repos, pass your GitHub Personal Access Token as github_token.

POST/api/v1/architect/run

Runs the Architect Co-Pilot: from a brief, produce a High-Level Design (and optionally a Low-Level Design + written design doc). Streams newline-delimited JSON progress events; the final line is a done event with the full result.

curl -N -X POST https://getdrawx.com/api/v1/architect/run \
  -H "Authorization: Bearer $DRAWX_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "brief": "Design a multi-tenant analytics platform ingesting 1M events/sec",
    "depth": "hld_lld",
    "style": "aws"
  }'
GET/api/v1/me

Returns your identity, plan, API tier, and remaining API quota. Useful to confirm a key works.

curl https://getdrawx.com/api/v1/me -H "Authorization: Bearer $DRAWX_API_KEY"

Errors

Every error returns { "error": string, "code": string } with an appropriate status.

CodeStatusMeaning
INVALID_INPUT400Request body failed validation.
AUTH_REQUIRED401No key or session supplied.
INVALID_API_KEY401Key is unknown or revoked.
QUOTA_EXHAUSTED403Monthly API quota reached — upgrade.
WALLET_EMPTY402Included calls used; top up your API wallet.
RATE_LIMITED429Too many requests; see Retry-After header.
SERVICE_UNAVAILABLE503Upstream model error; safe to retry.

GitHub Action — per-PR diagram sync

The DrawX GitHub Action regenerates your architecture diagram on every push and commits it back — so your documentation never drifts from the code. Setup takes 2 minutes.

  1. Create an API keyapp.getdrawx.com/profile#api-keys
  2. Add it as a repo secret — Settings → Secrets → Actions → DRAWX_API_KEY
  3. Add the workflow — copy this into .github/workflows/drawx-sync.yml:
name: "DrawX: Architecture Diagram Sync"
on:
  push:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: write
  pull-requests: write

jobs:
  drawx-sync:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - uses: SaharshPamecha/drawx-action@v1
        with:
          api_key: ${{ secrets.DRAWX_API_KEY }}
          # mode: commit        # or 'pr' for a pull request
          # generation_mode: ultra  # flash (3¢) | pro (8¢) | ultra (60¢)

Cost: each run uses one API call. Pro includes 20/month; beyond that, pay-as-you-go from your API wallet (Flash 3¢ / Pro 8¢ / Ultra 60¢ per call).

MCP server (Claude, Cursor, VS Code)

The @drawx/mcp-server exposes generate_diagram, architect_design, and whoami as MCP tools. Add it to your client config:

{
  "mcpServers": {
    "drawx": {
      "command": "npx",
      "args": ["-y", "@drawx/mcp-server"],
      "env": { "DRAWX_API_KEY": "drawx_live_..." }
    }
  }
}

Then ask your assistant: "Draw me a microservices checkout flow." Also listed on the official MCP Registry as io.github.SaharshPamecha/drawx-mcp-server.

Ready to build?

Create an API key and make your first request in under a minute.

Create an API key →