Errors
ClinikAPI uses standard HTTP status codes and returns structured error responses.Error Response Format
HTTP Status Codes
| Status | Meaning |
|---|---|
400 | Bad Request — malformed JSON or invalid parameters |
401 | Unauthorized — missing or invalid API key |
403 | Forbidden — key doesn’t have required scope |
404 | Not Found — resource doesn’t exist or belongs to another tenant |
409 | Conflict — resource version conflict |
422 | Validation Error — request body failed Zod validation |
429 | Rate Limited — too many requests for your plan |
500 | Internal Error — something went wrong on our end |
Error Codes
| Code | Description |
|---|---|
UNAUTHORIZED | Missing x-api-key header |
INVALID_KEY_FORMAT | Key doesn’t 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 errors that you can catch:Automatic Retries
The SDK automatically retries on5xx errors and 429 (rate limit) responses with jittered exponential backoff:
- Default: 2 retries
- Backoff: random jitter up to
min(1000 * 2^attempt, 10000)ms - Configurable via
retriesoption:
Rate Limits
Rate limits are plan-based and returned in response headers:| Header | Description |
|---|---|
X-RateLimit-Limit | Total requests allowed per window |
X-RateLimit-Remaining | Requests remaining in current window |
X-RateLimit-Reset | Seconds until the window resets |
meta: