# Pagination

Every search response includes a `next` field - a ready-made relative URL for the next page. You never build paging parameters yourself.

## The loop

1. Send your first request.
2. Fetch the results from the `records` array.
3. Append `next` to `https://api.webz.io` and call it.
4. Repeat until `moreResultsAvailable` reaches `0`.

```json
{
  "records": [ ... ],
  "next": "/breaches?token=YOUR_TOKEN&email_domain=example.com&next=CURSOR",
  "moreResultsAvailable": 1130
}
```

The cursor encodes the sort position, so keep `sort_by` and `order_by` unchanged while paging a result set.

## Boundaries

- If `moreResultsAvailable = 0`, the same `next` URL can be reused later to poll for newly indexed records.
- If `next` is `null`, a boundary was reached - for example a `crawled_to` / `breach_to` limit, or a descending search that ran out of results. Issue a new query with adjusted parameters.

> [!WARNING]
> Each page is a new request and consumes a credit - including a request that returns 0 records. See [Errors, Rate Limits & Credits](data-breach-errors-limits).
