Error Handling

The Offly API uses standard HTTP status codes and returns structured error responses.

Error response format

All error responses follow a consistent JSON structure:

Error Response
{
  "error": {
    "code": "validation_error",
    "message": "Start date is required",
    "details": { "field": "start_date" }
  }
}
FieldDescription
codeA machine-readable error code
messageA human-readable description of the error
detailsAdditional context (optional, varies by error type)

Common error codes

StatusCodeDescription
400bad_requestThe request body is malformed or missing required fields
401unauthorizedMissing or invalid API key
403forbiddenThe API key does not have the required scope for this action
404not_foundThe requested resource does not exist
409conflictThe request conflicts with the current state (e.g. duplicate leave request)
422validation_errorThe request body failed validation (see details for field-level errors)
429rate_limitedToo many requests — see Rate Limits
500internal_errorAn unexpected error occurred on our side — retry or contact support

Handling errors

  • Always check the HTTP status code before parsing the response body
  • Use the code field for programmatic error handling
  • Display the message field to users when appropriate
  • For 429 responses, respect the Retry-After header
  • For 500 errors, implement exponential backoff with retries