Search.../

getSession( )

Gets a session.

Description

The getSession() function returns a Promise that resolves to a session with the specified session ID.

Note: Only users with Bookings Admin permissions can view participant information in a retrieved session. You can override the permissions by setting the suppressAuth options to true.

Syntax

function getSession(sessionId: string, [options: Options]): Promise<Session>

getSession Parameters

NAME
TYPE
DESCRIPTION
sessionId
string

ID of the session to retrieve.

options
Optional
Options

An object representing the available options for getting a session.

Returns

Fulfilled - Session.

Return Type:

Promise<Session>
NAME
TYPE
DESCRIPTION
_id
string

Session ID.

scheduleId
string

ID of the schedule that the session belongs to.

scheduleOwnerId
string

ID of the resource or service that the session's schedule belongs to.

tags
Array<string>

Tags for the session. The value is inherited from the schedule and can be overridden unless the session is a recurring session.

notes
string

Additional information about the session. Notes are not supported for recurring sessions.

status
string

Session status.

One of:

  • "CONFIRMED" Default value.
  • "CANCELLED" The session was deleted.
recurringSessionId
string

ID of the recurring session if this session is an instance of a recurrence. Use this ID to update the recurrence and all of the instances.

type
string

Session type.

One of:

  • "EVENT" Reserved period of time on the schedule. For example, an appointment, class, course, or blocked time. Events are visible in the Dashboard in the Bookings app's Booking Calendar page.
  • "WORKING_HOURS" Placeholder for available time on a resource’s schedule.
recurrence
string

String representing a recurrence rule (RRULE) for a recurring session, as defined in iCalendar RFC 5545. If the session is an instance of a recurrence pattern, the instanceOfRecurrence property will contain the recurrence rule and this property will be empty. The RRULE defines a rule for repeating a session. Supported parameters are:

KeywordDescriptionSupported values
FREQThe frequency at which the session is recurs. Required.WEEKLY
INTERVALHow often, in terms of FREQ, the session recurs. Default is 1. Optional.
UNTILThe UTC end date and time of the recurrence. Optional.
BYDAYDay of the week when the event should recur. Required.One of: MO, TU, WE, TH, FR, SA, SU

For example, a session that repeats every second week on a Monday until January 7, 2022 at 8 AM: "FREQ=WEEKLY;INTERVAL=2;BYDAY=MO;UNTIL=20220107T080000Z"

instanceOfRecurrence
string

String representing a recurrence rule (RRULE) if the session is an instance of a recurrence pattern. Empty when the session is not an instance of a recurrence rule, or if the session defines a recurrence pattern, and recurrence is not empty.

start
CalendarDateTime

An object specifying the start date and time of the session. If the session is a recurring session, start must contain a localDateTime.

end
CalendarDateTime

An object specifying the end date and time of the session. If the session is a recurring session, end must contain a localDateTime.

Was this helpful?

Gets a session.

Copy Code
1import { sessions } from "wix-bookings-backend";
2
3export function myGetSession(sessionId) {
4 return sessions.getSession(sessionId, { suppressAuth: true })
5 .then((session) => {
6 return session
7 })
8 .catch((error) => {
9 console.error("Failed to get the session:", error);
10 });
11}
12
13/* Returns a Promise that resolves to a session object:
14 *
15 * {
16 * "_id":"193...Jzp",
17 * "start": {
18 * "localDateTime": {
19 * "year": 2021,
20 * "monthOfYear": 1,
21 * "dayOfMonth": 1,
22 * "hourOfDay": 10,
23 * "minutesOfHour": 0
24 * },
25 * "timestamp": "2021-01-01T15:00:00.000Z"
26 * },
27 * "end": {
28 * "localDateTime": {
29 * "year": 2021,
30 * "monthOfYear": 1,
31 * "dayOfMonth": 1,
32 * "hourOfDay": 11,
33 * "minutesOfHour": 0
34 * },
35 * "timestamp": "2021-01-01T16:00:00.000Z"
36 * },
37 * "notes": "",
38 * "recurringSessionId": "53616b1f0c3c45a1b282675acd248179-44539bfb63ae496693109b6cb3a65a65",
39 * "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179",
40 * "scheduleOwnerId": "b71df756-309f-468e-aec2-f82b9a9a9441",
41 * "status": "CONFIRMED",
42 * "tags": [
43 * "GROUP"
44 * ],
45 * "type": "EVENT"
46 * }
47 */
48