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

# Pagination

Cursor-paginated collection endpoints return this envelope:

```json
{
  "data": [ /* ... */ ],
  "next_cursor": "eyJpZCI6MTIzfQ==",
  "has_more": true
}
```

* **`data`** — the page of records.
* **`next_cursor`** — an opaque base64 cursor for the next page (`null` on the last page).
* **`has_more`** — `true` when more pages exist after this one.

This applies to workspaces, documents, expenses, projects, contacts, bank
accounts, bank statements, bank statement entries, and transactions.
Bank-account notification preferences return a bounded `{ data }` list without a
cursor.

## Walking the pages

Call without a cursor to start, then pass the previous response's
`next_cursor` as the `cursor` query parameter until `has_more` is `false`:

```bash
# First page
curl "https://app.lucanto.eu/api/v1/workspaces/{workspace_id}/invoices?limit=25" \
  -H "Authorization: Bearer lct_pat_xxx"

# Next page
curl "https://app.lucanto.eu/api/v1/workspaces/{workspace_id}/invoices?limit=25&cursor=eyJpZCI6MTIzfQ==" \
  -H "Authorization: Bearer lct_pat_xxx"
```

## Parameters

| Param    | Default | Max | Notes                                            |
| -------- | ------- | --- | ------------------------------------------------ |
| `limit`  | 25      | 100 | Items per page                                   |
| `cursor` | —       | —   | Opaque; pass the previous `next_cursor` verbatim |

> **Note**
>
> Cursors are keyset-based (stable under inserts), so paging never skips or
> duplicates rows the way offset paging can. Treat the cursor as opaque —
> don't decode or construct it yourself.

## Sorting

Document lists (invoices, quotes, proformas, credit notes) and transactions
accept optional `sort` and `order` query parameters:

```bash
curl "https://app.lucanto.eu/api/v1/workspaces/{workspace_id}/invoices?sort=created_at&order=asc" \
  -H "Authorization: Bearer lct_pat_xxx"
```

| Param   | Values        | Default              |
| ------- | ------------- | -------------------- |
| `sort`  | `created_at`  | unset → newest first |
| `order` | `asc`, `desc` | `desc`               |

* An unknown `sort` value is **ignored** (you get the default order, not an error).
* `contacts`, `bank_accounts`, and `bank_statements` don't support sorting yet.
* Sorting composes with cursors — the keyset tiebreak keeps paging stable.

## Filtering

Some list endpoints accept filters that compose with pagination. Contacts
support `q` name search; transactions support account, date, matching-status,
`kind=credit|debit`, and full-text filters; bank statements support account,
period overlap, file type, source, and extraction-status filters.