API and MCP
LetDraw’s REST API and MCP server let external tools and AI clients (Claude, Cursor) work with your diagrams: list, read, create, update, generate a diagram from code, convert back to code, share, and generate from a prompt.
Who can use it
Section titled “Who can use it”The API and MCP are available to Pro and Enterprise users. On self-hosted installations, every signed-in member can use them. Free and guest users cannot create tokens.
1. Create a token
Section titled “1. Create a token”- Sign in to LetDraw with a Pro/Enterprise account.
- Go to Settings -> Developer.
- Create a token: give it a name, pick the scopes (see below), and optionally restrict it to a single workspace.
- The generated
ld_live_...token is shown only once. Save it somewhere safe. If it leaks, revoke it from the same page.
Scopes
Section titled “Scopes”| Scope | Permission |
|---|---|
diagrams:read | Read workspaces, folders, and diagrams |
diagrams:write | Create, update, delete, and share diagrams |
export | Export a diagram to Mermaid/D2 code |
ai:generate | Generate a diagram from a prompt (AI) |
2. Authentication
Section titled “2. Authentication”Send the token as a Bearer value in the Authorization header on every request:
Authorization: Bearer ld_live_...No extra apikey header is needed.
REST API
Section titled “REST API”Base URL: https://api.letdraw.com/api-v1
All responses are JSON. Errors return with a standard body: { "error": { "code", "message" } }.
| Method | Path | Description | Scope |
|---|---|---|---|
| GET | / | API info (scopes, endpoints) | any |
| GET | /workspaces | Your workspaces (with role) | read |
| GET | /folders?workspace=<id> | Folders in a workspace | read |
| GET | /documents?workspace=<id> | Diagrams in a workspace (paginated) | read |
| GET | /documents?folder=<id> | Diagrams in a folder (paginated) | read |
| POST | /documents | Create a diagram | write |
| GET | /documents/:id | Diagram + scene (elements) | read |
| PATCH | /documents/:id | Update name and/or elements | write |
| DELETE | /documents/:id | Delete a diagram | write |
| POST | /documents/from-code | Generate a diagram from code | write |
| POST | /documents/generate | Generate a diagram from a prompt (AI) | ai:generate |
| GET | /documents/:id/export?format=mermaid|d2 | Export a diagram to code | export |
| POST | /documents/:id/share | Create a public read-only link | write |
| DELETE | /documents/:id/share | Remove the public link | write |
Pagination
Section titled “Pagination”List endpoints take ?limit= (1-100, default 50) and ?cursor=. The response
returns a nextCursor; pass it as cursor to get the next page.
Rate limit
Section titled “Rate limit”120 requests per minute per token. Exceeding it returns 429 rate_limited.
Examples
Section titled “Examples”# List workspacescurl -H "Authorization: Bearer ld_live_..." \ https://api.letdraw.com/api-v1/workspaces
# Generate a diagram from a docker-composecurl -X POST -H "Authorization: Bearer ld_live_..." -H "Content-Type: application/json" \ -d '{"workspaceId":"<id>","code":"services:\n web:\n image: nginx\n depends_on: [db]\n db:\n image: postgres\n"}' \ https://api.letdraw.com/api-v1/documents/from-code
# Export a diagram to Mermaidcurl -H "Authorization: Bearer ld_live_..." \ "https://api.letdraw.com/api-v1/documents/<id>/export?format=mermaid"MCP server
Section titled “MCP server”Model Context Protocol (MCP) clients (Claude, Cursor) can connect to LetDraw and work with your diagrams through tools.
- URL:
https://api.letdraw.com/mcp - Transport: Streamable HTTP (stateless JSON-RPC 2.0)
- Auth:
Authorization: Bearer ld_live_...
| Tool | Description |
|---|---|
list_workspaces | Accessible workspaces |
list_diagrams | Diagrams in a workspace/folder |
get_diagram | Diagram + scene |
create_diagram | Create a diagram from an elements array (LetDraw or Excalidraw format, auto-detected) |
update_diagram | Update name/elements |
delete_diagram | Delete a diagram |
diagram_from_code | compose, kubernetes, dot, plantuml, terraform, helm, sql -> diagram |
export_to_code | Diagram -> Mermaid/D2 |
share_diagram | Create a public link |
unshare_diagram | Remove the public link |
generate_from_prompt | Diagram from natural language (AI) |
Client setup
Section titled “Client setup”You can copy ready-made config blocks with your own token from the
Settings -> Developer page. Replace ld_live_... below with your own token.
Cursor
Section titled “Cursor”~/.cursor/mcp.json (global) or .cursor/mcp.json in the project root:
{ "mcpServers": { "letdraw": { "url": "https://api.letdraw.com/mcp", "headers": { "Authorization": "Bearer ld_live_..." } } }}Claude Desktop
Section titled “Claude Desktop”Claude Desktop connects to the remote HTTP server through the mcp-remote bridge
(Node.js required). Config file:
- Windows:
%APPDATA%\Claude\claude_desktop_config.json - macOS:
~/Library/Application Support/Claude/claude_desktop_config.json
{ "mcpServers": { "letdraw": { "command": "npx", "args": [ "-y", "mcp-remote", "https://api.letdraw.com/mcp", "--header", "Authorization:Bearer ld_live_..." ] } }}Restart the client after saving. Example prompts:
- “List my LetDraw workspaces.”
- “Turn this docker-compose into a diagram in letdraw: …”
- “Export diagram
as Mermaid.” - “Generate an OAuth login flow diagram.”
- “Draw this cloud architecture in letdraw: …” (free-form composition)
Telling the AI to “draw it in LetDraw”
Section titled “Telling the AI to “draw it in LetDraw””create_diagram and update_diagram accept the elements array in two
formats: LetDraw’s own element schema or the Excalidraw format. The format
is auto-detected, and Excalidraw elements are converted to LetDraw elements on
the server side (including colored nested containers, shape-bound labels, arrows
with bindings, text, and frames).
What this means: when you tell ChatGPT, Gemini, or Claude to “draw this architecture in LetDraw”, the model produces the Excalidraw JSON it already knows very well from its training data and sends it over MCP; LetDraw draws the exact equivalent. Whatever the model’s layout quality is, that is what you get in LetDraw.
Embedding a diagram (render.svg)
Section titled “Embedding a diagram (render.svg)”You can embed a publicly shared diagram as SVG in places like a README or Notion.
First get a share token with share_diagram (or REST .../share), then:
https://api.letdraw.com/render-svg?token=<share-token>This endpoint returns image/svg+xml and requires no API token (only shared
diagrams are rendered), so you can use it directly inside <img src="...">.