> 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: createReservation(reservation: Reservation, options: CreateReservationOptions) # Method package: wixTableReservationsV2 # Method menu location: wixTableReservationsV2 --> reservations --> createReservation # Method Link: https://dev.wix.com/docs/velo/apis/wix-table-reservations-v2/reservations/create-reservation.md # Method Description: Creates a new reservation. `createReservation()` accepts and requires different fields depending on the `status` provided and your permissions. **Status and source** If a `status` is not provided, it will be set to: * `RESERVED` if manual approval is not required for confirmation * `REQUESTED` if manual approval is required for confirmation. A reservation created with any `source` other than `WALK_IN` requires the `reservation.reservee.phone` and `reservation.reservee.firstName` fields. Attempting to create a reservation without these fields will result in an error. **Permissions** Including the fields `status`, `source`, `reservation.details.tableIds`, `reservation.details.endDate`, `ignoreReservationLocationConflicts`, or `ignoreTableCombinationConflicts` in the request requires additional permissions. See this API's Introduction article for more information. If `source` is not provided, its value is set depending on the permissions of the user making the call. See this API's Introduction article for more information. > **Note:** `createReservation()` requires all details of the reservation upfront. The process of creating a reservation can be broken up using `createHeldReservation`. `createHeldReservation` creates a temporary reservation that expires automatically unless it is completed with the addition of more details using `reserveReservation()`. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create a basic reservation (page code) ```javascript import { reservations } from 'wix-table-reservations.v2'; /* Sample reservation value: * { * "details": { * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2", * "startDate": new Date("2024-12-18T15:30:00Z"), * "partySize": 2 * }, * "reservee":{ * "phone":"+972555555555", * "firstName": "John" * }, * } */ reservations.createReservation(reservation) .then((createdReservation) => { const id = createdReservation._id; const status = createdReservation.status; console.log('Success! Created a reservation:', createdReservation); return createdReservation; }) .catch((error) => { console.error(error); // Handle the error }); /* Promise resolves to: * { * "reservation": { * "status": "RESERVED", * "source": "UNKNOWN", * "details": { * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2", * "tableIds": [], * "startDate": "2024-12-16T15:30:00.000Z", * "endDate": "2024-12-16T17:00:00.000Z", * "partySize": 2 * }, * "revision": "1", * "migrationNotes": [], * "tablesWithReservationConflicts": [], * "_id": "d9f15462-a46a-45df-8b0f-2ef557f94ca9", * "_createdDate": "2024-01-17T07:58:17.339Z" * } * } */ ``` ## Create a reservation with options (backend) ```javascript import { reservations } from 'wix-table-reservations.v2'; import { elevate } from 'wix-auth'; import { Permissions, webMethod } from 'wix-web-module'; /* Sample reservation value: * { * "details": { * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2", * "startDate": new Date("2024-12-15T10:30:00Z"), * "partySize": 2 * }, * "reservee":{ * "phone":"+972555555555", * "firstName": "John" * }, * "teamMessage": "Make sure the table has bottled water" * } * * Sample options value: * { * "ignoreTableCombinationConflicts":["RESERVED", "TOO_BIG"], * "ignoreReservationLocationConflicts":["PARTY_PACING"] * } */ export const myCreateReservationFunction = webMethod(Permissions.Anyone, async (reservation, options) => { const elevatedCreateReservation = elevate(reservations.createReservation); try { const result = await elevatedCreateReservation(reservation, options); return result; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "status": "RESERVED", * "source": "UNKNOWN", * "details": { * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2", * "tableIds": [ * "1ed802ae-708f-4da6-9177-54c3df5d3dd5" * ], * "startDate": "2024-12-15T10:30:00.000Z", * "endDate": "2024-12-15T12:00:00.000Z", * "partySize": 2 * }, * "reservee": { * "firstName": "John", * "phone": "+972555555555", * "contactId": "e8396cd4-1398-4886-a0ca-82647ff0ccaf" * }, * "teamMessage": "make sure the table has bottled water", * "revision": "1", * "migrationNotes": [], * "tablesWithReservationConflicts": [], * "_id": "586db492-986e-4849-9ef9-100f0ffa4321", * "_createdDate": "2024-01-17T09:46:43.844Z", * "_updatedDate": "2024-01-17T09:46:43.844Z" * } */ ``` ---