# Errors

> What an error looks like, every code the API sends, and what to do about each.

On the web: https://www.aeyho.com/docs/api/errors

## What an error looks like

Every error is `application/problem+json` ([RFC 9457](https://www.rfc-editor.org/rfc/rfc9457)):

```json
{
  "type": "https://aeyho.com/docs/api/errors#busy",
  "title": "Conflict",
  "status": 409,
  "detail": "That reel is still being made. Ask again when it's ready.",
  "code": "busy",
  "requestId": "req_4f1c2a9b7e3d5c8a1b2c"
}
```

- `code` is stable within v1: switch on it, not on `detail`.
- `detail` is a sentence a person can read. It may change.
- `type` links to the code's section on this page.
- `requestId` is also in the `x-request-id` header. Send your own `X-Request-Id` (up to 64 characters) and it's used instead. Quote it when you write to us.

## Codes

### invalid

`400`. The request isn't right: a missing or wrong field, a body that isn't JSON, or something that can't be done (for example, a fix with nothing open to fix). `detail` names the field. Also sent with `413` when a request or a drawing is too big. Fix the request before you send it again.

### unauthorized

`401`. No key, or a key that's unknown, revoked or expired. Send `Authorization: Bearer aey_live_…` with a key from aeyho's settings. See [authentication and keys](/docs/api/authentication-and-keys).

### forbidden

`403`. The key is valid but doesn't have the scope this route needs. Give the key that scope, or use a key that has it.

### plan_required

`402`. Making things needs a paid plan. Pick a plan in aeyho, then try again.

### credits_required

`402`. The account doesn't have enough credits for this. More come with the plan's renewal or a top-up. `GET /account` shows the balance.

### not_found

`404`. That brand, reel, version, comment or webhook isn't in this account, or there's no such route in v1. Check the id. Sample ids from [test mode](/docs/api/test-mode) are never found.

### conflict

`409`. The request clashes with how things are. For example, a reel can only be fixed once it's made, and an account has at most 10 keys and 5 webhooks. `detail` says what clashed.

### busy

`409`. That reel or carousel is still being made. Wait until its `status` is `done` or `failed`, then try again.

### idempotency_mismatch

`409`. That `Idempotency-Key` was already used for a different request. Use a new key for a new request. See [idempotency](/docs/api/idempotency).

### rate_limited

`429`. Too many requests for this key. Wait for the seconds in the `Retry-After` header, then try again. See [rate limits](/docs/api/rate-limits). Also sent when a version already has its 40 comments: fix those first.

### unavailable

`500`, `502` or `503`. Something went wrong on our side, or a part isn't available right now. Try again with backoff. With an `Idempotency-Key`, retrying a `POST` is safe. [Status](/status) shows whether everything is up.

### test_mode

Kept for calls a test key can't make. No call sends it today.

## Retrying

- `400`, `401`, `402`, `403`, `404`: don't retry as is. Fix the request, the key or the account first.
- `409 busy`: retry once the reel is done.
- `429`: retry after `Retry-After` seconds.
- `5xx`: retry with backoff (for example 1, 2, 4, 8 seconds), with the same `Idempotency-Key`.

## Try it

```bash
curl -i https://www.aeyho.com/api/v1/reels/not-a-reel \
  -H "Authorization: Bearer $AEYHO_KEY"
```
