# Errors (/errors)

When a call fails, the API returns an HTTP status code and a body in the standard **Problem Details** format ([RFC 9457](https://www.rfc-editor.org/rfc/rfc9457)). The content type is `application/problem+json`.

```http
HTTP/1.1 422 Unprocessable Content
Content-Type: application/problem+json
X-Request-Id: 01JD3W6Y7P4T

{
  "type": "https://docs.ajour.dk/errors/date-range-too-long",
  "title": "Date range is too long",
  "status": 422,
  "detail": "Sales lines allow at most 92 days. You asked for 120.",
  "requestId": "01JD3W6Y7P4T",
  "errors": { "to": ["Must be at most 92 days after from."] }
}
```

| Field | Meaning |
| --- | --- |
| `type` | A link to a page that explains the error. Use it in your code to tell errors apart. It does not change. |
| `title` | A short summary of the error type. |
| `status` | The HTTP status code. |
| `detail` | What went wrong in this request. The text can change. Do not use it in your code. |
| `requestId` | The same id as the `X-Request-Id` header. Send it to Ajour support when you report a problem. |
| `errors` | Only for invalid parameters: messages per parameter. |

## Error types [#error-types]

| Status | Type | When |
| --- | --- | --- |
| `400` | [`invalid-parameter`](/errors/invalid-parameter/) | A parameter has the wrong format or an unknown value. |
| `400` | [`impersonation-not-allowed`](/errors/impersonation-not-allowed/) | The request has the `Impersonation-Company-Id` header. |
| `400` | [`key-in-url`](/errors/key-in-url/) | An API key was found in the URL. |
| `401` | [`unauthorized`](/errors/unauthorized/) | The key is missing, wrong, revoked or expired. |
| `403` | [`missing-scope`](/errors/missing-scope/) | The key does not have the scope the call needs. |
| `403` | [`company-inactive`](/errors/company-inactive/) | The company's Ajour account is not active. |
| `403` | [`report-needs-all-locations`](/errors/report-needs-all-locations/) | The report needs a key for all locations. |
| `404` | [`not-found`](/errors/not-found/) | The item does not exist, or the location is outside the key. |
| `422` | [`validation-failed`](/errors/validation-failed/) | `to` is before `from`. |
| `422` | [`date-range-too-long`](/errors/date-range-too-long/) | The period is longer than the endpoint allows. |
| `422` | [`location-required`](/errors/location-required/) | A key for several locations must name one `locationId` for a report. |
| `429` | [`rate-limited`](/errors/rate-limited/) | Too many requests. Wait for `Retry-After` seconds. |
| `503` | [`report-timeout`](/errors/report-timeout/) | A report took longer than 90 seconds. |

## Which errors to retry [#which-errors-to-retry]

- Retry `429` after the `Retry-After` seconds.
- Retry `503` with a shorter period.
- Retry network errors and other `5xx` errors with a growing wait, for example 1, 2, 4 and 8 seconds.
- Do not retry `400`, `401`, `403`, `404` or `422`. Fix the request first.