API

Pagination

ulex cursor pagination: the list envelope, starting_after and ending_before, limit bounds, order and ULID ordering, next_cursor semantics, filters versus pagination, SCIM's startIndex and count, and audit-log and export paging.

Every list endpoint in ulex uses opaque cursor pagination. There is no offset, and there will never be one.

#The list envelope

json
{
  "object": "list",
  "data": [],
  "first_id": "usr_01M3PSV9GRT8GQGEG686AR1W9S",
  "last_id": "usr_01M3PSWBPGS08FWV4NV7P9VNFN",
  "has_more": true,
  "next_cursor": "usr_01M3PSWBPGS08FWV4NV7P9VNFN"
}
FieldTypeNotes
object"list"always literally list, so you can branch on it
dataarraythe page
first_idid | nulldata[0].id, or null when the page is empty
last_idid | nulldata[data.length - 1].id
has_morebooleanthe only field you should branch on
next_cursorid | nullnull exactly when has_more is false

#Parameters

ParameterTypeDefaultBounds
limitinteger201–200
starting_afterid—exclusive; return items after this id
ending_beforeid—exclusive; return items before this id
orderasc | descasc

starting_after and ending_before are mutually exclusive; sending both is 400 validation_failed with param: "starting_after".

text
page 1   GET /api/v1/users?limit=100
page 2   GET /api/v1/users?limit=100&starting_after=usr_01M3PSWBPGS08FWV4NV7P9VNFN
page 3   GET /api/v1/users?limit=100&starting_after=<next_cursor from page 2>
stop     has_more == false

#Rules

Warning

next_cursor is opaque. It happens to be a resource id today. Do not decode it, do not slice it, do not construct one, do not compare two of them. Pass it back verbatim as starting_after.

  1. Loop until has_more is false. Do not stop at the first page, do not assume 100 is everything.
  2. The cursor belongs to the query that produced it. Change a filter and discard the cursor. Cursors are a hash of the filter set; a mismatched one is 400 validation_failed with param: "starting_after" rather than silently wrong results.
  3. Do not use offset. Items are inserted and deleted constantly; an offset skips or repeats. A cursor does not.
  4. order: "asc" is creation order. ulex ids are prefixed ULIDs, so lexicographic order is chronological. desc is newest first.
  5. Set limit deliberately. 200 is the maximum and is a good default for a bulk agent run. 20 is the default for interactive use.
  6. Dedupe on id anyway. Two concurrent runs can both see the same page. id is the join key.

#Idempotent, resumable drain

ts
export async function drain<T extends { id: string }>(
  fetchPage: (cursor?: string) => Promise<{ data: T[]; has_more: boolean; next_cursor: string | null }>,
  handler: (item: T) => Promise<void>,
): Promise<{ processed: number; pages: number }> {
  let cursor: string | undefined;
  let processed = 0;
  let pages = 0;

  for (;;) {
    const page: { data: T[]; has_more: boolean; next_cursor: string | null } =
      await fetchPage(cursor);
    pages++;
    for (const item of page.data) {
      await handler(item); // must be idempotent: a retry re-delivers page edges
      processed++;
    }
    if (!page.has_more) break;
    cursor = page.next_cursor ?? undefined;
  }
  return { processed, pages };
}

// Every list endpoint in ulex:
const users = await drain(
  (cursor) =>
    tools.ulex_list_users({ limit: 200, order: "asc", starting_after: cursor }),
  (user) => syncUserToYourApp(user),
);

#Filters and pagination are independent

Filters narrow the result set; the cursor pages within it. Both are applied server-side.

bash
GET /api/v1/users?status=active&organization_id=org_01M3PSV8HGTKQFCAYF9GDWGN3C&limit=50&starting_after=usr_01M3PSWBPGS08FWV4NV7P9VNFN
EndpointFilters
GET /organizationsconnection_id, domain, search
GET /usersemail, external_id, organization_id, group_id, directory_id, status, search
GET /users/{id}/memberships—
GET /organizations/{id}/membersrole, group_id, search
GET /organizations/{id}/groupssource
GET /connectionsorganization_id, strategy, state, domain, search
GET /directoriesorganization_id, provider, state
GET /directories/{id}/usersstatus
GET /directories/{id}/syncsstate, trigger
GET /webhooksstatus, event
GET /webhooks/{id}/deliveriesstatus, event
GET /audit-events17 filters, see Audit logs
GET /deploymentsapplication_id, environment, state, branch, commit_sha
GET /applicationstype, search

A search filter is a prefix match, not a substring match. search=acme finds acme@…, acme.example, and acme-corp, but not contact@acme.example. There is no full-text index; that is a deliberate trade for cost at scale-to-zero.

#SCIM paginates differently

RFC 7644 uses offset paging, because that is what IdPs expect. /scim/v2/Users and /scim/v2/Groups:

ParameterTypeDefaultBounds
startIndexinteger11-based
countinteger201–200
sortByattribute—e.g. userName
sortOrderascending | descendingascending
json
{
  "schemas": ["urn:ietf:params:scim:api:messages:2.0:ListResponse"],
  "totalResults": 412,
  "itemsPerPage": 50,
  "startIndex": 51,
  "Resources": []
}

An empty Resources array with itemsPerPage: 0 means you have reached the end. totalResults is the count matching the filter, not the page size.

#Audit-log export is paged too

GET /audit-events/export does not take a cursor. Bound it by window and filter instead, and split a large window:

bash
# 7 days at a time
curl -sS -G "$BASE/audit-events/export" -H "Authorization: Bearer $ULEX_API_KEY" \
  --data-urlencode 'format=ndjson' \
  --data-urlencode 'since=2026-09-01T00:00:00.000Z' \
  --data-urlencode 'until=2026-09-08T00:00:00.000Z' \
  -o audit-week-36.ndjson

Exports above 100,000 events are 413. Above 10,000 in format: json they are truncated silently — use ndjson for anything you intend to verify a chain over.

#Limits and costs

AspectValue
Maximum limit200
Default limit20
GET /users and GET /organizations hard cap10,000 rows, then has_more: false and a truncated view
Cursor validity1 hour, then 400 validation_failed
Page consistencynot snapshot-isolated. Concurrent writes are visible between pages

That last row is the one to internalise: if you need a consistent snapshot, filter by since/until on a timestamp (audit events) or take a checkpoint yourself. For user and organization lists, a slightly stale view across pages is the correct trade.

Deeper: Rate limits, Idempotency, Errors.