Skip to content

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.

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. Sign in to LetDraw with a Pro/Enterprise account.
  2. Go to Settings -> Developer.
  3. Create a token: give it a name, pick the scopes (see below), and optionally restrict it to a single workspace.
  4. The generated ld_live_... token is shown only once. Save it somewhere safe. If it leaks, revoke it from the same page.
ScopePermission
diagrams:readRead workspaces, folders, and diagrams
diagrams:writeCreate, update, delete, and share diagrams
exportExport a diagram to Mermaid/D2 code
ai:generateGenerate a diagram from a prompt (AI)

Send the token as a Bearer value in the Authorization header on every request:

Authorization: Bearer ld_live_...

No extra apikey header is needed.

Base URL: https://api.letdraw.com/api-v1

All responses are JSON. Errors return with a standard body: { "error": { "code", "message" } }.

MethodPathDescriptionScope
GET/API info (scopes, endpoints)any
GET/workspacesYour workspaces (with role)read
GET/folders?workspace=<id>Folders in a workspaceread
GET/documents?workspace=<id>Diagrams in a workspace (paginated)read
GET/documents?folder=<id>Diagrams in a folder (paginated)read
POST/documentsCreate a diagramwrite
GET/documents/:idDiagram + scene (elements)read
PATCH/documents/:idUpdate name and/or elementswrite
DELETE/documents/:idDelete a diagramwrite
POST/documents/from-codeGenerate a diagram from codewrite
POST/documents/generateGenerate a diagram from a prompt (AI)ai:generate
GET/documents/:id/export?format=mermaid|d2Export a diagram to codeexport
POST/documents/:id/shareCreate a public read-only linkwrite
DELETE/documents/:id/shareRemove the public linkwrite

List endpoints take ?limit= (1-100, default 50) and ?cursor=. The response returns a nextCursor; pass it as cursor to get the next page.

120 requests per minute per token. Exceeding it returns 429 rate_limited.

Terminal window
# List workspaces
curl -H "Authorization: Bearer ld_live_..." \
https://api.letdraw.com/api-v1/workspaces
# Generate a diagram from a docker-compose
curl -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 Mermaid
curl -H "Authorization: Bearer ld_live_..." \
"https://api.letdraw.com/api-v1/documents/<id>/export?format=mermaid"

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_...
ToolDescription
list_workspacesAccessible workspaces
list_diagramsDiagrams in a workspace/folder
get_diagramDiagram + scene
create_diagramCreate a diagram from an elements array (LetDraw or Excalidraw format, auto-detected)
update_diagramUpdate name/elements
delete_diagramDelete a diagram
diagram_from_codecompose, kubernetes, dot, plantuml, terraform, helm, sql -> diagram
export_to_codeDiagram -> Mermaid/D2
share_diagramCreate a public link
unshare_diagramRemove the public link
generate_from_promptDiagram from natural language (AI)

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/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 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.

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="...">.