Keys
- Create a key on your Account page, under API keys. It belongs to your workspace, is shown once, and goes in every request as
Authorization: Bearer <key>. svl_live_keys use the workspace's SVG Lab credits: 1 credit a Design Engine call, AI Generate 500 (700 on business plans). A call that fails costs nothing.test_keys are the sandbox: 1,000 test credits a month per workspace, the real operations, watermarked SVG and PNG, and no AI Generate, PDF or code.- Every key has a daily credit cap you set. Revoking a key stops it on its next call.
One full example
Start a project, draw in it, take the SVG:
curl -s https://svglab.app/api/v1/projects \
-H "Authorization: Bearer $SVGLAB_KEY" -H "Content-Type: application/json" \
-H "Idempotency-Key: coffee-1" \
-d '{"name": "Coffee shop badge"}'
{"ok": true, "project": {"id": "3f6c2a7e-8b1d-4c55-9a0e-2d7b8f1e4c90",
"name": "Coffee shop badge", "url": "https://svglab.app/?project=3f6c2a7e-8b1d-4c55-9a0e-2d7b8f1e4c90"},
"credits": 1, "job": {"id": "b2e4...", "status": "succeeded"}}
curl -s https://svglab.app/api/v1/projects/3f6c2a7e-8b1d-4c55-9a0e-2d7b8f1e4c90/run \
-H "Authorization: Bearer $SVGLAB_KEY" -H "Content-Type: application/json" \
-d '{"ops": [
{"op": "add_artboard", "args": {"name": "Badge", "width": 512, "height": 512}},
{"op": "create_shapes", "args": {"artboard": "Badge", "shapes": [
{"type": "shape", "kind": "ellipse", "x": 56, "y": 56, "width": 400, "height": 400, "style": {"fill": "#3B2418"}},
{"type": "text", "content": "BREW", "x": 256, "y": 270, "font_family": "Fraunces", "font_size": 96, "style": {"fill": "#F3E3C7"}}]}}]}'
{"ok": true, "result": [{"ok": true, "name": "Badge"}, {"ok": true, "shape_ids": ["s4", "s5"]}],
"created_ids": ["s4", "s5"], "warnings": [], "credits": 1}
curl -s "https://svglab.app/api/v1/projects/3f6c2a7e-8b1d-4c55-9a0e-2d7b8f1e4c90/export?format=svg&artboard=Badge" \
-H "Authorization: Bearer $SVGLAB_KEY" -o badge.svg
run also takes code: JavaScript that calls await sl.op(name, args), so one call can build a whole screen. GET /api/v1/ops lists the operations and GET /api/v1/ops/{name} gives one's arguments.
Routes
| Route | Does |
|---|---|
POST /projects, GET /projects, GET /projects/{id} | Start, list, describe (listing is free) |
POST /projects/{id}/run | Design Engine operations: ops or code |
POST /projects/{id}/look | The render with measured problems (overflow, overlap, contrast) |
POST /generate | AI Generate: a sentence or a picture in, SVG code out, marked as AI-generated in the file; optionally placed in a project |
POST /projects/{id}/photos | A free placeholder photo by description, cropped into a box, with the photographer's credit kept in the file |
GET /projects/{id}/export?format=svg|png|pdf|code | The finished file |
GET /jobs/{id}, GET /usage, GET /guides/{topic} | Jobs, receipts, the design guides |
The OpenAPI 3.1 document has every field, generated from the same catalog the SVG Lab MCP serves.
Long runs, retries and limits
- AI Generate takes 1 to 3 minutes. Send
"async": truefor a 202 and a job, then pollGET /api/v1/jobs/{id}, or addwebhook_url. Webhooks carrySVGLab-Signature: t=<unix>,v1=<hex>, the HMAC-SHA256 oft + "." + bodywith the key's webhook secret. - Send
Idempotency-Keyon every POST you might retry: a repeat returns the first answer and is never billed twice. - About 120 calls a minute and 8 at once per workspace. A refusal carries
retry_after_s.
Partners
A partner key serves your own customers: send SVGLab-End-Customer: <your id for them> on every call, never an email address. Each end customer has its own daily cap, sees only its own projects and jobs, and can be paused on your Account page without pausing you. Receipts name the end customer.
Errors
Every error is {"ok": false, "error", "message", "fix"}, and fix says what to change.
| error | What to change |
|---|---|
missing_key, invalid_key, key_revoked (401) | Send a current key as Authorization: Bearer; make one on your Account page. |
missing_scope, account_suspended, team_workspace_not_ready | Use a key with the scope named; write to support; use a personal workspace key. |
credits_needed (402) | Add credits on Billing. |
key_daily_cap, end_customer_daily_cap, sandbox_credits_used_up, rate_limited (429) | Wait until resets_at, raise the cap, or use a live key. |
sandbox_no_ai_generate, sandbox_export_format | Use a live key. |
end_customer_id_required, end_customer_id_email, end_customer_id_invalid, end_customer_not_partner, end_customer_suspended | Partner keys only: your own id (letters, digits, . _ : -); the partner can resume a paused customer. |
bad_request, invalid_json, payload_too_large, webhook_url_invalid, idempotency_key_invalid | Fix the field the message names (JSON, under 16 MB, a public https webhook). |
project_not_found, job_not_found, not_found | Use an id this key made or can see; check the path in the OpenAPI document. |
operation_failed (422) | The message names what to change in the operation. |
idempotency_in_progress, idempotency_key_reused | Poll the job; use a new key for a new request. |
editor_starting, still_running | Send it again after retry_after_s; check the project before repeating a long call. |
export_failed, ai_generate_failed, ai_generate_unavailable, limiter_unavailable, credits_unavailable, api_not_ready, unavailable | Nothing was charged: try again in a minute. |
Rules
The terms apply. Never present AI Generate output as made by a person, and never use the API for harmful content. Questions: support@svglab.app.