Error Response Format
All API errors follow a consistent format to make error handling predictable and reliable.Standard Error Structure
HTTP status code (400, 401, 403, 404, 500, etc.).
Human-readable error description explaining what went wrong.
Machine-readable error code for programmatic error handling.
Unique identifier for this request. Include this when contacting support or reporting issues.
HTTP Status Codes
The API uses standard HTTP status codes to indicate the outcome of requests:Success Codes (2xx)
Request succeeded. Response body contains the requested data.
Resource created successfully. Response body contains the new resource.
Request succeeded with no response body (typically for DELETE operations).
Client Error Codes (4xx)
The request is malformed or contains invalid parameters.
Authentication is required or the provided credentials are invalid.
Authentication succeeded but the user lacks permission for this operation.
The requested resource does not exist.
The HTTP method is not supported for this endpoint.
The request conflicts with the current state (e.g., duplicate resource).
Request syntax is valid but contains semantic errors.
Rate limit exceeded. Check the
Retry-After header.Server Error Codes (5xx)
An unexpected error occurred on the server.
The service is temporarily unavailable (maintenance, overload, etc.).
Error Codes
Thecode field provides a machine-readable error identifier for programmatic handling.
Client Error Codes
| Error Code | HTTP Status | Description |
|---|---|---|
BAD_REQUEST | 400 | Malformed request or invalid parameters |
UNAUTHORISED | 401 | Missing or invalid authentication |
FORBIDDEN | 403 | Insufficient permissions |
NOT_FOUND | 404 | Resource does not exist |
METHOD_NOT_ALLOWED | 405 | HTTP method not supported |
CONFLICT | 409 | Resource conflict |
VALIDATION_ERROR | 422 | Request validation failed |
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
Server Error Codes
| Error Code | HTTP Status | Description |
|---|---|---|
INTERNAL_ERROR | 500 | Unexpected server error |
SERVICE_UNAVAILABLE | 503 | Service temporarily unavailable |
DATABASE_ERROR | 500 | Database connection or query error |
Common Error Scenarios
Authentication Errors
Missing Authorization Header:Validation Errors
Missing Required Fields:Resource Errors
Resource Not Found:Rate Limiting
Too Many Requests:Retry-After header:
Database Errors
Database Connection Issues:Server Errors
Internal Server Error:Error Handling Best Practices
Check Status Codes
Always check the HTTP status code before parsing the response:Handle Specific Error Codes
Use thecode field for programmatic error handling:
Implement Retry Logic
For transient errors (429, 503), implement exponential backoff:Log Request IDs
Always log therequest_id when errors occur:
Validate Input Client-Side
Validate input before sending requests to avoid unnecessary API calls:Debugging Errors
Include Request ID in Support Requests
When reporting issues, always include therequest_id:
Check Server Logs
For 5xx errors, the server logs contain detailed context:- Request method and path
- User ID and organisation ID
- Error stack trace
- Request ID for correlation
Monitor Error Rates
Track error rates by code to identify patterns:- High
UNAUTHORISEDrates may indicate token refresh issues - High
RATE_LIMIT_EXCEEDEDrates suggest too frequent requests - High
DATABASE_ERRORrates indicate infrastructure issues
Error Logging Behaviour
The API logs errors at different severity levels:Client Errors (4xx)
Logged atDEBUG level as these are expected client mistakes:
- Missing required fields
- Invalid input format
- Authentication failures
Server Errors (5xx)
Logged atERROR level as these indicate server-side issues:
- Database connection failures
- Unexpected exceptions
- Service unavailability
request_id for tracing requests through the system.