Cancels a Wix event and closes its registration.
The cancelEvent()
function returns a Promise that resolves to the newly-canceled Wix event after the specified Wix event is successfully canceled.
This function does the following:
"CANCELED"
. You can also see this status change in the Events collection.CLOSED
.Canceled Wix events cannot be "un-canceled." You can only delete and copy them.
Tip: You can copy a canceled Wix event if you want to reinstate it. Copying an event resets the event's status and registration status.
When using the API, you do not need to cancel a Wix event before deleting it. When using the Wix Events app in the Editor, you must cancel the Wix event first.
Only those with "Manage Events" permissions can cancel Wix events.
Note: This function requires elevated permissions to run.
This function is not universal and runs only on the backend.
function cancelEvent(eventId: string): Promise<WixEvent>;
Event ID.
import { Permissions, webMethod } from "wix-web-module";
import { wixEvents } from "wix-events-backend";
import { elevate } from "wix-auth";
/* Sample eventId value: '9d720f99-1b5a-4141-9877-d32985391e18'; */
export const myCancelEventFunction = webMethod(
Permissions.Anyone,
async (eventId) => {
try {
const elevatedCancelEvent = elevate(wixEvents.cancelEvent);
const canceledEvent = await elevatedCancelEvent(eventId);
console.log("Success! Canceled event:", canceledEvent);
return canceledEvent;
} catch (error) {
console.error(error);
// Handle the error
}
},
);
/* Promise resolves to:
{
"about": "Learn to handcraft leather goods using saddle stitching techniques, from choosing the leather to sealing the edges.",
"assignedContactsLabel": "custom.leather-crafting-101-a-course-by-christina-roth-1-",
"calendarLinks": {},
"categories": [],
"createdBy": "8a8b9b73-4da8-47a5-8268-4396e68a0605",
"_createdDate": "2023-02-03T10:56:59.721Z",
"description": "",
"eventUrl": {},
"form": {
"messages": {
"checkout": {},
"registrationClosed": {},
"rsvp": {
"noMessages": {},
"waitingMessages": {},
"yesMessages": {}
}
}
},
"guestList": {
"public": true
},
"_id": "9d720f99-1b5a-4141-9877-d32985391e18",
"language": "en",
"location": {
"address": {
"formatted": "Tacoma, WA, USA",
"location": {
"latitude": 47.2528768,
"longitude": -122.4442906
},
"city": "Tacoma",
"subdivision": "WA",
"country": "US",
"streetAddress": {
"name": "",
"number": "",
"apt": ""
}
},
"name": "Tacoma",
"tbd": false,
"type": "VENUE"
},
"registration": {
"rsvp": {},
"tickets": {
"highestTicketPrice": {},
"lowestTicketPrice": {},
"tax": {}
}
},
"scheduling": {
"formatted": "Time is TBD",
"hideEndDate": false,
"showTimeZone": false,
"startDateFormatted": "",
"startTimeFormatted": "",
"tbd": true,
"tbdMessage": "Time is TBD"
},
"slug": "leather-crafting-101-a-course-by-christina-roth-1",
"status": "CANCELED",
"summary": {
"rsvp": {},
"tickets": {
"revenue": {},
"totalSales": {}
}
},
"title": "Leather Crafting 101, A course by Christina Roth (1)",
"_updatedDate": "2023-11-08T11:56:16.000Z",
"videoConferencing": {
"session": {}
}
}
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.