# Errors

> Error format, status codes and error codes.

Every error is JSON with a `code` you can branch on and a `message` for people:

```json
{ "error": { "code": "invalid_api_key", "message": "This API key is invalid or was revoked." } }
```

| Status | Codes |
| --- | --- |
| `400` | `bad_request` |
| `401` | `invalid_api_key`, `missing_account_id`, `account_mismatch` |
| `402` | `out_of_credits` |
| `403` | `insufficient_scope`, `early_access`, `no_cloud_account`, `account_suspended` (with `resets_at` and `Retry-After`; see the [Abuse policy](/policies/abuse)) |
| `404` | `not_found` |
| `405` | `method_not_allowed` |
| `410` | `model_retired` (Model API: a retired model id, see [Line Code retirement](/models/line-code-retired)) |
| `413` | `too_large` |
| `429` | `rate_limited`, `too_many_runs`, `window_limit_reached`, `weekly_limit_reached`, `monthly_limit_reached` (app usage; with `resets_at` and `Retry-After`) |
| `502` | `upstream` |
| `503` | `unavailable` |

The [Errors guide](/agent/errors) explains each code and what to do about it.
