> ## Documentation Index
> Fetch the complete documentation index at: https://docs.moritosh.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Pagination

> How to page through list endpoints

All `list` endpoints (`GET /messages`, `GET /contacts`, `GET /templates`, and so on) share the same cursor-based pagination.

## Request parameters

| Parameter        | Description                                                                                                    |
| ---------------- | -------------------------------------------------------------------------------------------------------------- |
| `limit`          | Number of results to return, between 1 and 100. Defaults to 20.                                                |
| `starting_after` | A cursor for use in pagination. Pass the `id` of the last object from the previous page to fetch the next one. |

## Response shape

```json theme={null}
{
  "object": "list",
  "data": [
    { "id": "msg_3p2k9q", "...": "..." },
    { "id": "msg_8h1n2v", "...": "..." }
  ],
  "has_more": true
}
```

`has_more` is `true` if there are additional results after the ones returned. When it's `false`, you've reached the end of the list.

## Paging through every result

```javascript theme={null}
let startingAfter;
const allMessages = [];

while (true) {
  const page = await pulsewave.messages.list({ limit: 100, starting_after: startingAfter });
  allMessages.push(...page.data);

  if (!page.has_more) break;
  startingAfter = page.data[page.data.length - 1].id;
}
```

<Note>
  Lists are always ordered most-recent-first by creation time. There is no way to page backwards from a cursor — request the previous page again without `starting_after` advanced as far, or store cursors as you go.
</Note>
