Response Format & Error Handling

All API responses are JSON (Content-Type: application/json). This page describes the conventions used across different endpoint groups and how errors are communicated.

Data Endpoints

Trends, references, betting, and games endpoints return data directly - no envelope wrapper:

curl -X POST https://api.odditt.com/v1/trends/mixed-flows \
 -H "X-API-Key: YOUR_API_KEY" \
 -H "Content-Type: application/json" \
 -d '{"sport_id": 1, "league_id": 7, "page": 1, "page_size": 10}'
{
  "flows": [ ... ],
  "total_count": 42,
  "page": 1,
  "page_size": 10
}

Account Endpoints

Account management endpoints (/v1/account/*) wrap responses with a success field:

{
  "success": true,
  "api_keys": [ ... ]
}

Error Responses

The API uses standard HTTP status codes to indicate the success or failure of requests. All error responses return a JSON object with an error field:

{
  "error": "description of what went wrong"
}

Some endpoints return the response envelope with a success flag:

{
  "success": false,
  "error": "description of what went wrong"
}

HTTP Status Codes

CodeMeaningDescription
200OKRequest succeeded
201CreatedResource created (e.g. new API key or secret)
400Bad RequestInvalid request parameters or body
401UnauthorizedMissing, invalid, or expired authentication
403ForbiddenValid authentication but insufficient permissions or blocked by network policy
404Not FoundResource does not exist
409ConflictConflicting state (e.g. deactivating last API key)
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error

Common Error Scenarios

401 - Authentication Errors

{"error": "missing bearer token"}
{"error": "invalid authorization header"}
{"error": "invalid token"}
{"error": "invalid or missing API key"}

Resolution: Check your API key or access token. If using a JWT, it may have expired - refresh your token.

400 - Validation Errors

{"error": "invalid request body"}

Resolution: Check the API Reference for required parameters and valid values.

429 - Rate Limit Errors

{"error": "rate limit exceeded"}

Resolution: See Rate Limiting for backoff strategies.

403 - Forbidden

{"error": "forbidden"}

Resolution: Your client may not have permission to access this endpoint, or your IP/domain is not in the allowlist. Contact the Odditt team.

Common Headers

Request Headers

HeaderRequiredDescription
X-API-KeyConditionalAPI key authentication
AuthorizationConditionalBearer token authentication (Bearer <token>)
Content-TypeFor POSTMust be application/json for JSON request bodies

Response Headers

HeaderDescription
Content-TypeAlways application/json
X-Request-IdUnique request identifier for debugging
X-RateLimit-LimitYour rate limit ceiling
X-RateLimit-RemainingRemaining requests in the current window
X-RateLimit-ResetTimestamp when the rate limit window resets