Pagination

How list endpoints page results, and how to walk every page.

Pagination

List endpoints return a fixed-size page of results wrapped in a metadata envelope. The page size is capped at 100 items per request, there is no "unbounded" mode.

Response shape

Every paginated list endpoint returns the same wrapper:

{
  "data": [ /* up to pageSize items */ ],
  "pagination": {
    "page": 1,
    "pageSize": 50,
    "total": 137,
    "totalPages": 3,
    "hasNextPage": true,
    "hasPrevPage": false
  }
}
FieldTypeDescription
pagenumber1-indexed page number you just fetched.
pageSizenumberNumber of items per page (max 100).
totalnumberTotal matching records across all pages.
totalPagesnumberTotal number of pages. Always >= 1.
hasNextPagebooleantrue when another page is available.
hasPrevPagebooleantrue when there is a page before this one.

Query parameters

Every paginated list endpoint accepts the same two query parameters:

ParameterTypeDefaultNotes
pageinteger11-indexed page number.
pageSizeinteger50Items per page (1–100). Values above 100 are clamped to 100.

Filters (e.g. status, search) are applied before pagination, so pagination.total reflects the count of records matching your filters, not the total in the org.

Walking all pages

Loop until hasNextPage is false:

async function fetchAllLeads(token: string) {
  const out: Lead[] = [];
  let page = 1;
  while (true) {
    const res = await fetch(
      `https://your-host/api/v1/leads?page=${page}&pageSize=100`,
      { headers: { Authorization: `Bearer ${token}` } },
    );
    const body = await res.json() as {
      data: Lead[];
      pagination: { hasNextPage: boolean };
    };
    out.push(...body.data);
    if (!body.pagination.hasNextPage) return out;
    page++;
  }
}

Don't rely on pagination.totalPages snapshot from the first response, records can be created or deleted between requests. Always check hasNextPage on the page you just received.

cURL

# First page
curl -H "Authorization: Bearer $KEY" \
  'https://your-host/api/v1/leads?page=1&pageSize=100'

# Next page
curl -H "Authorization: Bearer $KEY" \
  'https://your-host/api/v1/leads?page=2&pageSize=100'

Performance tips

  • Use the largest pageSize (100) you can when bulk-exporting.
  • Combine pagination with filters (status, assignedToId, search) to keep pages small and queries fast.
  • Page reads are not strictly snapshot-isolated. If your data is mutating rapidly while you paginate, an item may move pages between calls. For one-shot exports, page through quickly and de-dupe by id on the client.