cancelBooking( )


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:

  • 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.

Method Declaration
Copy
function cancelBooking(
  bookingId: string,
  options: CancelBookingOptions,
): Promise<CancelBookingResult>;
Method Parameters
bookingIdstringRequired

ID of the booking to be canceled.


optionsCancelBookingOptionsRequired

An object representing the available options for canceling a booking.

Returns
Return Type:Promise<CancelBookingResult>
Cancel a booking.
JavaScript
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" * } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?