Skip to main content

Overview

The Ordinal API uses conventional HTTP response codes to indicate the success or failure of an API request. Codes in the 2xx 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:
For validation errors, additional field-level details are included:

Error Code Reference

Common Error Codes

400 Bad Request

Returned when the request contains invalid parameters or fails validation.
Common causes:
  • 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.
Common causes:
  • Missing Authorization header
  • 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.
Common causes:
  • 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.
Common causes:
  • Resource ID doesn’t exist
  • Resource belongs to a different workspace
  • Resource was deleted

409 Conflict

Returned when the request conflicts with existing data.
Common causes:
  • Attempting to create a duplicate resource
  • Unique constraint violation

429 Too Many Requests

Returned when you’ve exceeded the rate limit.
How to handle:
  • 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

Always check the HTTP status code before parsing the response body.
For 400 errors, check the data.errors field for field-specific messages.
For rate limits and server errors, implement retry with exponential backoff.
Log error responses with context for easier debugging.

Example Error Handler