# Next page token pagination method

## Overview

This method is a slight variation on the [next page URL](/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/pagination/next-page-url-pagination-method.md) approach. Instead of receiving a full URL in the response, it contains a 'token' (usually a random string/hash). The receiving system uses this token to keep track of the position of the last record in the current page of data. &#x20;

## Next page token options

<table><thead><tr><th width="284">Option</th><th>Summary</th></tr></thead><tbody><tr><td>Token parameter name</td><td>Enter the name of the URL parameter which holds the token for requesting the next page.</td></tr><tr><td>Limit parameter path</td><td>Enter the dot notation path for the data element in your response which contains the maximum number of items that the API should return in a single page of a paginated response. Commonly (though not necessarily), this would be a path to a <code>limit</code> field.   </td></tr><tr><td>Limit</td><td>Enter the number of items to be returned per page. For example: <code>10</code>.</td></tr><tr><td>Path to token in payload</td><td>Enter the dot notation path of the next page token within the payload. </td></tr></tbody></table>

## Example

Suppose we set the following options:

<table><thead><tr><th width="284">Option</th><th>Value</th></tr></thead><tbody><tr><td>Token parameter name</td><td><code>page_token</code></td></tr><tr><td>Limit parameter path</td><td><code>limit</code></td></tr><tr><td>Limit</td><td><code>10</code></td></tr><tr><td>Path to token in payload</td><td><code>links.next</code></td></tr></tbody></table>

...and we send a request to get the first page of data:

{% code lineNumbers="true" %}

```
GET https://my.shop/api/customers?limit=10
```

{% endcode %}

The response will include the first page of data, together with a next page token that should be used to get the next page of results. For example:

{% code lineNumbers="true" %}

```json
{
  "data": [
    {"id": 1, "name": "Alice"},
    {"id": 2, "name": "Bob"},
    {"id": 3, "name": "Charlie"},
    {"id": 4, "name": "Lyn"},
    {"id": 5, "name": "John"},
    {"id": 6, "name": "Gordon"},
    {"id": 7, "name": "Izzy"},
    {"id": 8, "name": "Mike"},
    {"id": 9, "name": "Ralph"},
    {"id": 10, "name": "Rex"}
  ],
  "links": {
    "next": "abcd5780HJKLMN0PqR24"
  }
}
```

{% endcode %}

Notice the `links.next` section at the end of this response, which includes our next page URL. So, our request for the next page of results would be:

{% code lineNumbers="true" %}

```
GET https://my.shop/api/customers?limit=10&page_token=abcd5780HJKLMN0PqR24
```

{% endcode %}

## When does pagination stop?

Pagination continues until the token is no longer included in the payload.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/pagination/next-page-token-pagination-method.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
