Closedloop.ai
API Reference

Pagination

How list endpoints page: offset pages, opt-in totals, and opaque cursors

List endpoints do not share one paging scheme. Each uses one of the patterns below, and its endpoint page states which parameters it takes and their limits.

Offset pages with an optional total

List documents and list tags page with limit and offset.

  • Omit limit and the endpoint returns every matching row.
  • Pass limit to bound the page, and offset to skip rows. offset without limit is rejected with 400.
  • By default data is a bare array. Pass includeTotal=true to receive a page envelope under data instead, holding items, a server-side total counted over the same filter, and hasMore. The documents envelope also reports the limit and offset it applied.
Endpointlimitoffset
GET /documents1–5000 and up
GET /tags1–1000–10,000
curl "https://api.closedloop.ai/documents?limit=50&offset=50&includeTotal=true" \
  -H "Authorization: Bearer sk_live_your_api_key_here"

Continuation headers on the document list

When GET /documents returns the bare array, it states the same facts in response headers, so a caller paging without includeTotal can tell a complete result from a capped one:

HeaderValue
x-document-list-totalCount of every document matching the filter.
x-document-list-has-moretrue or false.
x-document-list-next-offsetThe offset for the next page. Sent only when x-document-list-has-more is true.

Keep requesting until hasMore (or the header) is false. Do not stop on a short page or loop until an empty one.

Opaque cursors

Some endpoints page with a cursor instead of an offset. Pass the nextCursor from the previous response, unchanged, as cursor; omit it for the first page. Do not build or edit a cursor.

  • Search uses a cursor on its unified results (limit 1–100, default 25).
  • Agent session events page by cursor (limit 1–2,000, default 1,000).
  • List agent sessions pages by limit (1–500) and offset (0–10,000) by default, and by cursor when you pass pageMode=keyset. A keyset cursor is tied to the query that produced it: sending it with a different query, search, or scope returns 400.

Endpoints with a bound but no paging

List projects takes a limit (1–100) that applies only when teamId is given, and no offset or cursor.

On this page