Installation
Setup
CallsetupOpencals() once at app startup — a root layout, an API client singleton, or a module you import from your server code:
OPENCALS_API_KEY environment variable set, setupOpencals() needs no arguments.
Services
The SDK mirrors the API’s tags as static service classes:
Every method takes a single options object with typed
path, query, body, and headers fields matching the underlying endpoint:
headers field:
Customer-authenticated requests
For endpoints that act on behalf of a signed-in customer, either passcustomerToken to setupOpencals() or set the header per call:
Error handling
With the default error handler enabled, failed requests throw a typedOpencalsApiError:
Zod validation
Response types come with auto-generated Zod schemas, useful when data crosses a trust boundary (for example, after passing through your own API routes):Helpers
The SDK includes small utilities you’d otherwise rewrite in every booking UI:toLocalFromUtc / toUtcFromLocal handle the UTC conversion the API expects for appointment slots, and mergeTimeIntervals is handy when rendering availability ranges.