Pagination & filtering

List endpoints return one page at a time. Record lists also support filters, tags, free-text search and sorting.

Cursor pagination

curl "https://crm.codefab.dev/api/v1/objects/contact/records?limit=100" \
-H "X-API-Key: $CRM_API_KEY"

Pass nextCursor back as cursor to get the next page. When nextCursor is null, you have reached the end. limit is 50 by default and at most 200.

Node.js
async function* allContacts() {
let cursor
do {
const url = new URL('https://crm.codefab.dev/api/v1/objects/contact/records')
url.searchParams.set('limit', '200')
if (cursor) url.searchParams.set('cursor', cursor)
const page = await fetch(url, { headers: { 'X-API-Key': process.env.CRM_API_KEY } })
.then((r) => r.json())
yield* page.items
cursor = page.nextCursor
} while (cursor)
}

Cursors are opaque. Don't build or change them yourself.

Follow-ups page the same way: GET /api/v1/followups/page?scope=all&limit=100, oldest due first. Its response also has totals: how many follow-ups match in all, split into overdue, today, this week, later and done.

Filtering records

Add one or more filter parameters in the form field:operator:value. Filters are combined with AND.

cURL
curl -G "https://crm.codefab.dev/api/v1/objects/contact/records" \
-H "X-API-Key: $CRM_API_KEY" \
--data-urlencode "filter=locale:eq:sv" \
--data-urlencode "filter=email:contains:@example.com"
OperatorMeaningExample
eq / neqEquals / not equalslocale:eq:sv
containsContains text (case-insensitive)email:contains:@example.com
gt, gte, lt, lteGreater / less than (numbers, dates)total:gte:1000
existsThe field has a valuephone:exists
within_daysDate within the last N dayslast_order_at:within_days:30
before_daysDate more than N days agolast_order_at:before_days:180

More options:

  • tag=vip: only records with the tag (repeat for several).
  • q=anna: free-text search across the record.
  • sort=field:asc or sort=field:desc: sort by a field, or by created_at. Newest first by default.

Complex conditions

For OR groups, relations ("contacts with an order over 1 000 SEK") and event conditions, create a segment and list its members. Segments use the full condition model and stay up to date.