> 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.

# Authentication

All API requests authenticate with a Bearer token in the `Authorization`
header:

```
Authorization: Bearer <token>
```

## Token types

| Type                      | Prefix      | Scope                               | Use for                                                                     |
| ------------------------- | ----------- | ----------------------------------- | --------------------------------------------------------------------------- |
| **Personal access token** | `lct_pat_`  | Every workspace the user belongs to | AI agents and MCP clients (Claude Code, Codex) — not the REST API           |
| **Workspace token**       | `lct_live_` | One workspace, bound to the account | REST API: e-shop / accounting integrations that act as the workspace itself |

A personal access token spans multiple workspaces, so you always pass the
`workspace_id` in the path. A workspace token is bound to one workspace —
the `workspace_id` in the path must match, or the request returns `403`.

## Scopes

Tokens carry granular scopes in three tiers, per resource:

* `read:<resource>` — list and get
* `write:<resource>` — read + create + update
* `manage:<resource>` — write + custom actions (issue, mark paid, send, delete)

Resource keys are `invoices`, `quotes`, `proformas`, `credit_notes`,
`sales_orders`, `documents`, `expenses`, `contacts`, `bank_accounts`,
`transactions`, `projects`, `company_profile`, `document_settings`, and
`loans`. `sales_orders` and `loans` are read-only: a `write:` or `manage:`
scope on them grants read access only. A wildcard like `read:*` or
`manage:*` grants the tier across all resources.

The [MCP server](/mcp) also accepts an OAuth 2.1 sign-in from Claude; the
access it grants uses the same scopes and is capped the same way. Granted
permissions and per-firm access for active OAuth connections can be inspected
and edited under **Settings** > **Personal API access** without reconnecting.

Scopes are **capped at creation** by the issuing user's own permissions —
a token can never grant more than the user has. If the user later loses a
role, the token's effective power shrinks with it.

The user's current workspace role also limits record visibility. For example,
the built-in employee role can work with its own documents and expenses but
cannot use a broad token to read another member's records. A suspended
membership is treated as absent and returns `404` for that workspace.

Some authenticated endpoints are not delegated to API keys. Push-device
registration under `/devices` requires a signed-in JWT session.

## Errors

A missing or invalid token returns `401`:

```json
{
  "error": "unauthenticated",
  "message": "Authentication required.",
  "request_id": "8f9e4c2b-...",
  "docs_url": "https://docs.lucanto.eu/api/v1/errors/unauthenticated"
}
```

A valid token without the required scope returns `403` (`forbidden`).
See [Errors](/errors).