# Errors

Errors use HTTP status codes and a JSON body that says what went wrong.

```json title="HTTP 400"
{
  "error": {
    "code": "invalid_request",
    "message": "amount must be a positive integer",
    "param": "amount"
  }
}
```

- `code` is stable and meant for your code to check.
- `message` is for people; its wording can change.
- `param` is set when one request parameter is at fault.

## Codes

| Code | Status | Meaning |
|---|---|---|
| `invalid_request` | 400 | A parameter is missing or invalid. `param` names it. |
| `invalid_json` | 400 | The body is not valid JSON. |
| `unauthorized` | 401 | No API key, or the key is invalid or revoked. |
| `forbidden` | 403 | The key is not allowed to do this (e.g. a restricted key without the permission). |
| `account_not_active` | 403 | A live key was used before the account is active. |
| `currency_not_active` | 403 | A live payment was created in a currency whose account is not active. See [Amounts and currencies](/concepts/currencies.md). |
| `not_found` | 404 | No such object (or it belongs to the other mode). |
| `invalid_state` | 409 | The object is not in a state that allows this, e.g. refunding an unpaid payment. |
| `idempotency_conflict` | 409 | The Idempotency-Key was used before with a different request. |
| `rate_limited` | 429 | Too many requests. Back off and retry. |
| `internal_error` | 500 | Something went wrong on our side. Safe to retry with the same Idempotency-Key. |
| `provider_error` | 502 | The bank returned an error. |
| `provider_unavailable` | 503 | The bank is not reachable right now. Retry later. |

## Retrying

`429`, `500`, `502` and `503` are worth retrying with exponential back-off. Send the same `Idempotency-Key` on every retry of a POST so it can never be applied twice. `4xx` errors other than `429` will fail again until you change the request.
