> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://developer.lucanto.eu/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://developer.lucanto.eu/_mcp/server.

# Errors

Standard API errors share this envelope:

```json
{
  "error": "forbidden",
  "message": "You do not have permission to perform this action.",
  "request_id": "8f9e4c2b-0c1a-4f3e-9a8d-1b2c3d4e5f60",
  "docs_url": "https://docs.lucanto.eu/api/v1/errors/forbidden"
}
```

* **`error`** — a stable, machine-readable code. Branch on this, not the message.
* **`message`** — human-readable; wording may change between releases.
* **`request_id`** — also returned as the `X-Request-Id` header. Quote it in
  support tickets so we can pull the matching server log line.
* **`docs_url`** — deep link to the per-code documentation page.

Validation failures add an `errors` array of individual messages.

## Plan and feature limits

Feature gates use a separate actionable payload with a stable `code`, the
affected `feature_key`, and an `upgrade_url`:

```json
{
  "error": "Limit reached for ai_expense_extractions",
  "code": "feature_limit_exceeded",
  "feature_key": "ai_expense_extractions",
  "plan": "free",
  "upgrade_url": "https://app.lucanto.eu/42/billing/plans"
}
```

Branch on `code` for these responses. Period-based limits can also include
`current_usage`, `limit`, and `resets_at`, with `Retry-After` set when a reset
time is available. Unlike the standard envelope, feature-gate payloads do not
include `request_id` or `docs_url`.

## Status codes

| Status | `error`                                                             | Meaning                                                                                         |
| ------ | ------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
| 400    | `bad_request` / `invalid_idempotency_key`                           | Malformed request or idempotency key longer than 255 characters                                 |
| 401    | `unauthenticated`                                                   | Missing or invalid token                                                                        |
| 402    | `subscription_required`                                             | Workspace has no active subscription                                                            |
| 403    | `forbidden`                                                         | Token scope or role doesn't permit this action                                                  |
| 404    | `not_found`                                                         | Resource doesn't exist or isn't visible to you                                                  |
| 409    | `conflict` / `idempotency_in_progress`                              | Conflicting state or request with this key is already running (see [Idempotency](/idempotency)) |
| 422    | `unprocessable_entity` / `idempotency_key_conflict`                 | Validation failed (see `errors` array) or idempotency key reused with a different request       |
| 429    | `rate_limited` / `feature_limit_exceeded` / `registry_lookup_limit` | Throttled, plan limit reached, or the workspace's daily company-register lookups are spent      |
| 502    | `registry_unavailable`                                              | External business register unavailable (retry or manual entry)                                  |

> **Note**
>
> Cross-workspace access returns `404`, not `403`, so the API never leaks the
> existence of records you can't see.