Search.../

updateSession( )

Updates a session.

Description

The updateSession() function returns a Promise that resolves when the session has been updated.

The property values specified in the sessionInfo object replace the existing values. If a property is not specified in the request it will remain unchanged. Array properties, if specified, overwrite the existing array and all of its elements.

When you update a recurring session, only the future instances of the recurrence will be updated. Changing an individual instance's start or end time will change the way updates to start and end on the recurring session affect the session instance:

Change made to the instanceEffect of changes made to the recurrence
Instance start time changed.Changes to the recurring session's start or end time will not update the instance.
Instance end time changed, changing the session's durationChanges made to the recurring session's start time will be updated on the instance while keeping the new duration, but changes to the recurring session's end time not be updated on the instance.
Updating a changed start time for an instance back to the recurring session's value.Future changes to the recurring session start and end times will update the instance's starts and end time.

Changes to properties on the recurring session, other than start and end, are always updated on the recurrence instance.

Use the options.participantNotification object to notify participants if the session has been booked.

Notes:

  • Where there is no explicit timezone information, the timezone used is the business’s timezone.
  • Only users with Bookings Admin permissions can update a session. You can override the permissions by setting the suppressAuth option to true.

Syntax

function updateSession(sessionId: string, sessionInfo: UpdateSessionInfo, [options: Options]): Promise<Session>

updateSession Parameters

NAME
TYPE
DESCRIPTION
sessionId
string

ID of the session to update.

sessionInfo
UpdateSessionInfo

Information to use when updating a session.

options
Optional
Options

An object representing the available options for updating 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?

Update a session.

Copy Code
1import { sessions } from "wix-bookings-backend";
2
3export function myUpdateSession(sessionId) {
4
5 const sessionInfo = {
6 notes: "An updated note"
7 };
8
9 const updateSessionOptions = {
10 suppressAuth: true
11 };
12
13 return sessions.updateSession(sessionId, sessionInfo, updateSessionOptions)
14 .then((updatedSession) => {
15 return updatedSession;
16 })
17 .catch((error) => {
18 console.error("Update session failed:", error);
19 });
20}
21 /* Returns a Promise that resolves to a session object:
22 * {
23 * "_id": "2mmoW0vwKcSFyxtOfCdKNWpXfTMwOG1eDJiG34R4gORBP7dZp75XWXUVtvdEzhzsxfmG3a2lDyh9eqcQi2o6zxLAigrZPso7AQoP",
24 * "scheduleId": "4b21a5af-3b69-42ce-a3ba-9cf60d7b4422",
25 * "scheduleOwnerId": "49c7fac5-227c-44d0-a4f3-c1a5c511edf1",
26 * "start": {
27 * "timestamp": "2020-12-30T15:00:00.000Z"
28 * },
29 * "end": {
30 * "timestamp": "2020-12-30T16:00:00.000Z"
31 * },
32 * "status": "CONFIRMED",
33 * "tags": [
34 * "INDIVIDUAL"
35 * ],
36 * "type": "EVENT",
37 * "notes": "An updated note"
38 * }
39 */