> This page is for version Preview.
> For other versions, use one of these documentation indexes:
> - Current (default): https://docs.paid.ai/current/llms.txt
> - Preview: https://docs.paid.ai/preview/llms.txt

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

# Pagination

> Read every object in a list by following the cursor from one page to the next.

Every list endpoint on `https://api.paid.ai/v1` returns one page at a time, newest first. Each page tells you whether another follows and gives you a cursor to fetch it, so you can read a list of any length with the same loop.

Use pagination to:

* **Read a whole list.** Follow `nextCursor` until `hasMore` is `false`.
* **Control page size.** Ask for up to 100 objects a page with `limit`.
* **Resume where you stopped.** Keep the last `nextCursor` and send it later to continue from the same place.

## How it works

1. Call a list endpoint without a cursor. You get the newest objects first.
2. If `hasMore` is `true`, send the page's `nextCursor` as the `cursor` query parameter to get the next page.
3. Repeat until `hasMore` is `false`. The last page's `nextCursor` is `null`.

Objects are ordered by `createdAt`, newest first, with `id` breaking ties, so a page never repeats or skips an object that existed when you started. Objects created after your first request appear only on a new first page.

## Query parameters

| Parameter | Type    | Default | Description                                                        |
| --------- | ------- | ------- | ------------------------------------------------------------------ |
| `limit`   | integer | `10`    | How many objects to return, `1` to `100`.                          |
| `cursor`  | string  | none    | The `nextCursor` of the previous page. Omit it for the first page. |

A list endpoint can take its own filters too, such as a status. Send the same filters with every page: the cursor marks a position in the list, not the filters that made it.

## The list object

Every paginated response has the same shape:

| Field        | Type           | Description                                                        |
| ------------ | -------------- | ------------------------------------------------------------------ |
| `object`     | string         | Always `list`.                                                     |
| `data`       | array          | The objects on this page, newest first.                            |
| `hasMore`    | boolean        | Whether another page follows this one.                             |
| `nextCursor` | string or null | Send it as `cursor` to get the next page. `null` on the last page. |

```json
{
  "object": "list",
  "data": [
    { "id": "cus_8HqL2xT", "object": "customer", "name": "Northwind Traders" },
    { "id": "cus_3Fw9KpR", "object": "customer", "name": "Halberd LLP" }
  ],
  "hasMore": true,
  "nextCursor": "eyJjIjoiMjAyNi0xMS0wMVQwOTowMDowMC4wMDBaIiwiaSI6ImN1c18zRnc5S3BSIn0"
}
```

## Read every page

This loop reads a whole list with `curl` and `jq`. It works the same way for every list endpoint.

```bash
cursor=""
while :; do
  page=$(curl -sG https://api.paid.ai/v1/customers \
    -H "Authorization: Bearer $PAID_API_KEY" \
    --data-urlencode "limit=100" \
    ${cursor:+--data-urlencode "cursor=$cursor"})
  echo "$page" | jq -c '.data[]'
  [ "$(echo "$page" | jq -r '.hasMore')" = "true" ] || break
  cursor=$(echo "$page" | jq -r '.nextCursor')
done
```

## Cursors

Treat a cursor as an opaque string: don't build, parse or change one. Only send a cursor to the list that returned it, with the same filters. The API doesn't check which list produced a cursor, so one from another list or with other filters can silently skip objects. A cursor that isn't one the API produced returns a `400` `invalid_request` error with `param` set to `cursor`.

A few lists are short, fixed sets, such as the betas your account can use. They return every object in `data` with no `hasMore`, `nextCursor` or `limit`. The API Reference shows which lists those are.

## Related

* [Expanding responses](./expanding-responses)
* [Rate limits](./rate-limits)
* [Errors](/preview/developers/api/errors)
* [API Reference](./introduction)