Skip to content
Appointments
<sessions-appointments>

The time picker a business’s public page books appointments with, on its own. It draws the calendar’s Day view — the date header (whose date opens a month to jump to), a week strip with each day’s count of open times, and the day’s open times — with a month beside it on a wide page, and a View menu that switches to a drag-to-select Week grid or an availability Month. Everything around the picker is yours to draw: which service, how long or which services, a summary of the picked time and the button that books it. Read what there is to choose from the element’s activities, selectedActivity and lengths properties (or the sessions:activities-load and sessions:activity-change events), set your visitor’s choices on the activity, length and services attributes, follow the picked time with sessions:selection-change, and call book() from your own button. That opens the same booking sheet as the rest of Sessions — sign-in when the business wants an account, intake and consent, passes and memberships, guest or signed-in checkout, and payment — and sessions:booking-complete tells you when it went through. Supply an auth token (directly or via a wrapping <sessions-context>) to book as the signed-in visitor. For the whole booking surface, chooser and button included, use <sessions-schedule structure="booking">.

Install

<script type="module" src="https://assets.sessions.website/embeds/unstable/appointments.js"></script>
<sessions-appointments
  business="restore-wellness-demo"
></sessions-appointments>

Attributes

Edit any attribute below — the snippet above and the live preview to the side rebuild in place.

business : string

Handle of the business taking the appointments, without the leading @. Optional when a wrapping <sessions-context business="…"> already provides it.

activity : string

Id of the activity to book, from the element’s activities. Unset (or an id the business doesn’t take appointments for), the business’s first is booked. Changing it lets go of a picked time.

length : number

How long to book, in minutes, on an activity booked by length — one of the minutes in the element’s lengths. Unset, the shortest. A length the activity doesn’t offer is ignored. A picked time keeps its start when the new length still fits there.

services : string

Comma-separated service ids to book, on an activity with a service menu (pricing: "services"): one primary service and any add-ons, from the activity’s services. The picker then offers only starts with room for all of them.

view : day | week | month

The view it shows. day (default) is the time picker — a day’s open times under the week strip. week is a drag-to-select grid, for picking a range on a service booked by length. month shows how many times are open each day. Visitors can switch views from the View menu.

auth : token

Optional embed-scoped JWT issued via the business-pinned sign-in flow. When set, the appointment is booked on behalf of the token holder; when omitted, the visitor signs in (or checks out as a guest) in the booking sheet.

Scripting

Draw your own controls around the element and drive it from your page’s script: read its properties, set its attributes, call its methods and listen for its events.

<sessions-appointments business="your-business"></sessions-appointments>
<p id="summary"></p>
<button id="book" disabled>Book</button>

<script type="module">
  const picker = document.querySelector('sessions-appointments');
  const summary = document.querySelector('#summary');
  const button = document.querySelector('#book');

  // Build your own chooser and length chips from these, then set
  // picker.activity = id, or picker.setAttribute('length', '90').
  picker.addEventListener('sessions:activity-change', (event) => {
    const {selectedActivity, lengths} = event.target;
    console.log(selectedActivity?.name, lengths.map((length) => length.label));
  });

  picker.addEventListener('sessions:selection-change', (event) => {
    const {selection} = event.target;
    summary.textContent = selection
      ? [selection.label, selection.priceLabel].filter(Boolean).join(' · ')
      : '';
    button.textContent = selection?.actionLabel ?? 'Book';
    button.disabled = !selection?.bookable;
  });

  button.addEventListener('click', () => picker.book());

  picker.addEventListener('sessions:booking-complete', (event) => {
    const {booking} = event;
    console.log('Booked', booking.activity.name, booking.startAt);
  });
</script>

Properties

readonly activities: readonly AppointmentsActivity[]
What the business takes appointments for, to build your chooser from. Empty until they load; sessions:activities-load fires when they do.
readonly selectedActivity: AppointmentsActivity | null
The activity being booked: the one activity names, or the business’s first. (activity itself reflects the attribute, an id.)
readonly lengths: readonly AppointmentsLength[]
The lengths the selected activity can be booked for, each with its price, to build your length chips from. Empty when it books at one length or by its services.
readonly selection: AppointmentsSelection | null
The time the visitor picked, with what it costs and the label the business’s own button uses (“Book” or “Request this time”), or null.

Methods

book(): boolean
Book the picked time: opens the sign-in sheet when the business wants an account, then the booking sheet (details, intake and consent, payment). Returns false and opens nothing while there is no time to book — selection is null, or its bookable is false (say, no primary service picked yet).
clearSelection(): void
Let go of the picked time.

Events

Each is its own Event subclass, dispatched on the element. Read the state it changed from the element: event.target.selection. What isn’t state, like the booking just made, is on the event itself: event.booking, never event.detail. They bubble and cross shadow roots, so you can listen on the element or any ancestor. Outside a shadow root that holds the element, event.target is that root’s host, so read the element from event.composedPath()[0].

sessions:activities-load
AppointmentsActivitiesLoadEventevent.target.activities: readonly AppointmentsActivity[]
The business’s activities arrived. Fires again only if they change.
sessions:activity-change
AppointmentsActivityChangeEventevent.target.selectedActivity: AppointmentsActivity | nullevent.target.lengths: readonly AppointmentsLength[]
The activity being booked is known or changed, and with it the lengths to offer. Fires once the activities load, and again after each change to the activity attribute.
sessions:selection-change
AppointmentsSelectionChangeEventevent.target.selection: AppointmentsSelection | null
The visitor picked a time, changed it, or let it go (selection is null) — or its price settled. Draw your summary and enable your button from it.
sessions:booking-complete
AppointmentsBookingCompleteEventevent.booking: AppointmentsBooking
A booking went through in the sheet — or, when approval is manual, a request was sent to the business. The sheet stays open on its confirmation until the visitor closes it.
sessions:sheet-close
SessionsSheetCloseEvent
The booking sheet closed, booked or not.

Types

interface AppointmentsActivity {
  id: string;
  name: string;
  description: string | null;
  /** "Mon–Fri · 9:00 am – 5:00 pm · $90 / 60 min" */
  summary: string;
  /** manual: a booking is a request the business confirms */
  approval: 'automatic' | 'manual';
  /** increment: sized and priced by length; services: by its menu */
  pricing: 'increment' | 'services';
  services: readonly {
    id: string;
    kind: 'primary' | 'addOn';
    name: string;
    description: string | null;
    priceCents: number;
    priceLabel: string;
    durationMinutes: number;
  }[];
}
interface AppointmentsLength {
  minutes: number;
  /** "1 hr 30 min" */
  label: string;
  /** "$135", or null when free */
  priceLabel: string | null;
}
interface AppointmentsSelection {
  activity: {id: string; name: string};
  /** ISO 8601 */
  startAt: string;
  endAt: string;
  lengthMinutes: number;
  /** "Tue, Oct 6 · 10:00 – 11:00 am", in the business's time zone */
  label: string;
  /** before tax, in the currency's minor unit; 0 when free or covered by a pass */
  priceCents: number;
  priceLabel: string | null;
  serviceIds: readonly string[];
  /** "Book" or "Request this time" */
  actionLabel: string;
  /** whether book() can go ahead */
  bookable: boolean;
}
interface AppointmentsBooking {
  /** null when the order didn't report the booking */
  id: string | null;
  activity: {id: string; name: string};
  startAt: string | null;
  endAt: string | null;
  approval: 'automatic' | 'manual';
}

Content Security Policy

If your site sets a Content-Security-Policy, allow these origins: the embed loads its files from assets.sessions.website, calls the Sessions API on go.sessions.website, and frames sign-in and maps from embed.sessions.website. It also renders a card-payment form and (for guest checkout) a Cloudflare bot-challenge widget, and runs the business’s apps in hidden, sandboxed frames from go.sessions.website. Allow those origins too, or the payment form, challenge, or app rows will be blocked.

script-src https://assets.sessions.website https://challenges.cloudflare.com;
connect-src https://assets.sessions.website https://go.sessions.website;
frame-src https://embed.sessions.website https://challenges.cloudflare.com https://go.sessions.website;