# Pagination

List endpoints return a page of results and a cursor for the next one.

## Parameters

| Parameter | Meaning |
| --- | --- |
| `limit` | Page size. Default 20, at most 100. A value outside 1 to 100 is brought into range. |
| `cursor` | The `next_cursor` from the previous response. Leave it out for the first page. |

```bash title="request"
curl "https://globalymint.com/api/v1/customers?limit=50" \
  -H "Authorization: Bearer $MINT_SECRET_KEY"
```

```json title="200"
{
  "data": {
    "items": [{ "id": "0b8f6c1e-3d2a-4a57-9c41-7e5d2f8a1b90" }],
    "next_cursor": "MnwyMDI2LTExLTE4…"
  },
  "_agent": { "summary": "50 customer(s)", "status": "ok", "next_actions": [], "warnings": [] },
  "api_version": "2026-07-01"
}
```

Results are newest first. Pass `next_cursor` back as `cursor` to get the next page. When `next_cursor` is `null` you have reached the end.

## Rules

- Treat the cursor as opaque. Its format can change; a cursor we can no longer read starts you again from the first page or is refused, depending on the endpoint.
- Filters such as `status` or `customer_external_id` are applied by the server before paging. Send the same filters with every page.
- Not every list is paged. A short list, such as webhook endpoints, returns everything in `items` with no `next_cursor`. The [API reference](/docs/api) shows which parameters each list accepts.

## Loop over every page

```ts title="all-customers.ts"
let cursor: string | null = null
do {
  const url = new URL('https://globalymint.com/api/v1/customers')
  url.searchParams.set('limit', '100')
  if (cursor) url.searchParams.set('cursor', cursor)

  const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.MINT_SECRET_KEY}` } })
  const { data } = await res.json()
  for (const customer of data.items) await handle(customer)
  cursor = data.next_cursor
} while (cursor)
```
