Skip to main content
When a request fails, the API returns a JSON response with success: false and an error object containing a machine-readable code, a human-readable message, and the HTTP status code.

Error response format

boolean
Always false for error responses.
object
string
A machine-readable error code. Use this for programmatic error handling.
string
A human-readable description of the error. Suitable for logging but not guaranteed to be stable across versions.
number
The HTTP status code associated with the error.

Error codes

Handling errors in code

With ApiService

ApiService.invoke() throws on error. Wrap calls in try/catch:

With fetch

When using fetch directly, check the success field in the response body:

With TanStack Query

When using TanStack Query (React Query), errors propagate through the query’s error state:

Retry strategy

Use exponential backoff for 429 and 500 errors. These are the only error codes worth retrying automatically. Authentication errors (401) require a token refresh, and validation errors (400, 403, 404) indicate a problem with the request itself.A recommended approach:
  1. Start with a 1-second delay after the first failure.
  2. Double the delay after each subsequent failure (1s, 2s, 4s, 8s…).
  3. Add random jitter (0-500ms) to avoid thundering herd problems.
  4. Give up after 3-4 retries and surface the error to the user.

Common error scenarios

The most common cause is an expired access token. Supabase tokens typically expire after 1 hour. Use supabase.auth.refreshSession() to get a new token.
Each resource supports a specific set of actions. Sending an unsupported action (e.g., action: "archive" to a resource that does not support it) returns INVALID_ACTION. Check the resource’s documentation in the API reference for supported actions.
The user’s role does not allow the requested operation. For example, a consumer user cannot create genies. See Introduction for the role permission matrix.
The record either does not exist or belongs to another user. Non-admin users can only access their own resources. Verify the id value and confirm the user has access.
Back off and retry with exponential delay. A simple implementation: