Deletes a session from a schedule.
The deleteSession()
function returns a Promise that resolves to a session ID when the session has been deleted.
Use the participantNotification
property to send an email to the participants when the session is deleted.
When deleting a session of type "EVENT"
where a booking exists, the booking's status is updated to "CANCELED"
.
To delete a set of recurring sessions, specify the session's recurringSessionId
in the sessionId
property in the parameters.
When deleting a recurrence, only future instances of the recurrence are deleted.
Note: Only users with Bookings Admin permissions can delete a session. You can override the permissions by setting the suppressAuth
option to true
.
Permissions
This endpoint requires the Manage Bookings permissions scope
function deleteSession(
sessionId: string,
options: DeleteSessionOptions,
): Promise<string>;
ID of the session to delete.
An object representing the available options for deleting a session.
import { Permissions, webMethod } from "wix-web-module";
import { sessions } from "wix-bookings-backend";
export const myDeleteSession = webMethod(
Permissions.Anyone,
async (sessionId) => {
const deleteSessionOptions = {
suppressAuth: true,
participantNotification: {
notifyParticipants: true,
},
};
try {
const result = await sessions.deleteSession(
sessionId,
deleteSessionOptions,
);
return result;
} catch (error) {
console.error("Delete session failed:", error);
}
},
);
/* Returns a Promise that resolves to a sessionId:
*
"4jOkD28c0FrsNUSgzQzuLRkA2t1rv1FLTwquKmJyctoZm00vdeKFMyH4n9cCLtmQe8wvOVwmsJCUCPWT3LA2geDOBViOg62YOeTGcgvAnGyw6uKEiNVqqdHt8QVz4i7qMZu5irOPVjACrV2o5F5SFkTukwrkodDkJBBtH3JaGj18FY3z9vvxDE0COr8D282JjVfq7YMAwQnTq4tYWYJkfPm7PDLI6zoWZREstI4jt6L0rFzLgnygdPd34xwV1XTWy29NYFXkahlmVNGcT28Psi8J35SjuXKVSpBiz8AbGJNwhVjBiZ8mSR1C8AqlOXknDFaYIQ2dd1Bsgub"
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.