> For the complete documentation index, see [llms.txt](https://www.boxhero.io/docs/llms.txt). Every page is available as Markdown by appending `.md` to its URL; this page is [Markdown](https://www.boxhero.io/docs/developers/api/pagination.md).

# Pagination

> Walk through long lists in the BoxHero API with cursor-based pagination.

List endpoints return results one page at a time and use cursor-based pagination.

## Query parameters

| Parameter | Description |
| --- | --- |
| `cursor` | Where the page starts. Pass the `cursor` field from the previous response. Omit it on the first call. |
| `limit` | Page size. The allowed range and the default are listed with each endpoint, for example [List items](https://www.boxhero.io/docs/developers/api/reference/items/list-items.md). |

## Response

Each page carries the results with the fields you need to fetch the next one:

```json
{
  "items": [...],
  "count": 100,
  "limit": 100,
  "cursor": 1234567,
  "has_more": true
}
```

| Field | Description |
| --- | --- |
| `count` | Number of results on this page |
| `limit` | Page size used for this page |
| `cursor` | Pass this as the `cursor` query parameter to get the next page. `null` when there are no more pages. |
| `has_more` | `true` if there are more results after this page |

## Fetching every page

1. Call the list endpoint without `cursor`.
2. While `has_more` is `true`, call it again with `cursor` set to the `cursor` from the last response.
3. Stop when `has_more` is `false`.

```bash
curl "https://rest.boxhero-app.com/v1/items?cursor=1234567" \
  -H "Authorization: Bearer $BOXHERO_API_TOKEN"
```

Keep any filters you used on the first call the same on every following call.

## Ordering

Each resource defines its own order. Most list endpoints return results by id, ascending. [List transactions](https://www.boxhero.io/docs/developers/api/reference/transactions/list-transactions.md) returns the newest transactions first (by transaction time, with id as the tiebreaker).

> **Tip**
>
> **Pro Tip**: To keep a copy of your transactions in sync, store each transaction's `revision`. When you walk the list again, a higher `revision` tells you the transaction was edited since you last saw it.
