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

# Pagination

> Follow a cursor across pages of sessions, and find the pagination fields for other list endpoints.

Use cursor pagination when the endpoint documents a `cursor` query parameter and a `nextCursor` response field. The [sessions endpoint](https://docs.tembo.io/api/v1/sessions/list-sessions.md) supports this pattern.

## List sessions one page at a time

1. Request `GET /v1/sessions` with your filters and an optional `limit`. For sessions, the default limit is 50 and the allowed range is 1–100. Omit `cursor` on the first request.
2. Read the sessions from `items`. If `nextCursor` is `null`, you have reached the end.
3. Otherwise, pass the returned value as the next request’s `cursor`. Keep the same filters and sort order. Treat the cursor as opaque and let your HTTP client URL-encode it.

An active-session query can return a short page with a continuation cursor. Follow that cursor even if the page contains fewer sessions than you requested.

```bash cURL theme={null}
set -e
url="https://api.tembo.io/v1/sessions"
cursor_args=()
while true; do
  page=$(curl --fail --silent --show-error --get "$url" \
    -H "Authorization: Bearer $TEMBO_API_KEY" \
    --data-urlencode "limit=100" "${cursor_args[@]}")
  jq -r '.items[].id' <<< "$page"
  cursor=$(jq -r '.nextCursor // empty' <<< "$page")
  [[ -n "$cursor" ]] || break
  cursor_args=(--data-urlencode "cursor=$cursor")
done
```

```ts TypeScript theme={null}
const url = new URL("https://api.tembo.io/v1/sessions");
url.searchParams.set("limit", "100");

while (true) {
  const response = await fetch(url, {
    headers: { Authorization: `Bearer ${process.env.TEMBO_API_KEY}` },
  });
  if (!response.ok) throw new Error(`HTTP ${response.status}`);

  const page = await response.json();
  for (const session of page.items) console.log(session.id);
  if (page.nextCursor === null) break;
  url.searchParams.set("cursor", page.nextCursor);
}
```

For self-hosted deployments, use your [deployment’s API base URL](https://docs.tembo.io/api/index.md#base-urls).

## Endpoint differences

| Endpoint | How to read the response |
| - | - |
| [List sessions](https://docs.tembo.io/api/v1/sessions/list-sessions.md) | Read `items` and follow `nextCursor`. To get a count of matching sessions, pass `includeTotal=true`. This option is unavailable with `state=active`. |
| [List session sources](https://docs.tembo.io/api/v1/sessions/list-session-sources.md) | Read `items` and follow `nextCursor`. Pass `includeTotal=true` to also receive `totalCount` for matching sources. |
| [List pins](https://docs.tembo.io/api/v1/pins/list-pins.md) | Read `resources` and follow `nextCursor`. Even an empty `resources` array can have a continuation cursor. |
| [List folders](https://docs.tembo.io/api/v1/folders/list-folders.md) | Read `items` in a single response. This endpoint has no cursor or limit parameter. |

For other endpoints, check the operation’s query parameters and response schema for page-size limits, result fields, and support for totals.


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