# Errors

v1 and v2 report most errors in the response body, while v3 uses HTTP status codes. In every
version, check both the HTTP status and the body.

## v1 and v2

Responses include `succeed`. When a request fails, `succeed` is `false` and `message` describes the
error:

```json title="Error response"
{
  "succeed": false,
  "message": "list (123) does not exist"
}
```

These errors, including invalid parameters and failed authentication, have HTTP status 200, so
check `succeed`, not just the status. In the API reference, they are the `default` response of
each endpoint.

### Error messages

| Message                        | Reason                                                                         |
| ------------------------------ | ------------------------------------------------------------------------------ |
| `Unauthorized (token expired)` | Authentication failed. See [Handling errors](#handling-errors).                |
| `<endpoint> not supported`     | v1 has no endpoint with that name. Endpoint names are case-sensitive.          |
| `Unknown method`               | v2 has no endpoint with that path.                                             |
| `empty content`                | The v2 request body is empty. Send `{}` when the endpoint takes no parameters. |

An invalid or expired token returns a message that starts with `Unauthorized`. A token for another
product, an unexpected error, or a v1 request with an empty body returns a generic message with an
incident ID:

```json title="Error response"
{
  "succeed": false,
  "message": "There was an error processing the request. Incident id: 5e609601dd092"
}
```

Other messages describe what was wrong with the request. They are in English and can change, so
do not build logic on their exact text.

### HTTP error status

A few errors have an HTTP error status and a body without `succeed`:

| HTTP status | Reason                                                                                        |
| ----------- | --------------------------------------------------------------------------------------------- |
| 404         | The `Authorization` header is missing or malformed, or the API version in the path is unknown |
| 429         | Too many requests. See [Request rate](./restrictions#request-rate).                           |
| 500         | The request could not be processed                                                            |

For example, a request with a malformed `Authorization` header returns:

```json title="Error response"
{
  "message": "Authorization information not found or malformed",
  "status": 404,
  "status_message": "Not Found"
}
```

## v3

v3 returns errors with an HTTP status code and a JSON body with `code` and `message`. `code` is the
HTTP status as a string:

```json title="Error response"
{
  "code": "400",
  "message": "invalid sort key",
  "meta": { "response_at": "2026-12-01T09:00:00+02:00" }
}
```

| HTTP status | Reason                                                    |
| ----------- | --------------------------------------------------------- |
| 400         | A parameter is invalid, or the endpoint is unknown        |
| 401         | Authentication failed, for example the token has expired  |
| 403         | No permission for the resource                            |
| 404         | The resource was not found                                |
| 429         | Too many requests at the same time. The body is not JSON. |
| 500         | Unexpected error. `message` includes an incident ID.      |
| 501         | The endpoint does not support the request                 |

Each endpoint in the API reference lists the statuses it can return. A request without an
`Authorization` header, or with a header that is not a Bearer token, returns HTTP status 400
without a JSON body.

## Handling errors

- Check the HTTP status before you parse the body. Responses from the web server, such as HTTP
  status 413 for a request body that is too large and 429 for too many requests, are not JSON.
- If authentication fails, check your credentials. A
  [Bearer token](/authentication#request-an-access-token) expires after 15 minutes, so request a
  new one when it does. For an invalid or expired token, v1 and v2 return `succeed: false` with a
  `message` that starts with `Unauthorized`, and v3 returns HTTP status 401. For a token created
  for another product, v1 and v2 return `succeed: false` with the generic incident ID message.
- HTTP status 429 means you sent requests too fast. Wait before you send the next one, and stay
  within the [request rate limits](./restrictions#request-rate).
- Do not retry other errors without changing the request, as an invalid request fails again. Some
  requests, such as [`deliveries/batch-send`](/api/sending#batch-send-draft), create something
  each time, so retrying one after a timeout can send the mail twice.
- If an error has an incident ID, include it when you report the error to LianaMailer support.
