# Errors

Every error is JSON with a stable `type`, a `message`, a `fix` saying what to do next, a `docs_url` and a `request_id`. Branch on `type`; show or act on `fix`.

```json
{
  "error": {
    "type": "rate_limited",
    "message": "Too many verifications for this destination. Try again in 42 seconds.",
    "fix": "Wait for the number of seconds in retry_after before sending again.",
    "docs_url": "https://authtext.com.au/docs/errors/rate_limited.md",
    "request_id": "req_01JD3XA7Q2M7Q8R5T6V1W0XYZA",
    "retry_after": 42
  }
}
```

To see one in test mode, send to `+61400000003` with a test key.

| Type | Status | Fix |
|---|---|---|
| [invalid_request](errors/invalid_request.md) | 400 | Correct the field named in the message and send the request again. |
| [invalid_api_key](errors/invalid_api_key.md) | 401 | Send a valid key in the Authorization header as 'Bearer at_test_...' or 'Bearer at_live_...'. |
| [insufficient_balance](errors/insufficient_balance.md) | 402 | Ask the account owner to top up in the dashboard under Billing, or use an at_test_ key, which is free and sends nothing. |
| [insufficient_scope](errors/insufficient_scope.md) | 403 | Use a key that has the scope named in the message, or ask the account owner to create one. |
| [destination_not_allowed](errors/destination_not_allowed.md) | 403 | Send to an Australian mobile number, or ask the account owner to enable the destination country. |
| [account_suspended](errors/account_suspended.md) | 403 | Ask the account owner to resolve the billing or abuse hold in the dashboard. |
| [live_scope_required](errors/live_scope_required.md) | 403 | Ask the account owner to turn live sending on for this agent key, with a daily cap, in the dashboard under API keys, or remove 'live' from the request to keep working in test mode. |
| [not_found](errors/not_found.md) | 404 | Check the path and use the id returned by POST /v1/verifications with the same account's key. |
| [already_completed](errors/already_completed.md) | 409 | Treat the user as verified if a check already returned approved; otherwise start a new verification. |
| [idempotency_conflict](errors/idempotency_conflict.md) | 409 | Use a new Idempotency-Key for a new request, or retry the identical request in a few seconds. |
| [rate_limited](errors/rate_limited.md) | 429 | Wait for the number of seconds in retry_after before sending again. |
| [daily_cap_reached](errors/daily_cap_reached.md) | 429 | Wait until the cap resets at midnight UTC, or ask the account owner to raise the cap. |
| [internal_error](errors/internal_error.md) | 500 | Retry in a few seconds, and quote the request_id if you contact support. |
| [delivery_unavailable](errors/delivery_unavailable.md) | 503 | Retry in a minute; nothing was sent and nothing was billed. |

A wrong code is not an error. The check call returns 200 with status `denied` and the attempts left.
