Error Handling
When an API request fails, you’ll receive a structured error response with details about what went wrong.Error Response Format
All errors follow this consistent format:Error Codes
Authentication Errors
Example (API key):
Widget Token Errors
Example (token exchange):
Authorization Errors
These errors occur when your authentication is valid but you lack the required role. Common scenarios:
- A member tries to perform an admin-only action (inviting members, changing roles)
- A user tries to access a project they haven’t been granted access to
- A non-admin tries to manage project members
Resource Errors
Example:
Validation Errors
Examples:
Task Execution Errors
Example:
Handling Errors in Code
JavaScript
Python
SSE Stream Errors
Errors during streaming are delivered aserror events:
Best Practices
Always check success field
Even on 200 responses, verify
success: true before processing dataLog error codes
Log the
code field for debugging and monitoringImplement retries
For transient errors (5xx), implement exponential backoff retries
Validate inputs
Validate inputs client-side to avoid unnecessary API calls