Search.../

cancelBooking( )

Cancels an existing booking.

Description

The cancelBooking() function returns a Promise that resolves when the specified booking is canceled.

Canceling a booking causes the following changes:

  • The booking status changes to CANCELED.
  • The participant is removed from the session.
  • If the booking creates a session, the session that was created is deleted from the calendar.
  • The participant is notified, according to the participantNotification properties.

When cancelBooking() is invoked, the cancellation is validated against the service's bookings policy. If cancelBooking() is invoked by a Bookings Admin, the service's bookings policy can be ignored by setting ignoreCancellationPolicy to true.

Note: Only users with Bookings Admin permissions can cancel other customers' bookings. You can override the permissions by setting the suppressAuth option to true.

Syntax

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

cancelBooking Parameters

NAME
TYPE
DESCRIPTION
bookingId
string

ID of the booking to be canceled.

options
CancelBookingOptions

An object representing the available options for canceling a booking.

Returns

Return Type:

Promise<CancelBookingResult>
NAME
TYPE
DESCRIPTION
bookingId
string

ID of the canceled booking.

Was this helpful?

Cancel a booking.

Copy Code
1import { bookings } from "wix-bookings-backend";
2
3export function cancelBooking() {
4 const bookingId = "001c0674-d7c9-4c77-acb5-b492b427b201";
5 const cancelBookingOptions = {
6 participantNotification: {
7 notifyParticipants: true,
8 message: "Custom cancel booking message"
9 },
10 flowControlSettings: {
11 ignoreCancellationPolicy: false
12 },
13 suppressAuth: true
14 };
15
16 return bookings.cancelBooking(bookingId, cancelBookingOptions)
17 .then((id) => {
18 return id;
19 })
20 .catch((error) => {
21 return error;
22 });
23}
24
25/* Returns a promise that resolves to:
26 * {
27 * "bookingId": "001c0674-d7c9-4c77-acb5-b492b427b201"
28 * }
29 */