Errors & pagination
Errors & pagination
This page covers the conventions shared across every Rightbrain endpoint: how errors come back, how to page through lists, and the headers you can rely on.
Errors
A failed request returns a non-2xx status and a JSON body under a detail key.
Most Rightbrain errors carry a machine-readable reason, a human-readable message, and — where relevant — an error-specific details object:
Branch on reason (stable, machine-readable) rather than parsing message (human-readable, subject to change). Server errors (5xx) are deliberately opaque: they return reason: "INTERNAL_ERROR" with a generic message and no internal detail.
Authentication failures (401) are the exception to the detail envelope: they are rejected before the application layer and return {"error": {"code": 401, "status": "Unauthorized", "message": "Access credentials are invalid"}}, with no detail or reason.
Request validation
When a request body or query parameter fails schema validation, the API returns 422 with the standard FastAPI validation shape — a list of the fields at fault:
Status codes
Pagination
List endpoints return a paginated envelope: a pagination object plus a results array.
Page with two query parameters:
Pass the previous response’s pagination.next_cursor to fetch the next page. Omit it for the first page.
The maximum number of items per page.
Stop when has_next is false (next_cursor will be null).
Endpoints that return plain arrays
A few endpoints return a bare JSON array with no pagination envelope, because their result sets are small and fixed:
GET .../modelGET .../input_processorGET .../task_forwarder_typeGET .../guardrailGET .../api_keyGET .../task/{id}/share
Response headers
Task runs return two headers you can use for correlation and debugging:
x-task-run-id— the ID of the run just executed.x-task-revision-id— the revision that served it.
Idempotency
Public webhook triggers accept an idempotency key so a retried delivery is not processed twice. Use it when the caller might resend the same event. See Triggers & runs for configuring public webhook invocation.