Error reference
Rightbrain errors are not represented by one universal envelope. The forms below cover the shared contracts and high-impact exceptions. Check each endpoint’s API reference for its documented statuses and endpoint-specific errors.
Response forms
When detail.reason is present, branch on it instead of parsing detail.message. Do not assume every error has a reason code or an error-specific details field.
Authentication and permission
401 authentication failures
Missing or rejected credentials return a top-level error object rather than the detail envelope. It contains code, status, and message.
Mint or refresh the credential once, then retry the request.
403 permission failures
Permission checks return PERMISSION_CHECK_FAILED with a permissionCheckFailedError object describing the subject, resource, and permission.
The message can end with or it may not exist. A 403 therefore does not prove that the resource exists: the caller may lack permission, or the identifier may not resolve through the permission check.
404 resource failures
Structured resource lookups return RESOURCE_NOT_FOUND with a resourceNotFoundError object. Other endpoints return a string detail, including some file, trigger, integration, and MCP server lookups. Unmatched routes also return a string detail.
Treat 403 and 404 according to the endpoint contract. Do not infer resource ownership or existence from the status alone.
Request validation
Schema validation normally returns 422 with a detail array. FastAPI-generated items use msg; Rightbrain service validators can use message. Read both fields.
Common validation item types include:
Malformed identifiers resolved by application dependencies can instead return 400 MALFORMED_RESOURCE_IDENTIFIER. Validate UUIDs before sending them, but still handle both statuses.
Common reason codes
This table is not a complete list. It covers reason codes shared across multiple routes or important execution paths.
An endpoint can override a domain error’s default status. Use the API reference and the actual HTTP status together with the reason code.
Integration preconditions
Gmail inbox trigger creation uses detail.code, not detail.reason, when the integration cannot be used:
Other Gmail preconditions use string detail values: a missing integration returns 404, and a non-Gmail or incompatible integration returns 422.
MCP OAuth redirects
MCP server authorization is a browser flow:
The failure redirect appends error=oauth_authorization_failed, error_description, and server_url. When redirect_to is omitted, startup failures return a normal 400 JSON response instead.
The callback is also browser-driven. It uses the secure oauth_state cookie from the authorize step rather than bearer authentication and redirects after processing.
Task and agent runs
Task runs require a top-level task_input object. Request parsing and validation failures can occur before execution begins. Billing or credit preconditions return 402; changing the request without resolving the account state will not make that request succeed.
Agent runs require message and return Server-Sent Events after preflight checks pass. Preflight failures are ordinary HTTP errors, even when the request accepts text/event-stream. Once a 200 stream is open, run failures arrive as an error event.
An approval_required event is not a failure. It closes the current stream and leaves the run in waiting_for_human. Approving records the decision; call the approval request’s /resume endpoint to execute the approved tool and continue the run.
Server errors
A 5xx response can be:
- Plain text
Internal Server Errorfor an unhandled exception. - JSON with a string
detail. - A structured domain error, including
INVALID_LLM_RESPONSE,UNEXPECTED_TASK_EXECUTION, orINTERNAL_ERROR.
Check the status and content type before decoding JSON. Do not depend on internal provider text in an execution error remaining stable.
Retry guidance
- Refresh or replace a credential once after
401. - Resolve permission, validation, billing, or integration state before retrying
4xx. - Retry
409only after the conflicting state changes. - Back off on
429. - Retry transient
5xxfailures with a limit and jitter; investigate repeated structured execution failures.