Authentication
ClinikAPI uses API key authentication via thex-api-key header. Every request must include a valid key.
API Keys
Keys are created in the Developer Dashboard and follow this format:ClinikAPI is a Data API
ClinikAPI does not handle end-user authentication. You bring your own auth provider (Clerk, Auth0, Firebase, etc.) and use ClinikAPI purely for clinical data storage and retrieval.Tenant Isolation
Every resource stored in ClinikAPI is tagged with your organization’s tenant ID:- On create: the tenant tag is automatically injected
- On search: a
_tagfilter is automatically applied — you can only see your own data - On read/update/delete: ownership is verified before the operation proceeds
Multi-Datastore Routing
Requests are routed to different datastores based on your key and plan:
Enterprise customers get a fully isolated datastore provisioned in their preferred region.
Key Validation Flow
For minimal latency, API keys are validated against a co-located PostgreSQL database that mirrors your dashboard data:- You create/revoke keys in the Dashboard
- Key changes are automatically synced to the co-located database
- The API validates keys locally — no cross-region round trips
Key Scopes
Every API key carries scopes, and the API checks them on each request:read— GET operationswrite— POST, PATCH and DELETE operations
read and write. A request outside a key’s scopes is refused with
403 and the error code INSUFFICIENT_SCOPE. A key with no scopes at all is refused.
Live keys (clk_live_) can be created only by an organization owner or admin, and only on a paid plan. Test keys
(clk_test_) are available on every plan.
Security Best Practices
- Store keys in environment variables (
CLINIKAPI_SECRET_KEY) - Use
clk_test_*keys for development — they route to an isolated test datastore - Rotate keys periodically from the Dashboard
- Use scoped keys when possible (e.g., read-only for analytics services)
- For client-side UI, use
@clinikapi/reactwith the proxy pattern