Error Response Format
All error responses follow a consistent structure:| Field | Type | Description |
|---|---|---|
code | string | A machine-readable error code for programmatic handling |
message | string | A human-readable description of what went wrong |
details | object | Additional context about the error (optional) |
HTTP Status Codes
| Status | Meaning | When It Occurs |
|---|---|---|
200 | OK | Request succeeded |
201 | Created | Resource was created successfully |
204 | No Content | Request succeeded with no response body (e.g., DELETE) |
400 | Bad Request | Invalid request format or parameters |
401 | Unauthorized | Missing or invalid API key |
403 | Forbidden | Valid API key but insufficient permissions |
404 | Not Found | Resource doesn’t exist |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Something went wrong on our end |
503 | Service Unavailable | Temporary service outage |
Error Codes Reference
Authentication Errors
| Code | Status | Description |
|---|---|---|
UNAUTHORIZED | 401 | Invalid or missing API key |
INSUFFICIENT_PERMISSIONS | 403 | API key lacks required permissions |
Validation Errors
| Code | Status | Description |
|---|---|---|
VALIDATION_ERROR | 400 | Request body failed validation |
INVALID_INPUT | 400 | Invalid query parameters or input |
MISSING_QUERY | 400 | Required query parameter is missing |
Resource Errors
| Code | Status | Description |
|---|---|---|
NOT_FOUND | 404 | Requested resource doesn’t exist |
INVALID_MESSAGE_ID | 400 | Invalid message ID format |
INVALID_CONTACT_ID | 400 | Invalid contact ID format |
INVALID_BUSINESS_ID | 400 | Invalid business ID format |
Rate Limiting Errors
| Code | Status | Description |
|---|---|---|
RATE_LIMIT_EXCEEDED | 429 | Too many requests |
Server Errors
| Code | Status | Description |
|---|---|---|
INTERNAL_ERROR | 500 | Unexpected server error |
SERVICE_UNAVAILABLE | 503 | Service temporarily unavailable |
Handling Errors
Basic Error Handling
Retry with Exponential Backoff
For transient errors (429, 500, 503), implement retry logic with exponential backoff:Best Practices
Always check the error code
Always check the error code
Use the
code field for programmatic error handling, not the message. Error messages may change, but error codes remain stable.Log errors with context
Log errors with context
Include the request ID from response headers (
X-Request-ID) when logging errors to help with debugging and support requests.Handle validation errors gracefully
Handle validation errors gracefully
Parse the
details.issues array to show specific field errors to your users rather than generic error messages.