Skip to main content
@opencals/storefront-sdk is the official type-safe TypeScript client for the Storefront API. It’s generated from the same OpenAPI specification as the API reference, so every request and response is fully typed, and it ships with Zod schemas for runtime validation plus formatting helpers for prices, durations, and timezones. MIT licensed.

Installation

Setup

Call setupOpencals() once at app startup — a root layout, an API client singleton, or a module you import from your server code:
With the OPENCALS_API_KEY environment variable set, setupOpencals() needs no arguments.
The API key is attached to every request automatically — which also means SDK calls belong on the server, where the key is safe.

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:
Cart and checkout calls pass the cart ID through the typed headers field:

Customer-authenticated requests

For endpoints that act on behalf of a signed-in customer, either pass customerToken to setupOpencals() or set the header per call:
See Authentication for how to obtain and refresh customer tokens.

Error handling

With the default error handler enabled, failed requests throw a typed OpencalsApiError:

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.

Putting it together

The Build a booking page tutorial uses the SDK end-to-end — services, availability, cart, and checkout — and the open-source booking templates are complete Next.js apps built on it.
Last modified on June 21, 2026