Sample Flows

This guide provides sample flows focusing on the technical details of creating appointment, class session, and course bookings using Create Booking (SDK | REST). For a complete step-by-step overview of the full booking process (including service selection, availability checks, and payment), see End-to-End Booking Flows (SDK | REST).

Book an appointment

To create a booking for an appointment:

  1. Identify the business time zone and relevant service ID. For example, as described in End-to-End Booking Flows (SDK | REST).
  2. Call Query Availability (SDK | REST) specifying serviceId, timezone, startDate, and endDate as filters. Save the relevant availabilityEntries.slot.
  3. Call Create Booking (SDK | REST). Specify the slot's startDate, endDate, resource and location in booking.bookedEntity.slot. If the slot's availability hasn't changed since calling Query Availability, the call succeeds and the status of the booking is CREATED.

Book a class session

To create a booking for a class session:

  1. Identify the business time zone and relevant service ID. For example, as described in End-to-End Booking Flows (SDK | REST).
  2. Call Query Availability (SDK | REST). Specify serviceId, timezone, startDate, endDate, and the number of openSpots the customer intends to book as filters. Save the eventId from availabilityEntries.slot.eventId for the selected session.
  3. Call Create Booking (SDK | REST) specifying the event ID in booking.bookedEntity.slot.eventId. If the class session's availability hasn't changed since calling Query Availability, the call succeeds and the status of the booking is CREATED.

Book a course

To create a booking for a course:

  1. Identify the relevant business time zone, service ID, service default capacity, and service schedule ID. For example, as described in End-to-End Booking Flows (SDK | REST).
  2. Retrieve all bookings for this service with Query Extended Bookings (SDK | REST) and calculate how many people are already booked for the course.
  3. Make sure the intended numberOfParticipants doesn't exceed the remaining places.
  4. Call Create Booking (SDK | REST) specifying the relevant schedule ID as booking.bookedEntity.scheduleId. If the course's availability hasn't changed since calling Query Extended Bookings, the call succeeds and the status of the booking is CREATED.

Important: Calling Create Booking (SDK | REST) can fail if the service is no longer available. To ensure success, for example if you want to create a booking on behalf of the business owner, call Create Booking with options.flowControlSettings.skipAvailabilityValidation set to true. Using other flowControlSettings lets you override the maximum number of participants per session, or allow payment methods that aren't supported for the service.

Handle payments

Once you've created a booking, handle payments using Wix eCommerce (SDK | REST) or your own custom checkout flow. For step-by-step instructions for payment processing, see the Sample Booking Flows article (SDK | REST).

Did this help?