Skip to content

Booking

The site client’s booking lists the workspace’s calendars, reads a calendar’s free times and books one, through the same checks as its booking pages: the calendar’s hours, notice and window, the team’s calendars, deposits, and Turnstile.

const digize = createSiteClient();
const { services, turnstileSiteKey, bookingUrl } = await digize.booking.services();
const calendar = await digize.booking.calendar("latte-art");
// The first read needs the Turnstile widget's token; keep `session` for the next.
const { slots, session } = await digize.booking.slots(
"latte-art",
{ from: new Date(), to: Date.now() + 7 * 86_400_000 },
{ turnstileToken },
);
const booked = await digize.booking.book("latte-art", {
start: slots[0].start,
firstName: "Maya",
email: "maya@example.com",
answers: { allergies: "none" },
timezone: Intl.DateTimeFormat().resolvedOptions().timeZone,
turnstileToken: freshToken,
});
location.href = booked.checkoutUrl ?? booked.redirectUrl ?? booked.url;
Method Answers
services() business, currency, services (each calendar’s slug, name, description, duration in minutes, price and deposit in minor units, seats, location), bookingUrl and turnstileSiteKey.
calendar(slug) Its length, price, deposit, currency, timezone, team to pick from, noticeHours, windowDays, seats and questions.
slots(slug, { from, to }, { staffId, turnstileToken, session }) slots (each start in milliseconds and the staff free for it) and session, which lets the next reads skip Turnstile for half an hour.
book(slug, booking) url, the appointment’s own page to reschedule or cancel; checkoutUrl, Stripe Checkout when a deposit is due; redirectUrl, where the calendar sends people once booked; and status.

Booking sends the same confirmation emails, from the workspace’s sending domain, and starts the same automations as the booking page.