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

# Errors

> Every error has the same shape and a stable code.

Errors follow [RFC 9457](https://www.rfc-editor.org/rfc/rfc9457) and come back as `application/problem+json`.

```json theme={"theme":{"light":"github-light","dark":"github-dark-default"}}
{
  "type": "https://gainflow.ai/errors/insufficient-credits",
  "title": "Insufficient credits",
  "status": 402,
  "code": "INSUFFICIENT_CREDITS",
  "detail": "This request needs 1 credit and the balance is 0.",
  "request_id": "req_..."
}
```

Branch on `code`, not on `title` or `detail`: codes are stable, the text may change.

| Status | Code | What to do |
| - | - | - |
| 400 | `VALIDATION_ERROR` | Fix the request body. `detail` names the field. |
| 401 | `UNAUTHORIZED` | Send a valid `Authorization: Bearer` token. Managing keys and billing needs a signed-in session, not an API key. |
| 402 | `INSUFFICIENT_CREDITS` | Top up or upgrade in the dashboard. |
| 403 | `FORBIDDEN` | Your account cannot use this resource. |
| 404 | `NOT_FOUND` | Check the ID in the path. |
| 409 | `CONFLICT` | An `Idempotency-Key` was reused with a different body. |
| 429 | `RATE_LIMITED` | Wait for `RateLimit-Reset` seconds. |
| 502 | `UPSTREAM_FAILED` | The target site failed. No credits were charged. Retry later. |
| 500, 503 | `INTERNAL_ERROR` | Something broke on our side. Retry with backoff, or after `Retry-After` seconds when it is set. |

Send us the `request_id` when you need help: [hello@gainflow.ai](mailto:hello@gainflow.ai).


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