> ## Documentation Index
> Fetch the complete documentation index at: https://docs.diagramkit.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Responses and errors

Every error has the same shape; `issues` appears on `invalid_request`.

```json theme={null}
{
  "error": {
    "type": "invalid_request",
    "message": "Send {\"prompt\": \"...\"} with optional images, animate (true or false), preset (docs, blog, social, carousel, ad, data_story, explainer_video) and wait in seconds (0-300).",
    "issues": ["wait: Too big: expected number to be <=300"]
  }
}
```

![Decision diagram for a response: wait for it on 202 (poll GET /api/v1/diagrams/\{id}?wait=60) and 409 conflict (wait for the current change); retry it on 429 rate\_limited and 503 unavailable, with the same Idempotency-Key, which never charges twice; get a new link on 401 or 410 invalid\_link by downloading again with your key; fix before sending on 402 no\_credits (add credits), 403 plan\_required (upgrade or use PNG or JPEG), 400 invalid\_request and 422 not\_applied (fix the request) and 401 unauthorized (fix or replace the key).](https://mintcdn.com/diagramkit/sWlxT_qLaDK7vTGW/images/error-retry.png?fit=max\&auto=format\&n=sWlxT_qLaDK7vTGW\&q=85\&s=5c9a7c5a875d97c2a95cdb4942473ea0)

What to do with each response: wait for it, retry it, get a new link, or fix something before sending again.

| Status | Meaning |
| - | - |
| `200` | Done: the body is the finished job, or the file you asked for. |
| `202` | Accepted and still being made: the body is the job, with its id. Wait for it. |
| `400 invalid_request` | A parameter is missing or out of range. `message` says which; `issues` lists each problem. |
| `401 unauthorized` | No key, a malformed one, or a revoked one. |
| `401 invalid_link` | A download link that has expired or was not made for this file. Download it again with your key for a new link. |
| `410 invalid_link` | A download link made before the diagram's latest change. Download it again with your key for a new link. |
| `402 no_credits` | The balance cannot pay for this request. `message` says how many credits it needs and when plan credits return. Add credits, or turn on automatic top-up, at [https://app.diagramkit.ai/settings/api](https://app.diagramkit.ai/settings/api). |
| `403 plan_required` | The account's plan does not include this download: SVG and PDF are on paid plans. Do not retry; upgrade, or download PNG or JPEG. |
| `404 not_found` | No diagram with that id on this account, or it has no picture yet. |
| `409 conflict` | A change is already being made to this diagram. Wait for it, then send the next. |
| `409 not_animated` | You asked for an animation from a diagram that has none. Animate it first. |
| `422 too_long` | A video of every page would be too long for the format even at 1.5 seconds a still page. `message` says how many pages fit (`pages_fit`) and offers an MP4 or the all-pages PDF. |
| `422 not_applied` | An edit could not be made: no label matched `before`, an unknown part id, a part that cannot move, nothing changed, or the change would break the diagram (it is left as it was). `message` says why. |
| `429 rate_limited` | 50 requests are already in progress on this account. Wait for some to finish. |
| `503 unavailable` | The file could not be made right now. Retry shortly. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.