Skip to content

Errors and pagination

Problem documents, machine-readable codes, and cursor pagination.

3 min read

Errors

Most errors are RFC 9457 problem documents; a few endpoints, such as lead import and call-recording playback, return a plain JSON body with a message field instead. A problem document looks like this:

json
{
  "type": "https://docs.nexuscrm.com/api/problems/validation_failed",
  "title": "The request was invalid.",
  "status": 422,
  "detail": "1 field(s) did not pass validation.",
  "code": "validation_failed",
  "request_id": "01KYM97KCJK416C465Y2A8AN3N",
  "errors": [{ "field": "phone", "code": "invalid", "message": "Either a phone number or an email address is required." }]
}

Branch on code, never on title or detail. The human-readable strings may be reworded at any time; the code is a contract.

StatusCodeMeaning
401unauthenticatedMissing, malformed or revoked token
403forbiddenAuthenticated, but the token lacks the ability
404not_foundNo such record — or it is outside your data scope
409identifier_taken, illegal_status_transition, callback_date_required and othersA duplicate, or a state that forbids the change; each case has its own code
422validation_failedSee errors for per-field detail
429rate_limitedBack off; the body's retry_after gives the wait in seconds
503service_unavailableRetry with backoff
Note
Reading, editing or deleting a record that exists but sits outside your token's data scope returns 404, not 403 (changing a lead's status is an exception: it returns 403 forbidden, for unknown leads too). Confirming that a record exists but is off-limits is itself a disclosure.

An unexpected server error returns a generic internal_error body with no stack trace or SQL fragment. Quote request_id to support and we can find the exact request in our logs.

Pagination

The main record lists (leads, contacts, accounts, deals, tasks, conversations) are cursor-based. Leads, contacts and accounts also accept page[number] to jump to a page (up to page 200), and a few lists, such as call recordings, use page[offset] instead.

http
GET /api/v1/leads?page[size]=50
json
{
  "data": [],
  "links": { "next": "/api/v1/leads?page[size]=50&page[after]=01H8XGJ..." },
  "meta": { "has_more": true }
}

Follow links.next until it is null:

js
let url = '/api/v1/leads?page[size]=100';

while (url) {
  const page = await get(url);
  process(page.data);
  url = page.links.next;
}

Why there is no page=2

OFFSET 40000 makes the database walk forty thousand rows in order to discard them, so deep pages get progressively slower until an export times out. A cursor is a WHERE on an indexed column — page 500 costs the same as page 1.

It is also stable. With offset pagination, a row inserted while you iterate shifts everything down by one and you read the same record twice. A cursor cannot do that, because it remembers a position in the data rather than a count.

Stuck on a response you did not expect? Send us the request_id from the error body and we can trace the exact call — contact support.

Errors and pagination — API reference — atomcrm.ai