# Errors

Every error has one shape (RFC 9457), sent as `application/problem+json`, with a real HTTP status:

```json
{
  "type": "/WebInterface/api/v1/docs#error-forbidden",
  "title": "Forbidden",
  "status": 403,
  "code": "forbidden",
  "detail": "denied: target user holds rights you do not",
  "operation": "users.update",
  "permission": "users.user.edit.account",
  "request_id": "r-8f2c41d09a"
}
```

| Field | What |
|---|---|
| `code` | Stable: what a program switches on. The list is below. |
| `status` | The HTTP status again. |
| `detail` | What went wrong, in words, for a person. |
| `operation` | The operation that answered, when the path named one. |
| `permission` | For a refusal: the permission that was missing. |
| `errors` | For `validation_failed`: every field that fails, with its rule and a message. |
| `request_id` | The same as the `X-Request-Id` header; it finds the request in the server log. |

A program should switch on `code`, not on `detail` or `title`: those are words and may change.

## The codes

[[openapi API/openapi.json schema=Problem]]

## What to do

- **401 `unauthenticated`**: the credential is missing, wrong or expired. Get a new token.
- **403**: `forbidden` names the permission; ask `POST /explain` for the reason in full. `tier0` and `read_only_token` mean a token cannot do this at all; `legacy_account` means the account needs roles or a token.
- **404 `not_found`** is also the answer for an object outside the caller's scope, so that a scope cannot be mapped by trying names.
- **409 `conflict`**, **412 `precondition_failed`**: read the object again and decide again.
- **409 `fips_restricted`**: the server runs in [FIPS 140-3 mode](FIPS-Mode.md), which does not allow what was asked. `detail` says why and what to use instead, and `fips_id` names the item of [What FIPS mode changes](FIPS-Mode-Changes.md). Asking again will not help; change the request. `GET /server/fips` lists every item.
- **422 `validation_failed`**: fix the fields listed in `errors`.
- **429 `rate_limited`**: wait the seconds in `Retry-After`.
- **503 `unavailable`**: the server is starting or stopping; try again shortly.
