External Integrations

Error Model and Observability

Canonical error envelope, correlation ID behavior, and retry guidance for external clients.

Canonical Error Envelope

{
  "error": "Human-readable message",
  "code": "MACHINE_READABLE_CODE",
  "correlationId": "uuid"
}

Validation failures may include route-specific details payloads. Correlation IDs are also returned in X-Request-ID.

Error Code Matrix

CodeHTTPMeaningRetryable
AUTH_HEADER_INVALID401Authorization header missing or malformed for Clerk-protected endpoints.No
AUTH_TOKEN_INVALID401Clerk token invalid or expired.No
AUTH_NO_ORGANIZATION403No org/tenant context resolved from token/header.No
AUTHORIZATION_HEADER_MISSING401Device runtime call missing Authorization header.No
AUTHORIZATION_HEADER_INVALID401Device runtime Authorization header not in Bearer format.No
DEVICE_API_KEY_INVALID401Device API key hash not found or inactive.No
DEVICE_API_KEY_REVOKED401Device API key has been revoked.No
PROVISIONING_CODE_EXPIRED410Provisioning code is expired and cannot be reused.No
PROVISIONING_CODE_ALREADY_USED422Provisioning code has already been activated.No
RATE_LIMIT_EXCEEDED429Registration attempts exceeded per-IP threshold; honor Retry-After.Yes
DATABASE_ERROR500Unhandled persistence/query failure in route operation.Yes
REGISTRATION_ERROR500Device registration failed after internal compensation attempts.Yes

Retry Guidance

  • Respect Retry-After for HTTP 429 responses before retrying.
  • Treat 5xx responses as retryable with exponential backoff and jitter.
  • Do not retry expired/already-used provisioning codes (410, 422).
  • Do not retry authentication failures until credentials or context are fixed (401/403).

Operational Tracing

Always log and propagate X-Request-ID values in client logs and support tickets. This ID maps to API-side structured logs and is the primary trace handle for incident triage.