Pagination
Opaque cursor pagination on every list endpoint.
Every listing returns { "data": [...], "pagination": { "limit", "hasMore", "nextCursor" } }. There is no page, pageSize, offset or total.
How to paginate
- First call:
GET /v1/companies?limit=50.limitaccepts integers from 1 to 1000 (default50); invalid values return400withERROR_INVALID_LIMIT, never silently truncated. - Next pages: send
cursor=<nextCursor>keeping exactly the same filters. You may changelimitbetween pages. - At the end,
hasMoreisfalseandnextCursorisnull. An empty list returnsdata: []. - The cursor is opaque and versioned: do not edit, build or reuse it on another collection, tenant or filter (
400withERROR_INVALID_CURSOR). - Reads use current data with no snapshot between requests: items inserted later do not show up when continuing a descending listing, and a cursor keeps working if its record is deleted.
javascript
async function listAllCompanies() {
const all = [];
let cursor;
do {
const url = new URL(`${BASE_URL}/companies`);
url.searchParams.set("limit", "100");
if (cursor) url.searchParams.set("cursor", cursor);
const res = await fetch(url, {
headers: { "X-API-Key": process.env.CORVO_API_KEY },
});
const { data, pagination } = await res.json();
all.push(...data);
cursor = pagination.hasMore ? pagination.nextCursor : undefined;
} while (cursor);
return all;
}