updateReservation( )
Updates a reservation.
Description
Including the fields status
, source
, reservation.details.tableIds
, reservation.details.endDate
, ignoreReservationLocationConflicts
, and ignoreTableCombinationConflicts
in the request requires additional permissions. See this API's Introduction article for more information.
Each time the reservation is updated, revision increments by 1. The existing revision must be included when updating the reservation. This ensures you're working with the latest reservation information, and it prevents unintended overwrites.
This function requires elevated permissions to run. This function is not universal and runs only on the backend.
Syntax
function updateReservation(_id: string, reservation: UpdateReservation, options: UpdateReservationOptions): Promise<Reservation>
updateReservation Parameters
NAME
TYPE
DESCRIPTION
Reservation ID.
Reservation information to update.
Options for updating the reservation.
Returns
Reservation.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the reservation was created.
Reservation ID.
Date and time the reservation was changed.
The reason the reservation was declined.
Reservation details.
Information about the person making the reservation.
This field is required if the reservation's status
is anything other than WALK_IN
.
Information about the person the reservation is being made for.
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 results in an error.
Revision number, which increments by 1 each time the reservation is updated. To prevent conflicting changes, the current revision must be passed when updating the reservation.
Ignored when creating a reservation.
Reservation source.
This indicates how the reservation was made.
ONLINE
indicates that the customer made the reservation through a website or app.OFFLINE
indicates that the reservation was made by a restaurant employee, for example when a customer calls to make a reservation.WALK-IN
indicates that the customer did not make a reservation beforehand, and the reservation was entered into the system by a restaurant employee when the customer arrived at the restaurant.
Status of the reservation.
Supported values:
HELD
: The reservation is temporary and will expire in 10 minutes if its status isn’t changed. This phase temporarily reserves the required number of seats and tables for a given party size at a chosen time while a customer enters details and/or confirms their reservation request.REQUESTED
: A customer finished requesting this reservation, meaning they have added all necessary details and confirmed the request. Restaurant staff can now either approve or decline the reservation request.DECLINED
: The restaurant’s owner or staff declined the customer’s request to make the reservation.RESERVED
: The reservation is confirmed.SEATED
: The customer is currently occupying the table.CANCELED
: The reservation is canceled.NO_SHOW
: The customer didn't show up for their reservation.FINISHED
: The reservation completed successfully.
See the article for this API titled "The Reservation Lifecycle" in the menu on the left for more details on each of the statuses, and an explanation of the reservation lifecycle.
Team message.
A message for the restaurant staff containing any additional information regarding the reservation, such as special requirements for the guests.
Was this helpful?
1import { Permissions, webMethod } from 'wix-web-module';2import { reservations } from 'wix-table-reservations.v2';3import { elevate } from 'wix-auth';45/* Sample reservationId value: "1e3db995-5614-4748-8903-cbe7c74c5753"6 *7 * Sample reservationObject value:8 * {9 * "details": {10 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",11 * "startDate": new Date("2024-12-18T15:30:00Z"),12 * "endDate": new Date("2024-12-18T16:30:00Z"),13 * "partySize": 314 * },15 * "reservee":{16 * "phone":"+972555555555",17 * "firstName":"John"18 * },19 * "revision": "23"20 * }21 *22 * Sample options value:23 * {24 * "ignoreTableCombinationConflicts":["RESERVED", "TOO_BIG"],25 * "ignoreReservationLocationConflicts":["PARTY_PACING"]26 * }27 */2829export const myUpdateReservationFunction = webMethod(Permissions.Anyone, async (reservationId, reservation, options) => {30 const elevatedUpdateReservation = elevate(reservations.updateReservation);3132 try {33 const result = await elevatedUpdateReservation(reservationId, reservation, options);34 return result;35 } catch (error) {36 console.error(error);37 // Handle the error38 }39});4041/* Promise resolves to:42 * {43 * "status": "RESERVED",44 * "source": "ONLINE",45 * "details": {46 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",47 * "tableIds": [48 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"49 * ],50 * "startDate": "2024-12-18T15:30:00.000Z",51 * "endDate": "2024-12-18T16:30:00.000Z",52 * "partySize": 353 * },54 * "reservee": {55 * "firstName": "John",56 * "email": "pedro.doe@mail.com",57 * "phone": "+972555555555"58 * },59 * "revision": "24",60 * "migrationNotes": [],61 * "tablesWithReservationConflicts": [62 * {63 * "tableId": "1ed802ae-708f-4da6-9177-54c3df5d3dd5",64 * "reservationIds": [65 * "1c98f3af-f5e1-47b8-b935-1426345652d8"66 * ]67 * }68 * ],69 * "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",70 * "_createdDate": "2024-01-22T07:25:51.008Z",71 * "_updatedDate": "2024-02-07T08:46:57.544Z"72 * }73 */
This function call requires additional permissions and can only be called without elevation from a dashboard page.
1import { reservations } from 'wix-table-reservations-v2';2import { myUpdateReservationFunction } from 'backend/reservations.jsw';34/* Sample reservationId value: "1e3db995-5614-4748-8903-cbe7c74c5753"5 *6 * Sample reservationObject value:7 * {8 * "details": {9 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",10 * "startDate": new Date("2024-12-18T15:30:00Z"),11 * "endDate": new Date("2024-12-18T16:30:00Z"),12 * "partySize": 313 * },14 * "reservee":{15 * "phone":"+972555555555",16 * "firstName":"John"17 * },18 * "revision": "23"19 * }20 *21 * Sample options value:22 * {23 * "ignoreTableCombinationConflicts":["RESERVED", "TOO_BIG"],24 * "ignoreReservationLocationConflicts":["PARTY_PACING"]25 * }26 */2728myUpdateReservationFunction(reservationId, reservation, options)29 .then((updatedReservation) => {30 const startDate = updatedReservation.details.startDate;31 const partySize = updatedReservation.details.partySize;3233 console.log('Success! Updated reservations:', updatedReservation);34 return updatedReservation;35 })36 .catch((error) => {37 console.error(error);38 // Handle the error39 });4041/* Promise resolves to:42 * {43 * "status": "RESERVED",44 * "source": "ONLINE",45 * "details": {46 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",47 * "tableIds": [48 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"49 * ],50 * "startDate": "2024-12-18T15:30:00.000Z",51 * "endDate": "2024-12-18T16:30:00.000Z",52 * "partySize": 353 * },54 * "reservee": {55 * "firstName": "John",56 * "email": "pedro.doe@mail.com",57 * "phone": "+972555555555"58 * },59 * "revision": "24",60 * "migrationNotes": [],61 * "tablesWithReservationConflicts": [62 * {63 * "tableId": "1ed802ae-708f-4da6-9177-54c3df5d3dd5",64 * "reservationIds": [65 * "1c98f3af-f5e1-47b8-b935-1426345652d8"66 * ]67 * }68 * ],69 * "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",70 * "_createdDate": "2024-01-22T07:25:51.008Z",71 * "_updatedDate": "2024-02-07T08:46:57.544Z"72 * }73 */74