APIs & Integrations

Error Codes

Complete reference of Optra API error codes with causes and remediation steps.

All errors follow a consistent envelope. The code field is a machine-readable string you can match programmatically; message is human-readable context.

{
  "error": {
    "code": "DEVICE_NOT_FOUND",
    "message": "No device with id 'dev_xyz' exists in this organisation.",
    "request_id": "req_7f3a9b"
  }
}

Authentication Errors (401 / 403)

Code HTTP Cause & Fix
UNAUTHORIZED401Missing or malformed Authorization header. Check your API key.
TOKEN_EXPIRED401OAuth token has expired. Request a new access token.
FORBIDDEN403Key lacks the required scope. Check your key's permissions.

Resource Errors (404 / 409)

Code HTTP Cause & Fix
DEVICE_NOT_FOUND404Device ID does not exist or belongs to another organisation.
RULE_NOT_FOUND404Rule ID does not exist.
DEVICE_ALREADY_EXISTS409A device with this serial is already registered.

Validation Errors (422)

Code HTTP Cause & Fix
VALIDATION_ERROR422Request body failed schema validation. See details array for field-level errors.
INVALID_DATE_RANGE422from is after to, or range exceeds the maximum 90-day window.

Server Errors (5xx)

Code HTTP Cause & Fix
INTERNAL_ERROR500Unexpected server error. Quote the request_id when contacting support.
SERVICE_UNAVAILABLE503Platform maintenance window. Retry with exponential backoff.