Overview
The Ordinal API uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the2xx range indicate success, codes in the 4xx range indicate an error with the provided information, and codes in the 5xx range indicate an error with Ordinal’s servers.
Error Response Format
All error responses follow a consistent JSON format:Error Code Reference
| Code | HTTP Status | Description |
|---|---|---|
BAD_REQUEST | 400 | Invalid input or validation failure |
UNAUTHORIZED | 401 | Authentication required or failed |
FORBIDDEN | 403 | Access denied |
NOT_FOUND | 404 | Resource not found |
CONFLICT | 409 | Resource conflict |
TOO_MANY_REQUESTS | 429 | Rate limit exceeded |
INTERNAL_SERVER_ERROR | 500 | Server error (contact support if persistent) |
Common Error Codes
400 Bad Request
Returned when the request contains invalid parameters or fails validation.- Validation Error
- Business Logic Error
- Invalid Reference
- Missing required fields
- Invalid field formats (e.g., invalid UUID, email, date)
- Business rule violations
- References to resources that don’t exist or belong to another workspace
401 Unauthorized
Returned when authentication fails.- Missing
Authorizationheader - Invalid API key format
- API key doesn’t exist
- API key was revoked
403 Forbidden
Returned when authentication succeeds but the request is not allowed.- Revoked Key
- Expired Key
- Insufficient Permissions
- Engagement Profile
- API key has been revoked or expired
- Insufficient permissions for the operation
- Attempting to use engagement-only profiles for analytics
404 Not Found
Returned when the requested resource doesn’t exist.- Resource ID doesn’t exist
- Resource belongs to a different workspace
- Resource was deleted
409 Conflict
Returned when the request conflicts with existing data.- Attempting to create a duplicate resource
- Unique constraint violation
429 Too Many Requests
Returned when you’ve exceeded the rate limit.- Wait for the rate limit to reset
- Implement exponential backoff
- Cache responses where appropriate
- Contact support if you need to increase the rate limit
Handling Errors
Best Practices
Check HTTP Status Codes
Check HTTP Status Codes
Always check the HTTP status code before parsing the response body.
Handle Validation Errors
Handle Validation Errors
For 400 errors, check the
data.errors field for field-specific messages.Implement Retry Logic
Implement Retry Logic
For rate limits and server errors, implement retry with exponential backoff.
Log Errors for Debugging
Log Errors for Debugging
Log error responses with context for easier debugging.