Wix Bookings events are fired in your site's backend when certain events occur in your site's Bookings application. You can write event handlers that react to these events. Event handler functions receive data that correspond to the event that has occurred. Use event handlers to create custom responses to bookings events.
To add a bookings event handler, add an events.js file to the Backend section of your site if one does not already exist. All event handler functions for your site are defined in this file.
Event handler functions are defined using the following pattern:
For example, an event handler that handles a new booking request looks like this:
Note: Backend events don't work when previewing your site.
An event that fires when a booking is canceled.
The onBookingCanceled()
event handler runs when a booking is canceled.
The event
object includes a trigger
property that describes the action that triggered the event.
The trigger
value is one of:
"OWNER_CANCELED"
: The booking was canceled by the business."MEMBER_CANCELED"
: The booking was canceled by the member.Note: Backend events don't work when previewing your site.
function onBookingCanceled(event: BookingEvent): void;
Information about a canceled booking.
// Place this code in the events.js file
// of your site's Backend section.
export function wixBookings_onBookingCanceled(event) {
const eventTrigger = event.trigger;
const bookingId = event.booking._id;
}
/* Full event object
* {
* "trigger": "OWNER_CANCELED",
* "booking": {
* "id": "23c9c0e1-345e-48e6-8d8f-30fd7249521e",
* "bookedResources": [{
* "id": "76570209-101f-409b-af97-b445bdb63125",
* "name": "John Smith",
* "email": "jsmith@gmail.com"
* }],
* "status": "CANCELED",
* "createdDate": "2021-02-24T10:15:22.485Z",
* "bookingSource": {
* "platform": "WEB",
* "actor": "CUSTOMER",
* "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
* "appName": "Wix Bookings"
* },
* "bookedEntity": {
* "serviceId": "b71df756-309f-468e-aec2-f82b9a9a9441",
* "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179",
* "singleSession": {
* "sessionId":193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7Ex
* gIRM1HunZjEPUQ0IeScwcTFJNXEmLG2g6 * Q8tvUJQZrPhU6XKhVrlLZraC3YcVfygADFiCPyy
* y5IVhgtDpF30FnQoG8I60n21QAlhok4LHNlkBszoGZ67jGMeDOqxS8PXZgJx87ByXwfgsN3AfXb
* ndYxESrFnttLnRSFzcsolQicMTHTo5lYkhTLLlW8g5lcg1nWBohx2JkDABUO7SXWvqSkQZBmgXo
* aZqiD1TBONPzIF84Vryelr1iTTzNl1cc6uJkhqo7DeSwWL",
* "start": "2021-03-12T17:30:00Z",
* "end": "2021-03-12T18:00:00Z"
* },
* "title": "Yoga Class",
* "rate": {
* "labeledPriceOptions": {
* "general": {
* "amount": "50",
* "currency": "USD",
* "downPayAmount": "0"
* }
* }
* },
* "tags": ["GROUP"],
* "location": { "locationType": "OWNER_BUSINESS" }
* },
* "paymentDetails": {
* "balance": {
* "finalPrice": {
* "amount": "50",
* "currency": "USD",
* "downPayAmount": "0"
* },
* "amountReceived": "0"
* },
* "state": "CANCELED",
* "wixPayMultipleDetails": [{
* "txId": "76c8f02b-b530-433b-9fb2-ee5e3483418c",
* "orderId": "93e44e16-17d1-48de-837c-53ed55132405",
* "orderAmount": "50",
* "paymentVendorName": "offline"
* }]
* },
* "formInfo": {
* "paymentSelection": [{
* "rateLabel": "general",
* "numberOfParticipants": 1
* }],
* "additionalFields": [{
* "id": "00000000-0000-0000-0000-000000000008",
* "label": "Add Your Message",
* "valueType": "LONG_TEXT"
* }],
* "contactDetails": {
* "contactId": "156b86e2-0cee-4586-aac8-f434c919e14c",
* "firstName": "Michael White",
* "email": "mwhite@gmail.com",
* "phone": "555 3456",
* "timeZone": "America/New_York",
* "countryCode": "US"
* }
* }
* },
* "previousBooking": {
* "id": "23c9c0e1-345e-48e6-8d8f-30fd7249521e",
* "bookedResources": [{
* "id": "76570209-101f-409b-af97-b445bdb63125",
* "name": "John Smith",
* "email": "jsmith@gmail.com"
* }],
* "status": "CONFIRMED",
* "createdDate": "2021-02-24T10:15:22.485Z",
* "bookingSource": {
* "platform": "WEB",
* "actor": "CUSTOMER",
* "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
* "appName": "Wix Bookings"
* },
* "bookedEntity": {
* "serviceId": "b71df756-309f-468e-aec2-f82b9a9a9441",
* "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179",
* "singleSession": {
* "sessionId":193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7Ex
* gIRM1HunZjEPUQ0IeScwcTFJNXEmLG2g6 * Q8tvUJQZrPhU6XKhVrlLZraC3YcVfygADFiCPyy
* y5IVhgtDpF30FnQoG8I60n21QAlhok4LHNlkBszoGZ67jGMeDOqxS8PXZgJx87ByXwfgsN3AfXb
* ndYxESrFnttLnRSFzcsolQicMTHTo5lYkhTLLlW8g5lcg1nWBohx2JkDABUO7SXWvqSkQZBmgXo
* aZqiD1TBONPzIF84Vryelr1iTTzNl1cc6uJkhqo7DeSwWL",
* "start": "2021-03-12T17:30:00Z",
* "end": "2021-03-12T18:00:00Z"
* },
* "title": "Yoga Class",
* "rate": {
* "labeledPriceOptions": {
* "general": {
* "amount": "50",
* "currency": "USD",
* "downPayAmount": "0"
* }
* }
* },
* "tags": ["GROUP"],
* "location": { "locationType": "OWNER_BUSINESS" }
* },
* "paymentDetails": {
* "balance": {
* "finalPrice": {
* "amount": "50",
* "currency": "USD",
* "downPayAmount": "0"
* },
* "amountReceived": "0"
* },
* "state": "PENDING_MARK_AS_PAID",
* "wixPayMultipleDetails": [{
* "txId": "76c8f02b-b530-433b-9fb2-ee5e3483418c",
* "orderId": "93e44e16-17d1-48de-837c-53ed55132405",
* "orderAmount": "50",
* "paymentVendorName": "offline"
* }]
* },
* "formInfo": {
* "paymentSelection": [{
* "rateLabel": "general",
* "numberOfParticipants": 1
* }],
* "additionalFields": [{
* "id": "00000000-0000-0000-0000-000000000008",
* "label": "Add Your Message",
* "valueType": "LONG_TEXT"
* }],
* "contactDetails": {
* "contactId": "156b86e2-0cee-4586-aac8-f434c919e14c",
* "firstName": "Michael White",
* "email": "mwhite@gmail.com",
* "phone": "555 3456",
* "timeZone": "America/New_York",
* "countryCode": "US"
* }
* }
* }
* }
*/
An event that fires when a booking request is confirmed.
The onBookingConfirmed()
event handler runs when a new booking request is confirmed.
The event
object includes a trigger
property that describes the action that triggered the event.
The trigger
value is one of:
"BOOKING_AUTO_CONFIRMED"
: A new booking was made for a service that is configured for automatic confirmation."OWNER_CONFIRMED_BOOKING_REQUEST"
: A booking was confirmed by the business."OWNER_BOOKED"
: The owner made a booking directly from the calendar.Note: Backend events don't work when previewing your site.
function onBookingConfirmed(event: BookingEvent): void;
Information about a confirmed booking.
// Place this code in the events.js file
// of your site's Backend section.
export function wixBookings_onBookingConfirmed(event) {
const eventTrigger = event.trigger;
const bookingId = event.booking._id;
}
/* Full event object
* {
* "trigger": "BOOKING_AUTO_CONFIRMED",
* "booking": {
* "_id": "99a406e7-cbce-4765-a4cd-ff0d2d9fb8c2",
* "bookedResources": [
* {
* "id": "5fe118a5-d4b2-464e-9334-268be4422908",
* "name": "Sam Slade",
* "email": "sams@gmail.com"
* }
* ],
* "status": "CONFIRMED",
* "createdDate": "2021-02-23T16:47:36.403Z",
* "bookingSource": {
* "platform": "WEB",
* "actor": "CUSTOMER",
* "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
* "appName": "Wix Bookings"
* },
* "bookedEntity": {
* "serviceId": "b71df756-309f-468e-aec2-f82b9a9a9441",
* "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179",
* "singleSession": {
* "sessionId": * "193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7ExgIRM1HunZjEPUQ0IeScwcTFJNXEmLG2g6Q8tvUJQZrPhU6XKhVrlLZraC3YcVfygADF * iCPyyy5IVhgtDpF30FnPznyrtkyH5fPewLT28aPO3bYaUZcXnNWumH3AaEAb8eyvUVbvkBxGSsv9RZXCgcMTjnhXUNwTBUGGxULnv2i5O933JqU3MACfQ6DUFaws9ufRJUc * RZwhmKpRIwWNmd0NtCD7ZlKaLkhu41yYjkZ4Z7YnqdBStzobnKjwbPbzPbVw4rXF8n47h8MTF",
* "start": "2021-02-25T23:30:00Z",
* "end": "2021-02-26T00:30:00Z"
* },
* "title": "Yoga Class",
* "rate": {
* "labeledPriceOptions": {
* "general": {
* "amount": "50",
* "currency": "USD",
* "downPayAmount": "0"
* }
* }
* },
* "tags": [
* "GROUP"
* ],
* "location": {
* "locationType": "OWNER_BUSINESS"
* }
* },
* "paymentDetails": {
* "balance": {
* "finalPrice": {
* "amount": "50",
* "currency": "USD",
* "downPayAmount": "0"
* },
* "amountReceived": "0"
* },
* "state": "PENDING_MARK_AS_PAID",
* "wixPayMultipleDetails": [
* {
* "txId": "f86bdab0-bd12-4128-85cd-e24f82dc38b8",
* "orderId": "5e65776f-ac54-4dc7-b94e-f2b887ba06e3",
* "orderAmount": "50",
* "paymentVendorName": "offline"
* }
* ]
* },
* "formInfo": {
* "paymentSelection": [
* {
* "rateLabel": "general",
* "numberOfParticipants": 1
* }
* ],
* "additionalFields": [
* {
* "id": "00000000-0000-0000-0000-000000000008",
* "label": "Add Your Message",
* "valueType": "LONG_TEXT"
* }
* ],
* "contactDetails": {
* "contactId": "eef94a55-8309-4927-ab6f-d91711e5484a",
* "firstName": "Andrew Brown",
* "email": "abrown@gmail.com",
* "phone": "555 3456",
* "timeZone": "America/New_York",
* "countryCode": "US"
* }
* }
* },
* "previousBooking": {
* "bookedEntity": {
* "location": { }
* },
* "paymentDetails": { },
* "formInfo": {
* "contactDetails": { }
* }
* }
* }
*/
An event that fires when a booking request is declined.
The onBookingDeclined()
event handler runs when a booking request is declined by the business.
The event
object includes a trigger
property that describes the action that triggered the event. The trigger
value for this event is "OWNER_DECLINED_BOOKING_REQUEST"
.
Note: Backend events don't work when previewing your site.
function onBookingDeclined(event: BookingEvent): void;
Information about a declined booking.
// Place this code in the events.js file
// of your site's Backend section.
export function wixBookings_onBookingDeclined(event) {
const eventTrigger = event.trigger;
const bookingId = event.booking._id;
}
/* Full event object
* {
* "trigger": "OWNER_DECLINED_BOOKING_REQUEST",
* "booking": {
* "_id": "d939f806-bb01-4472-a366-c0e136592531",
* "bookedResources": [{
* "id": "dc19d7db-6996-494b-8d6d-943d64e1f32a",
* "name": "Tom Jones",
* "email": "tom@yoga.com"
* }],
* "status": "DECLINED",
* "createdDate": "2021-02-28T17:32:18.310Z",
* "bookingSource": {
* "platform": "WEB",
* "actor": "CUSTOMER",
* "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
* "appName": "Wix Bookings"
* },
* "bookedEntity": {
* "serviceId": "49c7fac5-227c-44d0-a4f3-c1a5c511edf1",
* "scheduleId": "4b21a5af-3b69-42ce-a3ba-9cf60d7b4422",
* "singleSession": {
* "sessionId":"2mmoW0vwKcSFyxtOfCdMkutTlCGjD2Zol12Xf8oBKd3JBbarU
* KabZB1NL1R17TsQtpgpCg6eScmLnAtlwEzi7IiungZ45aRewhjR",
* "start": "2021-03-05T15:00:00.000Z",
* "end": "2021-03-05T16:00:00.000Z"
* },
* "title": "Meditation Tutorial",
* "rate": {
* "labeledPriceOptions": {
* "general": {
* "amount": "100",
* "currency": "USD",
* "downPayAmount": "0"
* }
* }
* },
* "tags": ["INDIVIDUAL"],
* "location": {
* "address": "105 West Street, Apt. 321, New York, New York",
* "customAddress": {
* "formatted": "105 West Street, Apt. 321, New York, New York"
* },
* "locationType": "CUSTOM"
* }
* },
* "paymentDetails": {
* "balance": {
* "finalPrice": {
* "amount": "100",
* "currency": "USD",
* "downPayAmount": "0"
* },
* "amountReceived": "0"
* }
* },
* "formInfo": {
* "paymentSelection": [{
* "rateLabel": "general",
* "numberOfParticipants": 1
* }],
* "additionalFields": [{
* "id": "00000000-0000-0000-0000-000000000008",
* "label": "Add Your Message",
* "valueType": "LONG_TEXT"
* },
* {
* "id": "1b1ee05f-aa4d-4a9e-9086-aef1d9d98a49",
* "label": "Agree to terms",
* "valueType": "CHECK_BOX"
* }],
* "contactDetails": {
* "contactId": "53013366-1ff2-419f-ac58-2c82a7a3abdb",
* "firstName": "John Walker",
* "email": "jw@test.com",
* "phone": "5557321",
* "timeZone": "America/New_York",
* "countryCode": "US",
* "address": {
* "formatted": "105 West Street, Apt. 321, New York,New York"
* }
* }
* }
* },
* "previousBooking": {
* "_id": "d939f806-bb01-4472-a366-c0e136592531",
* "bookedResources": [{
* "id": "dc19d7db-6996-494b-8d6d-943d64e1f32a",
* "name": "Tom Jones",
* "email": "tom@yoga.com"
* }],
* "status": "PENDING_APPROVAL",
* "createdDate": "2021-02-28T17:32:18.310Z",
* "bookingSource": {
* "platform": "WEB",
* "actor": "CUSTOMER",
* "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
* "appName": "Wix Bookings"
* },
* "bookedEntity": {
* "serviceId": "49c7fac5-227c-44d0-a4f3-c1a5c511edf1",
* "scheduleId": "4b21a5af-3b69-42ce-a3ba-9cf60d7b4422",
* "singleSession": {
* "sessionId":"2mmoW0vwKcSFyxtOfCdMkutTlCGjD2Zol12Xf8oBKd3JBbarU
* KabZB1NL1R17TsQtpgpCg6eScmLnAtlwEzi7IiungZ45aRewhjR",
* "start": "2021-03-05T15:00:00.000Z",
* "end": "2021-03-05T16:00:00.000Z"
* },
* "title": "Meditation Tutorial",
* "rate": {
* "labeledPriceOptions": {
* "general": {
* "amount": "100",
* "currency": "USD",
* "downPayAmount": "0"
* }
* }
* },
* "tags": ["INDIVIDUAL"],
* "location": {
* "address": "105 West Street, Apt. 321, New York, New York",
* "customAddress": {
* "formatted": "105 West Street, Apt. 321, New York, New York"
* },
* "locationType": "CUSTOM"
* }
* },
* "paymentDetails": {
* "balance": {
* "finalPrice": {
* "amount": "100",
* "currency": "USD",
* "downPayAmount": "0"
* },
* "amountReceived": "0"
* }
* },
* "formInfo": {
* "paymentSelection": [{
* "rateLabel": "general",
* "numberOfParticipants": 1
* }],
* "additionalFields": [{
* "id": "00000000-0000-0000-0000-000000000008",
* "label": "Add Your Message",
* "valueType": "LONG_TEXT"
* },
* {
* "id": "1b1ee05f-aa4d-4a9e-9086-aef1d9d98a49",
* "label": "Agree to terms",
* "valueType": "CHECK_BOX"
* }],
* "contactDetails": {
* "contactId": "53013366-1ff2-419f-ac58-2c82a7a3abdb",
* "firstName": "John Walker",
* "email": "jw@test.com",
* "phone": "5557321",
* "timeZone": "America/New_York",
* "countryCode": "US",
* "address": {
* "formatted": "105 West Street, Apt. 321, New York, New York"
* }
* }
* }
* }
* }
*/
An event that fires when a booking request is created.
The onBookingRequestCreated()
event handler runs when a new booking request is created for a service that requires manual booking confirmation.
The event
object includes a trigger
property that describes the action that triggered the event. The trigger
value for this event is "VISITOR_BOOKING_REQUEST_CREATED"
.
Note: Backend events don't work when previewing your site.
function onBookingRequestCreated(event: BookingEvent): void;
Information about a newly-created booking request.
// Place this code in the events.js file
// of your site's Backend section.
export function wixBookings_onBookingRequestCreated(event) {
const eventTrigger = event.trigger;
const bookingId = event.booking._id;
}
/* Full event object
* {
* "trigger": "VISITOR_BOOKING_REQUEST_CREATED",
* "booking": {
* "_id": "abcde6c0-312d-463f-ac15-12345db761a6",
* "bookedResources": [
* {
* "id": "dc19d7db-6996-494b-8d6d-943d64e1f32a",
* "name": "Tom Jones",
* "email": "tom@yoga.com"
* }
* ],
* "status": "PENDING_APPROVAL",
* "createdDate": "2021-02-23T13:25:08.447Z",
* "bookingSource": {
* "platform": "WEB",
* "actor": "CUSTOMER",
* "appDefId": "13d21c63-b5ec-5912-8397-c3a5ddb27a97",
* "appName": "Wix Bookings"
* },
* "bookedEntity": {
* "serviceId": "49c7fac5-227c-44d0-a4f3-c1a5c511edf1",
* "scheduleId": "4b21a5af-3b69-42ce-a3ba-9cf60d7b4422",
* "singleSession": {
* "sessionId":"mmoW0vwKcSFyxtOfCdMkx03iaGJPrwicZi6txH3v4xV1BjsDJnqagj
* 6Kgq9OkF0yrmnAQoowvm9jGbIhun5QPTT3hBcxoTtd5zB",
* "start": "2021-03-26T14:30:00Z",
* "end": "2021-03-26T15:30:00Z"
* },
* "title": "Meditation Tutorial",
* "rate": {
* "labeledPriceOptions": {
* "general": {
* "amount": "100",
* "currency": "USD",
* "downPayAmount": "0"
* }
* }
* },
* "tags": [
* "INDIVIDUAL"
* ],
* "location": {
* "address": "123 4th Street Fivetown",
* "customAddress": {
* "formatted": "123 4th Street Fivetown"
* },
* "locationType": "CUSTOM"
* }
* },
* "paymentDetails": {
* "balance": {
* "finalPrice": {
* "amount": "100",
* "currency": "USD",
* "downPayAmount": "0"
* },
* "amountReceived": "0"
* }
* },
* "formInfo": {
* "paymentSelection": [
* {
* "rateLabel": "general",
* "numberOfParticipants": 1
* }
* ],
* "additionalFields": [
* {
* "id": "00000000-0000-0000-0000-000000000008",
* "label": "Add Your Message",
* "valueType": "LONG_TEXT"
* },
* {
* "id": "1b1ee05f-aa4d-4a9e-9086-aef1d9d98a49",
* "label": "I need equipment",
* "valueType": "CHECK_BOX"
* }
* ],
* "contactDetails": {
* "contactId": "f8937331-2452-4c9f-a090-69b6b384021b",
* "firstName": "John Smith",
* "email": "johnsmith@gmail.com",
* "phone": "9998765",
* "timeZone": "America/New_York",
* "countryCode": "US",
* "address": {
* "formatted": "123 4th Street Fivetown"
* }
* }
* }
* },
* "previousBooking": {
* "bookedEntity": {
* "location": {}
* },
* "paymentDetails": {},
* "formInfo": {
* "contactDetails": {}
* }
* }
* }
*/