Gets a session.
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
.
Permissions
This endpoint requires the Read Bookings Calendar or the Manage Bookings permission scope. With the Read Bookings Calendar permission scope, the session participants are not returned.
function getSession(sessionId: string, options: Options): Promise<Session>;
ID of the session to retrieve.
An object representing the available options for getting a session.
import { Permissions, webMethod } from "wix-web-module";
import { sessions } from "wix-bookings-backend";
export const myGetSession = webMethod(Permissions.Anyone, (sessionId) => {
return sessions
.getSession(sessionId, { suppressAuth: true })
.then((session) => {
return session;
})
.catch((error) => {
console.error("Failed to get the session:", error);
});
});
/* Returns a Promise that resolves to a session object:
*
* {
* "_id":"193...Jzp",
* "start": {
* "localDateTime": {
* "year": 2021,
* "monthOfYear": 1,
* "dayOfMonth": 1,
* "hourOfDay": 10,
* "minutesOfHour": 0
* },
* "timestamp": "2021-01-01T15:00:00.000Z"
* },
* "end": {
* "localDateTime": {
* "year": 2021,
* "monthOfYear": 1,
* "dayOfMonth": 1,
* "hourOfDay": 11,
* "minutesOfHour": 0
* },
* "timestamp": "2021-01-01T16:00:00.000Z"
* },
* "notes": "",
* "recurringSessionId": "53616b1f0c3c45a1b282675acd248179-44539bfb63ae496693109b6cb3a65a65",
* "scheduleId": "53616b1f-0c3c-45a1-b282-675acd248179",
* "scheduleOwnerId": "b71df756-309f-468e-aec2-f82b9a9a9441",
* "status": "CONFIRMED",
* "tags": [
* "GROUP"
* ],
* "type": "EVENT"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.