TypeScript SDK
The SDK stays close to the HTTP API while giving browser code Schedule X-ready config:
- Backend code creates users and calendars with the organization API token.
- Backend code creates short-lived frontend tokens.
- Browser code uses a frontend token to load Schedule X config and persist event changes.
- The calendar preset wires loaded config into Schedule X Calendar.
Install
Section titled “Install”pnpm add @schedule-x-cloud/sdk temporal-polyfillFor the calendar preset, also install the Schedule X peer packages used by your app:
pnpm add @schedule-x/calendar @schedule-x/event-recurrence @schedule-x/translations @sx-premium/interactive-event-modalServer Token Issuing
Section titled “Server Token Issuing”Create one server client for backend-only work:
import { ScheduleXServerClient } from '@schedule-x-cloud/sdk'
const serverClient = new ScheduleXServerClient({ apiKey: process.env.SCHEDULE_X_ORG_API_TOKEN,})The SDK defaults to https://cloud.schedule-x.com. You can pass baseUrl to target another deployment:
const serverClient = new ScheduleXServerClient({ apiKey: process.env.SCHEDULE_X_ORG_API_TOKEN, baseUrl: 'https://calendar-api.example.com',})Create or find the Cloud user after your application authenticates the user:
const user = await serverClient.users.create( process.env.SCHEDULE_X_ORGANIZATION_ID!, { email: 'ada@example.com', displayName: 'Ada Lovelace', role: 'Member', })Create a calendar:
const calendar = await serverClient.calendars.create( process.env.SCHEDULE_X_ORGANIZATION_ID!, { name: 'Work', slug: 'work', colorName: 'work', lightMainColor: '#2563eb', lightContainerColor: '#dbeafe', lightOnContainerColor: '#172554', })Issue a frontend token for a Cloud user id:
import { ScheduleXServerClient } from '@schedule-x-cloud/sdk'
export async function createScheduleXFrontendToken(userId: string) { return serverClient.auth.createFrontendToken({ organizationApiToken: process.env.SCHEDULE_X_ORG_API_TOKEN!, organizationId: process.env.SCHEDULE_X_ORGANIZATION_ID!, userId, })}Browser Config
Section titled “Browser Config”import 'temporal-polyfill/global'import { ScheduleXBrowserClient } from '@schedule-x-cloud/sdk'
const client = new ScheduleXBrowserClient({ token: frontendToken.token,})
const config = await client.scheduleX.getCalendarAppConfig({ from: '2026-05-01T00:00:00+00:00', to: '2026-06-01T00:00:00+00:00',})Browser clients do not need an organization id for the default config and event endpoints. The API resolves the organization and user from the frontend token.
Browser Event Writes
Section titled “Browser Event Writes”const event = await client.events.create({ calendarId: calendar.id, title: 'Planning', start: '2026-06-10T09:00:00+02:00', end: '2026-06-10T10:00:00+02:00', timeZone: 'Europe/Berlin',})
await client.events.update(event.id, { calendarId: calendar.id, title: 'Updated planning', start: '2026-06-10T09:30:00+02:00', end: '2026-06-10T10:30:00+02:00', timeZone: 'Europe/Berlin',})
await client.events.delete(event.id)Create and update requests require calendarId, start, end, and timeZone.
Calendar Preset
Section titled “Calendar Preset”import 'temporal-polyfill/global'import '@schedule-x/theme-default/dist/index.css'import '@sx-premium/interactive-event-modal/index.css'
import { createCalendar } from '@schedule-x/calendar'import { ScheduleXBrowserClient, loadScheduleXCloudCalendarPreset,} from '@schedule-x-cloud/sdk'
const client = new ScheduleXBrowserClient({ token: frontendToken.token,})
const preset = await loadScheduleXCloudCalendarPreset({ client, configQuery: { from: '2026-05-01T00:00:00+00:00', to: '2026-06-01T00:00:00+00:00', },})
const calendarApp = createCalendar(preset.calendarOptions)The preset creates the default day, week, month grid, and month agenda views. It also wires browser create, update, and delete calls for events.
You can customize persistence behavior:
const preset = await loadScheduleXCloudCalendarPreset({ client, canPersistEvent: (event) => event.calendarId === 'work', callbacks: { onCreateError: (error) => console.error(error), onUpdateError: (error) => console.error(error), onDeleteError: (error) => console.error(error), },})Errors
Section titled “Errors”Failed API responses throw ScheduleXApiError.
import { ScheduleXApiError } from '@schedule-x-cloud/sdk'
try { await client.events.create(request)} catch (error) { if (error instanceof ScheduleXApiError) { console.error(error.status, error.responseBody) }}