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 instance | Effect 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 duration | Changes 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 totrue
.
Syntax
function updateSession(sessionId: string, sessionInfo: UpdateSessionInfo, [options: Options]): Promise<Session>
updateSession Parameters
NAME
TYPE
DESCRIPTION
ID of the session to update.
Information to use when updating a session.
An object representing the available options for updating a session.
Returns
Fulfilled - Session.
Return Type:
NAME
TYPE
DESCRIPTION
Session ID.
ID of the schedule that the session belongs to.
ID of the resource or service that the session's schedule belongs to.
Tags for the session. The value is inherited from the schedule and can be overridden unless the session is a recurring session.
Additional information about the session. Notes are not supported for recurring sessions.
Session status.
One of:
"CONFIRMED"
Default value."CANCELLED"
The session was deleted.
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.
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.
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:
Keyword | Description | Supported values |
---|---|---|
FREQ | The frequency at which the session is recurs. Required. | WEEKLY |
INTERVAL | How often, in terms of FREQ , the session recurs. Default is 1. Optional. | |
UNTIL | The UTC end date and time of the recurrence. Optional. | |
BYDAY | Day 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"
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.
An object specifying the start date and time of the session. If the session is a recurring session, start
must contain a localDateTime
.
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.
12import { Permissions, webMethod } from "wix-web-module";3import { sessions } from "wix-bookings-backend";45export const myUpdateSession = webMethod(Permissions.Anyone, async (sessionId) => {6 const sessionInfo = {7 notes: "An updated note"8 };910 const updateSessionOptions = {11 suppressAuth: true12 };1314 try {15 const updatedSession = await sessions.updateSession(sessionId, sessionInfo, updateSessionOptions);16 return updatedSession;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 */40