Search.../

getReservation( )

Developer Preview

Retrieves a reservation.

Description

Calling this method with fieldsets set to FULL requires additional permissions. See this API's Introduction article for more information.

Syntax

function getReservation(reservationId: string, options: GetReservationOptions): Promise<Reservation>

getReservation Parameters

NAME
TYPE
DESCRIPTION
reservationId
string

Reservation ID.

options
Optional
GetReservationOptions

Returns

Reservation.

Return Type:

Promise<
Reservation
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the reservation was created.

_id
string

Reservation ID.

_updatedDate
Date

Date and time the reservation was changed.

declineReason
string

The reason the reservation was declined.

details
Details

Reservation details.

reservedBy
ReservedBy

Information about the person making the reservation.

This field is required if the reservation's status is anything other than WALK_IN.

reservee
Reservee

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
string

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.

source
string

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
string

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.

teamMessage
string

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?

Get a reservation (page code)

Copy Code
1import { reservations } from 'wix-table-reservations.v2';
2
3// Sample reservationId value: "1e3db995-5614-4748-8903-cbe7c74c5753"
4
5reservations.getReservation(reservationId)
6 .then((retrievedReservation) => {
7 const startDate = retrievedReservation.details.startDate;
8 const partySize = retrievedReservation.details.partySize;
9
10 console.log('Success! Retrieved reservation:', retrievedReservation);
11 return retrievedReservation;
12 })
13 .catch((error) => {
14 console.error(error);
15 // Handle the error
16 });
17
18/* Promise resolves to:
19 * {
20 * "status": "RESERVED",
21 * "source": "UNKNOWN",
22 * "details": {
23 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",
24 * "tableIds": [],
25 * "startDate": "2024-12-04T12:30:00.000Z",
26 * "endDate": "2024-12-04T14:00:00.000Z",
27 * "partySize": 2
28 * },
29 * "revision": "1",
30 * "migrationNotes": [],
31 * "tablesWithReservationConflicts": [],
32 * "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",
33 * "_createdDate": "2024-01-22T07:25:51.008Z"
34 * }
35 */
36
Get a reservation with options (backend)

This example demonstrates how to request the FULL fieldset in options using elevation to get the necessary permissions.

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { reservations } from 'wix-table-reservations.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample reservationId value: "1e3db995-5614-4748-8903-cbe7c74c5753"
6 *
7 * Sample options value:
8 * {
9 * "fieldsets": ["FULL"]
10 * }
11 */
12
13export const myGetReservationFunction = webMethod(Permissions.Anyone, async (reservationId, options) => {
14 const elevatedGetReservation = elevate(reservations.getReservation);
15
16 try {
17 const result = await elevatedGetReservation(reservationId, options);
18 return result;
19 } catch (error) {
20 console.error(error);
21 // Handle the error
22 }
23});
24
25/* Promise resolves to:
26 * {
27 * "status": "RESERVED",
28 * "source": "ONLINE",
29 * "details": {
30 * "reservationLocationId": "fab8cc1f-31cf-462f-b5bb-392594624bf2",
31 * "tableIds": [
32 * "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
33 * ],
34 * "startDate": "2024-12-04T12:30:00.000Z",
35 * "endDate": "2024-12-04T14:00:00.000Z",
36 * "partySize": 2
37 * },
38 * "revision": "1",
39 * "migrationNotes": [],
40 * "tablesWithReservationConflicts": [],
41 * "_id": "1e3db995-5614-4748-8903-cbe7c74c5753",
42 * "_createdDate": "2024-01-22T07:25:51.008Z",
43 * "_updatedDate": "2024-01-22T07:25:51.008Z"
44 * }
45 */