# Errors

REST errors are JSON with an HTTP status:

```json
{ "error": { "code": "not_pdf", "message": "The file is not a PDF." } }
```

Branch on `code`, not on `message`. Messages may change.

| Status | Code | Cause | Retry? |
| --- | --- | --- | --- |
| 400 | `missing_file` | No file in the request: empty body, no `file` field, or JSON without `file_url` or `file_base64`. | No. Fix the request. |
| 400 | `not_pdf` | The bytes do not start with a PDF header. Often an HTML error page or login page downloaded instead of the PDF. | No. |
| 400 | `bad_format` | `format` is not one of the supported values. | No. |
| 400 | `bad_json` | `Content-Type` is JSON but the body does not parse. | No. |
| 400 | `download_failed` | `file_url` could not be fetched: not https, private address, timeout, HTTP error, too many redirects or too large. The message says which. | Only after fixing the URL. |
| 401 | `unauthorized` | Missing, malformed or revoked key. | No. |
| 403 | `plan_required` | The account is on the Free plan. | No. |
| 413 | `too_large` | The PDF is over 15 MB. | No. Split the PDF. |
| 422 | `scanned_pdf` | The PDF has no text layer (it is a scan or photo). | No. Run OCR first, or use the web app's AI extraction. |
| 422 | `unreadable_pdf` | The PDF is encrypted, password protected or damaged. | No. Remove the password and resend. |
| 429 | `rate_limited` | More than 60 requests in a minute for this account. | Yes, after 60 seconds. |
| 429 | `quota_exceeded` | The monthly page quota is used up. | Next month, or after upgrading. |
| 501 | `not_configured` | The deployment has no database configured. | No. Contact support. |

A 5xx without a JSON body is a platform error. Retry once after a few seconds.

## A 200 that is still a problem

A successful response can contain zero transactions or a failed balance check. These are not errors in the HTTP sense, so check them:

- `transactions` is empty: the layout was not understood. Do not retry with the same input. Try the other `date_order` only if dates are the issue; otherwise report that the statement could not be read.
- `balance_check.reconciled < balance_check.checkable`: treat the result as partly wrong.
- `warnings` is not empty: see [Response and data model](https://extractivio.com/docs/response.md).

## MCP

The hosted MCP server reports tool problems inside a normal tool result with `isError: true` and a text of the form `code: message`, using the same codes as above. Authentication and plan problems are HTTP errors (401, 403, 429) with a JSON-RPC error body, before any tool runs.
