requestId that uniquely identifies the failed request — always log this value so you can correlate client-side errors with server-side traces when filing a support ticket. By default, the SDK retries transient failures automatically using jittered exponential backoff.
Error types
The SDK defines four error classes:| Class | HTTP status | When thrown |
|---|---|---|
ClinikValidationError | 422 | Request body failed schema validation |
ClinikRateLimitError | 429 | Rate limit exceeded |
ClinikNotFoundError | 404 | Resource does not exist |
ClinikApiError | Any other | All other API errors |
Catching errors
Error properties
All SDK errors extendClinikApiError and share these base properties:
The error class name, for example
ClinikValidationError.Human-readable description of the error. Never contains Protected Health Information.
Machine-readable error code, for example
validation_failed, rate_limit_exceeded, not_found.HTTP status code returned by the API.
Unique request identifier. Include this in support tickets so the ClinikAPI team can trace the exact server-side execution.
ClinikValidationError
ClinikValidationError adds an issues array that describes each individual field-level validation failure:
Array of validation issue objects. Each issue has a
severity (always error), a code, and a diagnostics message that names the field and constraint.Validation error diagnostics describe field names and constraints — never field values. This ensures that PHI is never included in error messages.
ClinikRateLimitError
Number of seconds to wait before retrying. The SDK respects this automatically when
retries > 0.Automatic retries
The SDK retries failed requests automatically for:- 5xx server errors — transient server-side failures
- 429 rate-limit responses — waits for
retryAfterseconds before retrying - Network failures — DNS errors, connection resets, and timeouts
Configuring retries and timeout
Maximum retry attempts. Set to
0 to disable automatic retries entirely — useful for operations where idempotency is uncertain.Request timeout in milliseconds. The SDK cancels requests that exceed this limit and throws a
ClinikApiError with code timeout.Best practices
Follow these patterns to build resilient integrations:- Always wrap SDK calls in
try/catch— do not let unhandled SDK errors reach your users. - Log
requestIdon every error so you can cross-reference with ClinikAPI support. - Handle
ClinikValidationErrorseparately to present field-level feedback in your UI. - Monitor
meta.rateLimitRemainingin high-throughput workflows to throttle before hitting the limit. - Use
retries: 0for idempotency-sensitive create operations.