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

# Pagination

Endpoints that list resources, such as customers, invoices or wallet transactions, return their results in pages rather than all at once, which keeps every response fast and predictable however many records your account holds. Every list endpoint uses the same cursor-based pagination, so the code your integration uses to page through one resource works for every other resource in the API.

## How pagination works

Your integration requests a page and sets how many records it should contain with `limit`. Each response includes a `next_cursor` that marks where the following page begins, and sending that value back as `cursor` returns the next page, continuing until the response reports that there are no more records to fetch.

| Parameter | Description                                                                                       |
| --------- | ------------------------------------------------------------------------------------------------- |
| `limit`   | The number of records to return on each page, from 1 to 100, with 20 returned when it is not set. |
| `cursor`  | The `next_cursor` value from the previous response, left out when requesting the first page.      |

## Reading a page

A list response contains the page of records in a `data` array and the details needed to continue in a `meta` object, alongside the `message` described in [Requests and responses](/api-reference/requests-and-responses).

**`Response`**

```json title="Response"
{
  "message": "Invoices retrieved successfully",
  "data": [],
  "meta": {
    "total": 42,
    "limit": 20,
    "has_more": true,
    "next_cursor": "cur_Mg"
  }
}
```

| Field         | Description                                                                             |
| ------------- | --------------------------------------------------------------------------------------- |
| `total`       | The total number of records that match the request across every page.                   |
| `limit`       | The page size used for this response.                                                   |
| `has_more`    | Whether further records exist after this page.                                          |
| `next_cursor` | The value to send as `cursor` to fetch the next page, which is `null` on the last page. |

## Fetching a complete list

To retrieve every record, request the first page without a cursor, then send the `next_cursor` from each response with the following request until `has_more` is `false`. Any filters, such as an invoice status, should be sent unchanged with every request, so that each page continues the same list.

```bash
# First page
curl --request GET \
  --url "https://api.mitu.ai/v1/invoices?status=paid&limit=50" \
  --header "x-api-key: $MITU_API_KEY"

# Next page, using next_cursor from the previous response
curl --request GET \
  --url "https://api.mitu.ai/v1/invoices?status=paid&limit=50&cursor=cur_Mg" \
  --header "x-api-key: $MITU_API_KEY"
```

## Working with cursors

1. **Treat cursors as opaque**\
   Send a cursor back exactly as it was returned, without building, storing or altering one, since its format may change. A cursor that cannot be read returns the first page rather than an error, so a mistake in handling cursors shows up as the same records being returned again.
2. **Expect records to move**\
   Lists are returned newest first, so records created while you are paging can move earlier records onto later pages, and the same record may appear twice. Use each record's identifier to recognise any you have already processed.
3. **Use the largest page you need**\
   Requesting up to 100 records at a time reduces the number of requests needed to retrieve a long list and keeps you well within your [rate limits](/platform/additional-information/rate-limits).

Pagination is the right way to retrieve records in bulk, such as during an initial import or a periodic reconciliation, while changes that happen after that point are best received as they occur, by [configuring a webhook](/guides/get-started/webhooks/configure-webhooks) and updating your records from [events](/platform/webhooks/events) rather than paging through the same lists repeatedly.