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

# Pagination

> Cursor parameters, the page_info object, page sizes and cursor errors

Endpoints that can return long lists are cursor-paginated. Their responses hold the records in
`data` and the cursors in `page_info`:

```json theme={null}
{
  "data": [{ "id": "esl_..." }, { "id": "esl_..." }],
  "page_info": {
    "has_next_page": true,
    "end_cursor": "eyJ2IjoxLCJjcmVhdGVkX2F0Ijoi...",
    "has_previous_page": false,
    "start_cursor": "eyJ2IjoxLCJjcmVhdGVkX2F0Ijoi..."
  }
}
```

For a walk through how the two directions fit together, see
[How cursor pagination works](https://docs.pocketflows.com/concepts/pagination.md).

## Query parameters

**after** `string`

A page's `end_cursor`. Returns the next page of older records. The record the cursor points to is
not included. Accepted by every paginated endpoint.

**before** `string`

A page's `start_cursor`. Returns the page of records immediately newer than the cursor. The record
the cursor points to is not included. Accepted only by the endpoints listed under [Endpoints that
accept `before`](#endpoints-that-accept-before).

`after` and `before` can't be sent in the same request. With neither, you get the newest page.

## `page_info`

Every paginated endpoint returns `has_next_page` and `end_cursor`. Endpoints that accept `before`
also return `has_previous_page` and `start_cursor`.

| Field | Type | Meaning |
| - | - | - |
| `has_next_page` | boolean | Whether records older than this page exist. Always `false` on a request that uses `before`. |
| `end_cursor` | string or `null` | The position of the oldest record on the page, to pass as `after`. `null` when the page is empty. |
| `has_previous_page` | boolean | Whether records newer than this page exist. Only computed on a request that uses `before`, and `false` on every other. |
| `start_cursor` | string or `null` | The position of the newest record on the page, to pass as `before`. `null` when the page is empty. |

## Ordering and page size

* Records are ordered newest first on every page, including pages fetched with `before`.
* The page size is fixed for each endpoint and can't be changed: 100 for the endpoints that accept
  `before`, and 25 for the rest.

## Cursors

* A cursor is an opaque string. Don't parse it or build one yourself.
* Only use a cursor with the endpoint and the parent resource it came from. Don't use a cursor from
  one campaign's step logs for another campaign, or for the same campaign's email events.

## Endpoints that accept `before`

* `GET /campaigns/:id/execution_step_logs`
* `GET /triggers/:id/execution_step_logs`
* `GET /campaigns/:id/sent_email_events`
* `GET /triggers/:id/sent_email_events`

Every other paginated endpoint accepts only `after`. The API Reference tab lists the parameters for
each endpoint.

## Errors

Cursor problems return `422` in the usual [error shape](https://docs.pocketflows.com/reference/errors.md), with `path` set to the
parameter at fault:

| `message` | `path` | Cause |
| - | - | - |
| `Specify only one of after or before` | `before` | Both parameters were sent. |
| `Invalid cursor` | `after` or `before` | The value isn't a cursor returned by the API. |
| `Unsupported cursor version` | `after` or `before` | The cursor is in a format this version of the API no longer reads. |

## Related

* [How cursor pagination works](https://docs.pocketflows.com/concepts/pagination.md) for a worked example of both directions.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.