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

# Errors and retries

> How errors look, and which ones to retry.

A refused request answers `application/problem+json`:

```json theme={null}
{
  "type": "https://docs.magica.ai/toolbox/errors/insufficient-balance",
  "title": "Insufficient balance",
  "status": 402,
  "code": "INSUFFICIENT_BALANCE",
  "retryable": false,
  "request_id": "req_01JCB7Q2…"
}
```

* `code` is stable: branch on it, never on `detail`.
* `retryable` (and the `x-should-retry` header) says whether the same request can succeed later. When it is `false`,
  change the request first.
* `Retry-After` is the least time to wait, never more than 60 seconds.
* A run that fails after it starts is not an HTTP error: the run answers `200` with `status: "failed"` and an `error`.

Retry only on network errors, timeouts and the retryable codes, with exponential backoff and jitter (up to 30 s, at
most 4 retries), and keep the same [`Idempotency-Key`](/docs/concepts/idempotency) on every retry of a create.

> [card] [Every error code](/docs/api-reference/errors.md)
>
> The full list of request and run error codes, with when each happens and whether to retry.


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