Cancels an existing booking.
The cancelBooking()
function returns a Promise that resolves when the specified booking is canceled.
Canceling a booking causes the following changes:
CANCELED
.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
.
function cancelBooking(
bookingId: string,
options: CancelBookingOptions,
): Promise<CancelBookingResult>;
ID of the booking to be canceled.
An object representing the available options for canceling a booking.
import { Permissions, webMethod } from "wix-web-module";
import { bookings } from "wix-bookings-backend";
export const cancelBooking = webMethod(Permissions.Anyone, async () => {
const bookingId = "001c0674-d7c9-4c77-acb5-b492b427b201";
const cancelBookingOptions = {
participantNotification: {
notifyParticipants: true,
message: "Custom cancel booking message",
},
flowControlSettings: {
ignoreCancellationPolicy: false,
},
suppressAuth: true,
};
try {
const id = await bookings.cancelBooking(bookingId, cancelBookingOptions);
return id;
} catch (error) {
return error;
}
});
/* Returns a promise that resolves to:
* {
* "bookingId": "001c0674-d7c9-4c77-acb5-b492b427b201"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.