# Errors

> The error body, the status codes and what to do about each.

Page: https://percia.ai/docs/errors. Index of all docs pages: https://percia.ai/docs/llms.txt

# Errors

Errors are JSON:

```json
{
  "error": { "code": "invalid_request", "message": "Describe what to watch for", "field": "goal", "request_id": "req_411b5f5fd4eeda46aa6e" },
  "message": "Describe what to watch for",
  "request_id": "req_411b5f5fd4eeda46aa6e"
}
```

Branch on the HTTP status and `error.code`, never on the message text. `field` names the first invalid field on a validation error. Every response has an `x-percia-request-id` header, and a JSON error repeats it as `request_id`: **quote it when you ask for help** (Discord or support@percia.ai).

A plan limit (`429 plan_limit`) names the limit that was reached in `limit`:

```json
{
  "error": { "code": "plan_limit", "limit": "activeWatches", "message": "You can have up to 20 active watches. Pause or delete one first.", "request_id": "req_411b5f5fd4eeda46aa6e" },
  "message": "You can have up to 20 active watches. Pause or delete one first.",
  "request_id": "req_411b5f5fd4eeda46aa6e"
}
```

## Statuses

| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | `invalid_request` | A field failed validation | Fix the field named in `field` |
| 400 | `goal_not_allowed` | The goal asks to identify a person, recognise faces or infer emotion | Reword it |
| 400 | `pairing_invalid` | A camera pairing link is invalid, used or expired | Make a new one |
| 401 | `unauthenticated` | No credential, a wrong key, or an expired session | Check the key |
| 402 | `payment_required` | The last payment failed and the 48 hour grace is over | Update the card on the Billing page; do not retry |
| 402 | `card_required` | Redeeming a code needs a card on file | Add a card, then redeem again |
| 403 | `insufficient_scope` | The key lacks a scope; the answer names it | Create a key with that scope |
| 404 | `not_found` | No such thing, or it is not yours (the two look the same) | Check the id and account |
| 404 | `code_invalid` | A credit code is unknown, disabled or expired | Check the code |
| 409 | `camera_in_use` | A camera has watches | Delete or move the watches first |
| 409 | `code_already_redeemed`, `code_fully_claimed` | The account used the code, or it has none left | Do not retry |
| 409 | `unsupported_not_acknowledged` | Part of the goal cannot be watched | Tell the person, then send `acknowledgeUnsupported: true` |
| 422 | `clarification_needed` | The goal needs an answer; nothing was created | Answer the `question`, then create with the `draftId` |
| 422 | `invalid_request` with an old field name | An input from an older version (`cooldownS`, `zones` and similar) | Remove it and say it in the goal |
| 429 | `rate_limited` | Too many requests | Wait for `Retry-After`; do not loop |
| 429 | `plan_limit` | A limit was reached: 11th watch on a camera, 21st active watch on the account, billing, 20 connections | Read `limit` and `message` |
| 429 | `camera_limit` | 50 cameras | Delete one |
| 5xx | `internal_error` | A fault on our side | Retry with backoff. A create that returned 5xx may have succeeded: list your watches first |
| 503 | `integration_unavailable`, `layer_unavailable` and similar | That feature is not available right now | Try later |

A failed webhook delivery is not an API error. It shows on the event as `deliveryStatus: "failed"` (see [Events and webhooks](https://percia.ai/docs/webhooks.md#5-retries-and-failures)).

Every operation in the [API reference](https://percia.ai/docs/api.md) lists the statuses it can answer.
