Pagination
10ex list endpoints are cursor-based. Cursors are opaque tokens that point at a position in a stable result set, so you don’t have to worry about offsets shifting when new data lands mid-iteration.
Request
GET /api/v1/crm/leads?limit=50&cursor=<opaque>limit: max items per page (default 50, hard cap 200).cursor: opaque token from a prior response. Omit on the first page.
Response
{
"items": [ ... ],
"next_cursor": "opaque_or_null",
"total": 12345
}When next_cursor is null, you’ve reached the end. total is best-effort. Some endpoints in very large workspaces omit it because the count is too expensive to compute on every page load.
How to fetch every lead
A typical pagination loop:
let cursor: string | null = null
const all = []
do {
const url = new URL('https://api.10ex.ai/api/v1/crm/leads')
url.searchParams.set('limit', '200')
if (cursor) url.searchParams.set('cursor', cursor)
const res = await fetch(url, {
headers: { Authorization: `Bearer ${process.env.TENEX_API_KEY}` }
})
const page = await res.json()
all.push(...page.items)
cursor = page.next_cursor
} while (cursor)Common mistakes
- Treating
cursoras a row number. It’s opaque. Don’t parse it, don’t increment it. - Forgetting to URL-encode the cursor. Some implementations include
=and+. - Holding cursors across days. They’re stable for the life of a query, not forever. If you need resumable jobs, store the highest
created_atyou saw and re-query with a filter.
Last updated on