Search.../

cancelBooking( )

Developer Preview

Cancels a booking.

Description

The booking status changes to CANCELED.

If the booking was for an appointment, the corresponding session is deleted from the business calendar.

If the booking was for a class or course, the participants are removed from the class session or the course. But the course or class session remains on the business calendar.

You can pass a participantNotification.message to notify the customer of the cancelation. You also need to pass participantNotification.notifyParticipants as true to actually send the message.

In case you want to cancel a booking on behalf of a customer, we recommend to pass flowControlSettings.ignoreCancellationPolicy as false. This ensures that the cancelation is validated against the service's cancelation policy.

This function is not a universal function and runs only on the backend.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function cancelBooking(bookingId: string, options: CancelBookingOptions): Promise<CancelBookingResponse>

cancelBooking Parameters

NAME
TYPE
DESCRIPTION
bookingId
string

ID of the booking to cancel.

options
CancelBookingOptions

An object representing the available options for canceling a booking.

Returns

Return Type:

Promise<
CancelBookingResponse
>
NAME
TYPE
DESCRIPTION
booking
Booking

Canceled booking.

Was this helpful?

cancelBooking example

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