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 totrue
.
Syntax
function cancelBooking(bookingId: string, options: CancelBookingOptions): Promise<CancelBookingResult>
cancelBooking Parameters
NAME
TYPE
DESCRIPTION
ID of the booking to be canceled.
An object representing the available options for canceling a booking.
Returns
Return Type:
NAME
TYPE
DESCRIPTION
ID of the canceled booking.
Was this helpful?
Cancel a booking.
1import { Permissions, webMethod } from "wix-web-module";2import { bookings } from "wix-bookings-backend";34export const cancelBooking = webMethod(Permissions.Anyone, async () => {5 const bookingId = "001c0674-d7c9-4c77-acb5-b492b427b201";6 const cancelBookingOptions = {7 participantNotification: {8 notifyParticipants: true,9 message: "Custom cancel booking message",10 },11 flowControlSettings: {12 ignoreCancellationPolicy: false,13 },14 suppressAuth: true,15 };1617 try {18 const id = await bookings.cancelBooking(bookingId, cancelBookingOptions);19 return id;20 } catch (error) {21 return error;22 }23});2425/* Returns a promise that resolves to:26 * {27 * "bookingId": "001c0674-d7c9-4c77-acb5-b492b427b201"28 * }29 */