Search.../

createBooking( )

Developer Preview

Creates a booking.

Description

To create a booking for an appointment or a session of a class, pass a booking with the relevant slot.

To create a booking for the entire course, pass a booking with the relevant schedule. You can use the Query Availability endpoint to check the availability beforehand.

If you create a booking for an existing session, we recommend that you only pass slot.sessionId. Then, any specified slot details are calculated.

If you create a booking for a new session, we recommend to call Query Availability first. Then, pass the retrieved availability.slot object as the BookedEntity.Slot of the booking in the request.

Bookings are created with a status of CREATED. CREATED bookings don't appear on the business calendar and don't affect a related schedule's availability.

To create a booking with a given status, pass a booking with the wanted status. This is only permitted for site Owners.

You can pass a participantNotification.message to notify the customer of the booking with a message. It's also necessary to pass participantNotification.notifyParticipantsas true to send the message.

You can pass sendSmsReminder as true, if you want an SMS reminder to be sent to the phone number specified in the ContactDetails, 24 hours before the session starts.

When creating a booking you must pass either participantsChoices or totalParticipants. If you pass participantsChoices, all the provided choices must exist for the service, otherwise the call returns an INVALID_SERVICE_CHOICES error.

When creating a booking, you can pass selectedPaymentOption. This specifies which payment method the customer plans to use. But it's possible for them to later use another supported payment method.

You can skip the checkout and payment flow if you call Confirm Or Decline Booking otherwise, after you create the booking, you can use the Wix eCommerce APIs (coming soon) for the checkout and payment flow or use a different service for checkout.

Syntax

function createBooking(booking: Booking, options: CreateBookingOptions): Promise<CreateBookingResponse>

createBooking Parameters

NAME
TYPE
DESCRIPTION
booking
Booking

The booking to create.

options
Optional
CreateBookingOptions

Returns

Return Type:

Promise<
CreateBookingResponse
>
NAME
TYPE
DESCRIPTION
booking
Booking

Created booking.

Was this helpful?

createBooking example

Copy Code
1import { bookings } from 'wix-bookings.v2';
2
3 async function createBooking(booking, options) {
4 try {
5 const result = await bookings.createBooking(booking, options);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13