> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: createBooking(booking: Booking, options: CreateBookingOptions) # Method package: wixBookingsV2 # Method menu location: wixBookingsV2 --> bookings --> createBooking # Method Link: https://dev.wix.com/docs/velo/apis/wix-bookings-v2/bookings/create-booking.md # Method Description: Creates a booking. To create a booking for an appointment or a session of a class, pass a booking with the relevant `slot`. To create a booking for the entire course, pass a booking with the relevant `schedule`. You can use Query Availability to check the availability beforehand. If you create a booking for an existing session, we recommend that you only pass `slot.sessionId`. Then, any specified slot details are calculated. If you create a booking for a new session, we recommend to call Query Availability first. Then, pass the retrieved `availability.slot` object as the BookedEntity.Slot of the booking in the request. Bookings are created with a status of `CREATED`. `CREATED` bookings don't appear on the business calendar and don't affect a related schedule's availability. To create a booking with a given status, pass a booking with the wanted status. This is only permitted for site Owners. You can pass a `participantNotification.message` to notify the customer of the booking with a message. It's also necessary to pass `participantNotification.notifyParticipants`as `true` to send the message. You can pass `sendSmsReminder` as `true`, if you want an SMS reminder to be sent to the phone number specified in the ContactDetails, 24 hours before the session starts. When creating a booking you must pass either `participantsChoices` or `totalParticipants`. If you pass `participantsChoices`, all the provided choices must exist for the service, otherwise the call returns an `INVALID_SERVICE_CHOICES` error. When creating a booking, you can pass `selectedPaymentOption`. This specifies which payment method the customer plans to use. But it's possible for them to later use another supported payment method. You can skip the checkout and payment flow if you call Confirm Or Decline Booking otherwise, after you create the booking, you can use the Wix eCommerce APIs (coming soon) for the checkout and payment flow or use a different service for checkout. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a booking for a class session. ```javascript import { bookings } from 'wix-bookings.v2'; /* Sample booking value: * { * totalParticipants: 1, * contactDetails: { * firstName: 'Aditi', * lastName: 'Naidu', * email: 'aditi.naidu765@example.com' * }, * bookedEntity: { * slot: { * sessionId: '193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7ExgIRM1UZAV13fLX2gNLq4sCQwIdZIpxI6tDJxatWo81RhW6mQLgcnnO6ONJkvJH5ZYZEwHOIPMbmhqD5t41JnX3cUcIi0QOtrQjuZmfUCJFaA6fTnI97I4b9OD9AbOfkGsYnZW5UL0Yoc0amYhtACJPhRRe3qJSC5Qxp0aHl0j0ExBDV5ZTajTM1L6QktIUelYWU4Fq45KPYFvqc1UXeLTURzcOG4wsATMD47b5XfFqC9Myj02MJFRmz5nBS47v7586qsxgmQTYw6MVp' * } * } * } */ bookings.createBooking(booking, options) .then((newSessionBooking) => { const id = newSessionBooking._id; const status = newSessionBooking.status; console.log('Success! Created a new booking:', newSessionBooking); return newSessionBooking; .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * { * "bookedEntity": { * "slot": { * "sessionId": "193ZPR9ppP9emJUCLevcLf6orynNEIDt5nc0520xjGQILnPPaF5s62yK3BWz7ExgIRM1UZAV13fLX2gNLq4sCQwIdZIpxI6tDJxatWo81RhW6mQLgcnnO6ONJkvJH5ZYZEwHOIPMbmhqD5t41JnX3cUcIi0QOtrQjuZmfUCJFaA6fTnI97I4b9OD9AbOfkGsYnZW5UL0Yoc0amYhtACJPhRRe3qJSC5Qxp0aHl0j0ExBDV5ZTajTM1L6QktIUelYWU4Fq45KPYFvqc1UXeLTURzcOG4wsATMD47b5XfFqC9Myj02MJFRmz5nBS47v7586qsxgmQTYw6MVp", * "serviceId": "036d51c9-d9fd-4459-be7a-a05e882f3e93", * "scheduleId": "c0cf791e-fbc0-44e7-8db3-4c2eb7aa9253", * "eventId": "11bhnkliQkhMrXr0AM2tX25A7AobX7raOYBkACbOPXIaluO3YHF3CH2Lge0zoU8BZOWKrWh8POSBCjnlWYlbHRIaiVY6X73ys6EnBfO5NOmQi9FxjIApGtM", * "startDate": "2024-04-11T13:30:00.000+01:00", * "endDate": "2024-04-11T14:30:00.000+01:00", * "timezone": "Europe/Madrid", * "resource": { * "name": "Sandra", * "email": "info@mysite.com", * "scheduleId": "f0212cd6-8437-4f2f-bdb0-019bc407bd84", * "explicitlyRequested": true, * "_id": "76570209-101f-409b-af97-b445bdb63125" * }, * "location": { * "locationType": "OWNER_BUSINESS" * } * }, * "title": "Crossfit Beginners", * "tags": [ * "GROUP" * ] * }, * "contactDetails": { * "firstName": "Aditi", * "lastName": "Naidu", * "email": "aditi.naidu765@example.com" * }, * "additionalFields": [], * "numberOfParticipants": 1, * "status": "CREATED", * "paymentStatus": "UNDEFINED", * "selectedPaymentOption": "UNDEFINED", * "revision": "1", * "createdBy": { * "identityType": "UNKNOWN", * "memberId": "c0e1854d-efd1-4c10-a079-bcb922dea639" * }, * "startDate": "2024-04-11T12:30:00.000Z", * "endDate": "2024-04-11T13:30:00.000Z", * "flowControlSettings": { * "ignoreBookingWindow": false, * "skipAvailabilityValidation": false, * "skipBusinessConfirmation": false, * "skipSelectedPaymentOptionValidation": false, * "withRefund": false * }, * "totalParticipants": 1, * "v2Availability": false, * "_id": "df846146-51e7-4bcb-b09c-04c4b0f787f4", * "_createdDate": "2024-02-18T14:35:31.987Z", * "_updatedDate": "2024-02-18T14:35:31.987Z" * } */ ``` ---