> For the complete documentation index, see [llms.txt](https://docs.stackai.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stackai.com/technical-reference/connections-and-tool-execution/pagination-and-large-result-sets.md).

# Pagination and Large Result Sets

List and search actions can return only one page of results. Use the action’s pagination fields when you need the complete result set.

![Use the continuation method exposed by the action](https://1957915746-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FSQ1Sgy933krTyK0S4JpP%2Fuploads%2FrZuQnmJ4CNo09U86HV1u%2Fpagination-and-large-result-sets.png?alt=media)

Provider-neutral pseudocode. Replace records, has\_more, and continuation with the selected action’s actual output fields. Some actions use offsets or links instead of cursors. Keep filtering and ordering consistent.

<details>

<summary>Copy the example</summary>

```python
page = fetch_first_page()
while True:
    process_records(page.records)
    if not page.has_more:
        break
    page = fetch_next_page(page.continuation)
```

</details>

## Before you begin

An action that exposes pagination and a defined stopping condition.

## Key concepts

| Term        | Definition                                                                                                                                                |
| ----------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Pagination  | Retrieval of a collection through multiple pages. Use the continuation method exposed by the selected operation.                                          |
| Cursor      | A continuation value returned for the next page on cursor-based endpoints. Treat it as opaque; do not manufacture it from a display name or record count. |
| Offset      | A numeric starting position used by some list operations. Keep filtering and ordering consistent while moving through pages.                              |
| Resource ID | A stable identifier for a project, file, connection, or other resource. Use the required ID type; matching display names do not make IDs interchangeable. |

## Configuration options

| Option    | Purpose                                                           | Behavior                                                               |
| --------- | ----------------------------------------------------------------- | ---------------------------------------------------------------------- |
| Page size | The maximum number of records requested or processed in one page. | It is not a guarantee that all records in the collection are included. |

## Retrieve additional results

1. Inspect the page size and continuation fields in the action schema.
2. Process the returned page and request the next page using its token or offset.
3. Stop when the response indicates that no further page is available.

The workflow processes the required records across the returned pages.

## Behavior and limitations

Pagination styles differ by provider and action. A page size is not a total-result guarantee. Do not invent a cursor field for an action that does not expose one. Large collections may require multiple runs or a smaller scope. Preserve record IDs to detect duplicates when the provider’s data changes during collection.

## Related resources

[Connection Ownership, Sharing, and Permissions](https://docs.stackai.com/technical-reference/connections-and-tool-execution/connection-ownership-sharing-and-permissions.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stackai.com/technical-reference/connections-and-tool-execution/pagination-and-large-result-sets.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
