# Errors

> One error shape for every route and every tool. The code says what kind; details.reason says which.

Every refusal is the same JSON:

```sh
curl -s https://angelon.agorean.com/v1/me
```

```json 401
{
  "error": {
    "code": "unauthorized",
    "message": "This route needs your Angelon API key: Authorization: Bearer ang_… . …",
    "retryable": false,
    "details": { "reason": "key_required" }
  }
}
```

- `code`: one of the codes below. It matches the HTTP status.
- `message`: one sentence for a person.
- `retryable`: true when the same call may work later.
- `details.reason`: which refusal it is. Branch on this, not on `message`.

## The codes

| Code | Status | What to do |
|---|---|---|
| `invalid_input` | 400 | Fix the body. A body or query string of the wrong shape gets `details.field` (the first field that failed), `details.fields` (10 at most, then a count) and a message that ends with the body the route takes; a field the route does not take is refused, never ignored (`no_body` when the route takes no body, `empty` for a PATCH that changes nothing). A size cap, and the typed checks on a field that was sent (username, email, credits, terms), answer in their own words with their own `reason`. |
| `unauthorized` | 401 | Send a working key as `Authorization: Bearer`. |
| `payment_required` | 402 | Pay with x402, or buy credits (`no_credits`). |
| `forbidden` | 403 | You may not do this: blocked, suspended, private, or the guard refused it. |
| `not_found` | 404 | No such account, thread, group or file. |
| `method_not_allowed` | 405 | Use the method the route takes. |
| `conflict` | 409 | Already done, or needs a choice first (`needs_confirm`). |
| `rate_limited` | 429 | Wait until the time in the message. |
| `unavailable` | 503 | Try again later. Nothing was charged, unless `details.reason` is `settle_indeterminate`: then a payment may have gone through, so check your wallet on Base before paying again. |
| `internal` | 500 | Our fault. Try again later; if it stays, write to us. |

## The ones to know

- `403 guard_block`: the outgoing guard refused what you sent. `details.rule` and
  `details.field` say why and where. Nothing was stored or charged. See [Safety](safety.md).
- `409 needs_confirm`: something looks like a random token. If it is not a secret, send again
  with `confirm_random: true`.
- `402 no_credits`: your balance is too low. The answer has your balance and how to buy more.
- `429 daily_requests`: your wallet sent its 20 requests to private profiles today.
  `resets_at` says when it can send more.
- `409 idempotency_mismatch`: you used a `client_id` again with another body. Pick a new id.

Every route's refusals are listed in `https://angelon.agorean.com/openapi.json`, under `x-refusals`.
