Pagination

Navigate large result sets with cursor-based pagination.

Overview

List endpoints return paginated results using cursor-based pagination. This provides consistent results even when data changes between requests.

Parameters

ParameterTypeDefaultDescription
limitinteger20Number of items per page (max 100)
cursorstringCursor from previous response

Response

{
  "data": [
    { "id": "conv_1", "created_at": "2025-01-15T10:00:00Z" },
    { "id": "conv_2", "created_at": "2025-01-15T09:30:00Z" }
  ],
  "pagination": {
    "has_more": true,
    "next_cursor": "eyJpZCI6ImNvbnZfMiJ9"
  }
}

Usage

First Page

curl https://api.your-domain.com/v1/conversations?limit=20 \
  -H "Authorization: Bearer YOUR_API_KEY"

Next Page

curl "https://api.your-domain.com/v1/conversations?limit=20&cursor=eyJpZCI6ImNvbnZfMiJ9" \
  -H "Authorization: Bearer YOUR_API_KEY"

Iterate All Pages

async function fetchAll(endpoint) {
  const results = [];
  let cursor = undefined;

  do {
    const params = new URLSearchParams({ limit: '100' });
    if (cursor) params.set('cursor', cursor);

    const response = await fetch(`${endpoint}?${params}`, {
      headers: { Authorization: 'Bearer YOUR_API_KEY' },
    });
    const { data, pagination } = await response.json();

    results.push(...data);
    cursor = pagination.has_more ? pagination.next_cursor : undefined;
  } while (cursor);

  return results;
}

On this page