Error response format
Every error response includes a human-readable message, a machine-readable code, a request ID for support, and an optional array of validation issues:requestId when contacting support — it traces the full request through ClinikAPI’s infrastructure.
HTTP status codes
| Status | Meaning |
|---|---|
400 | Bad request — malformed JSON or invalid parameters |
401 | Unauthorized — missing or invalid API key |
403 | Forbidden — key does not have the required scope |
404 | Not found — resource does not exist or belongs to another tenant |
409 | Conflict — resource version conflict |
422 | Validation error — request body failed schema validation |
429 | Rate limited — too many requests for your plan |
500 | Internal error — something went wrong on ClinikAPI’s end |
Error codes
| Code | Description |
|---|---|
UNAUTHORIZED | Missing x-api-key header |
INVALID_KEY_FORMAT | Key does not match clk_live_* or clk_test_* pattern |
INVALID_KEY | Key not found in the database |
KEY_REVOKED | Key has been revoked |
KEY_EXPIRED | Key has passed its expiration date |
VALIDATION_ERROR | Request body failed schema validation |
RATE_LIMITED | Plan request limit exceeded |
NOT_FOUND | Resource not found |
INTERNAL_ERROR | Unexpected server error |
SDK error handling
The SDK throws typed error classes that you can catch and branch on. This lets you handle validation failures, rate limits, and general API errors with different logic:err.requestId to ClinikAPI support when reporting unexpected ClinikApiError instances.
Automatic retries
The SDK automatically retries on5xx errors and 429 rate limit responses using jittered exponential backoff:
- Default: 2 retries
- Backoff: random jitter up to
min(1000 * 2^attempt, 10000)ms - Both
retriesandtimeoutare configurable at client initialization:
retries: 0 to disable automatic retries entirely.
Rate limit headers
Rate limits are plan-based. Every response includes headers so you can track your usage and back off proactively:| Header | Description |
|---|---|
X-RateLimit-Limit | Total requests allowed per window |
X-RateLimit-Remaining | Requests remaining in the current window |
X-RateLimit-Reset | Seconds until the window resets |
meta field of every response, so you do not need to parse headers directly:
PHI sanitization
Error responses never contain Protected Health Information (PHI). Field values are stripped from all validation error messages — only field names and constraint descriptions are included. For example, a validation error onbirthDate will report "birthDate: Invalid date format", not the value you submitted.