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
limitand the endpoint returns every matching row. - Pass
limitto bound the page, andoffsetto skip rows.offsetwithoutlimitis rejected with400. - By default
datais a bare array. PassincludeTotal=trueto receive a page envelope underdatainstead, holdingitems, a server-sidetotalcounted over the same filter, andhasMore. The documents envelope also reports thelimitandoffsetit applied.
| Endpoint | limit | offset |
|---|---|---|
GET /documents | 1–500 | 0 and up |
GET /tags | 1–100 | 0–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:
| Header | Value |
|---|---|
x-document-list-total | Count of every document matching the filter. |
x-document-list-has-more | true or false. |
x-document-list-next-offset | The 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 (
limit1–100, default 25). - Agent session events
page by cursor (
limit1–2,000, default 1,000). - List agent sessions
pages by
limit(1–500) andoffset(0–10,000) by default, and by cursor when you passpageMode=keyset. A keyset cursor is tied to the query that produced it: sending it with a different query, search, or scope returns400.
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.