Pagination
How cursor-based pagination works in the DramWell API — request parameters, response envelope, and traversal patterns.
Overview
All DramWell API list endpoints use cursor-based pagination. Unlike page-number pagination, cursors remain stable as data changes — new records inserted at the top of a list will not shift items between pages or cause duplicates in your results.
Request Parameters
| Parameter | Type | Default | Max | Description |
|---|---|---|---|---|
limit |
integer | 20 |
100 |
Number of records to return |
cursor |
string | — | — | Opaque cursor from a previous response's cursor field |
GET /v1/customers?limit=50&cursor=cur_01HXYZ
Authorization: Bearer sk_live_xxxx
Response Envelope
List endpoints always return the pagination envelope:
{
"data": [
{ "id": "cus_01HABC", "name": "Riverside Properties", ... },
{ "id": "cus_01HDEF", "name": "Summit HVAC Group", ... }
],
"cursor": "cur_01HDEF",
"has_more": true
}
| Field | Type | Description |
|---|---|---|
data |
array | The records for this page |
cursor |
string or null | Pass this value as cursor to fetch the next page. null when on the last page |
has_more |
boolean | true if more records exist beyond this page |
Fetching All Pages
To retrieve all records, loop until has_more is false:
async function fetchAll(resource: string): Promise<unknown[]> {
const results: unknown[] = []
let cursor: string | null = null
do {
const params = new URLSearchParams({ limit: '100' })
if (cursor) params.set('cursor', cursor)
const response = await fetch(`https://api.dramwell.ai/v1/${resource}?${params}`, {
headers: { Authorization: `Bearer ${process.env.DRAMWELL_API_KEY}` }
})
if (!response.ok) throw new Error(`API error: ${response.status}`)
const body = await response.json()
results.push(...body.data)
cursor = body.cursor
} while (cursor !== null)
return results
}
Filtering and Sorting
Filters are applied before pagination. Pass filter parameters as query strings alongside limit and cursor. Available filters vary by resource and are documented on each resource's reference page.
GET /v1/jobs?status=scheduled&technician_id=tech_01HABC&limit=25
Sorting defaults to created_at descending (newest first). Endpoints that support custom sort orders accept a sort parameter:
GET /v1/invoices?sort=amount_desc&limit=20
Tips
- Always store the
cursorfrom the last response, not a computed offset, when building sync pipelines. - Setting
limit=100reduces round trips for large exports but counts as 1 request against your rate limit regardless of page size. - Cursor values are opaque strings — do not parse or construct them manually.
Related Articles
Was this article helpful?