createEvent( )


Creates a Wix event.

The createEvent() function returns a Promise that resolves to the newly-created Wix event after it has successfully been created.

When creating an event, you must define if the event is an RSVP event or a ticketed event. This is stored in the registration.initialType property. After the initial save, you can further define event registration details. If you change the event's registration to be external or unnecessary, this is reflected in the registration.type property. The registration.initialType property after initial creation is read-only.

The new Wix event is created with a default registration form in the site's default language, using the site's default regional settings.

The default registration form includes input fields for first name, last name, and email. Keep in mind that the registration form for a ticketed event has different fields from the form for a non-ticketed event.

By default, the event is automatically configured to send daily summary reports of new registrations to the site's business email.

Only those with "Manage Events" permissions can create Wix events.

Note: This function requires elevated permissions to run.

This function is not universal and runs only on the backend.

Method Declaration
Copy
function createEvent(
  eventInfo: WixEventInfo,
  options: WixEventInfoOptions,
): Promise<WixEvent>;
Method Parameters
eventInfoWixEventInfoRequired

Info used to create the Wix event.


optionsWixEventInfoOptionsRequired

Options to use when creating the Wix event.

Returns
Return Type:Promise<WixEvent>

This example creates a ticketed event.

JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { wixEvents } from "wix-events-backend"; import { elevate } from "wix-auth"; /* Sample eventInfo value: { title: "Nature's Symphony: A Musical Journey Through Wildlife.", description: "Immerse yourself in the enchanting harmony of nature's symphony as it intertwines with the power of music!", registration: { initialType: "TICKETS", restrictedTo: "VISITOR", tickets: { formAssignedPerTicket: false, tax: { type: "INCLUDED" } } }, guestList: { public: true }, about: "Join us for Nature's Symphony: A Musical Journey Through Wildlife at the iconic Royal Albert Hall.", location: { name: "Royal Albert Hall", address: { formatted: "Kensington Gore, London SW7, UK", location: { latitude: 51.5009132, longitude: -0.1766086 }, city: "London", country: "GB", postalCode: "SW7 2BL", streetAddress: { name: "Kensington Gore", number: "SW7" } }, type: "VENUE" }, scheduling: { tbd: false, startDate: new Date("2024-09-14T19:00:00.000Z"), endDate: new Date ("2024-09-14T23:00:00.000Z"), timeZoneId: "Europe/Dublin", hideEndDate: false, showTimeZone: false } } Sample options value: { "language": "de" } */ export const myCreateEventFunction = webMethod( Permissions.Anyone, async (eventInfo, options) => { try { const elevatedCreateEvent = elevate(wixEvents.createEvent); const createdEvent = await elevatedCreateEvent(eventInfo, options); console.log("Success! CreatedEvent:", createdEvent); return createdEvent; } catch (error) { console.error(error); // Handle the error } }, ); /* Promise resolves to: { "about": "Join us for Nature's Symphony: A Musical Journey Through Wildlife at the iconic Royal Albert Hall.", "assignedContactsLabel": "custom.natures-symphony-a-musical-journey-through-wildlif", "calendarLinks": { "google": "http://calendar.google.com/calendar/render?action=TEMPLATE&text=Nature%27s+Symphony%3A+A+Musical+Journey+Through+Wildlife&dates=20231129T190000Z%2F20231129T230000Z&location=Kensington+Gore%2C+London+SW7%2C+UK&details=Thank+you+for+registering+to+our+event%21+Your+tickets+are+attached+to+this+email.+Don%27t+forget+to+bring+them.%0A%0AWe%27re+looking+forward+to+seeing+you+there.%0A%0AHere+are+the+details%3A%0A%0ANature%27s+Symphony%3A+A+Musical+Journey+Through+Wildlife%0A29+November+2023%2C+19%3A00%E2%80%9323%3A00%0ARoyal+Albert+Hall%2C+Kensington+Gore%2C+London+SW7%2C+UK", "ics": "https://www.wixevents.com/media/v2/calendar?token=JWS.eyJraWQiOiJpb21iOUJ0eSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiaW5zdGFuY2VJZFwiOlwiMWY2ZGM5MDYtODAzZC00NjUwLTgzZjUtNzJlYTFkODgxMDBiXCIsXCJldmVudElkXCI6e1widmFsdWVcIjpcImMyNDFlNmUyLWM5NTEtNDQwZC04YjYyLTUyYTZlYzM4MjE0MFwifSxcIm9jTGlua1wiOm51bGx9IiwiaWF0IjoxNjk5NDUwMDE2fQ.2wZA5WH2TOR4f8M1QICFOu8oD4gX70jBaCRMCFQRbqI" }, "categories": [], "createdBy": "8a8b9b73-4da8-47a5-8268-4396e68a0605", "_createdDate": "2023-07-13T12:52:00.911Z", "description": "Immerse yourself in the enchanting harmony of nature's symphony as it intertwines with the power of music!", "eventUrl": { "baseUrl": "https://mysite.com/events", "path": "/event-details-registration/natures-symphony-a-musical-journey-through-wildlife" }, "form": { "inputGroups": [ { "_id": "name", "inputs": [ { "additionalLabels": [], "label": "First name", "maxLength": 50, "name": "firstName", "options": [], "required": true, "type": "TEXT" }, { "additionalLabels": [], "label": "Last name", "maxLength": 50, "name": "lastName", "options": [], "required": true, "type": "TEXT" } ], "orderIndex": 0, "system": true, "type": "NAME" }, { "_id": "email", "inputs": [ { "additionalLabels": [], "label": "Email", "maxLength": 255, "name": "email", "options": [], "required": true, "type": "TEXT" } ], "orderIndex": 1, "system": true, "type": "INPUT" } ], "messages": { "checkout": { "checkoutLabel": "Continue", "title": "Add your details" }, "registrationClosed": { "exploreEventsLabel": "See other events", "message": "Registration is closed" }, "rsvp": { "noMessages": { "confirmationTitle": "Sorry You Can't Make It", "shareLabel": "Share", "title": "Add your details" }, "rsvpNo": "Not Going", "rsvpYes": "I'm Going", "submitRsvpLabel": "SUBMIT", "waitingMessages": { "addToCalendarLabel": "Add to Calendar", "confirmationMessage": "We'll update you if additional spots become available.", "confirmationTitle": "Thanks! You've been added to the waitlist.", "shareLabel": "Share", "title": "Looks like this event is full. Join the waitlist." }, "yesMessages": { "addToCalendarLabel": "Add to Calendar", "confirmationMessage": "An email with all the event info was sent to you.", "confirmationTitle": "Thank you!", "shareLabel": "Share", "title": "Add your details" } } } }, "guestList": { "public": true }, "_id": "c241e6e2-c951-440d-8b62-52a6ec382140", "language": "en", "location": { "address": { "formatted": "Kensington Gore, London SW7, UK", "location": { "latitude": 51.5009132, "longitude": -0.1766086 }, "city": "London", "country": "GB", "postalCode": "SW7 2BL", "streetAddress": { "name": "Kensington Gore", "number": "SW7", "apt": "" } }, "name": "Royal Albert Hall", "tbd": false, "type": "VENUE" }, "registration": { "initialType": "TICKETS", "restrictedTo": "VISITOR", "rsvp": { "responseOptions": "YES_ONLY", "waitlist": false }, "status": "OPEN_TICKETS", "tickets": { "currency": "EUR", "formAssignedPerTicket": false, "highestTicketPrice": { "currency": "EUR", "value": "20.00" }, "highestTicketPriceFormatted": "€20", "lowestTicketPrice": { "currency": "EUR", "value": "20.00" }, "lowestTicketPriceFormatted": "€20", "tax": {} }, "type": "TICKETS" }, "scheduling": { "endDate": "2023-11-29T23:00:00.137Z", "formatted": "29 November 2023, 19:00–23:00", "hideEndDate": false, "showTimeZone": false, "startDate": "2023-11-29T19:00:00.000Z", "startDateFormatted": "29 November 2023", "startTimeFormatted": "19:00", "tbd": false, "timeZoneId": "Europe/Dublin" }, "slug": "natures-symphony-a-musical-journey-through-wildlife", "status": "SCHEDULED", "summary": { "rsvp": { "noCount": 0, "totalRsvps": 0, "waitlistCount": 0, "yesCount": 0 }, "tickets": { "currencyLocked": false, "revenue": {}, "totalOrders": 0, "totalSales": {}, "totalTickets": 0 } }, "title": "Nature's Symphony: A Musical Journey Through Wildlife", "_updatedDate": "2023-11-08T13:22:57.000Z", "videoConferencing": { "session": { "guestLink": "https://www.wixevents.com/oc?join=JWS.eyJraWQiOiJpb21iOUJ0eSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiYWN0aW9uXCI6XCJqb2luXCIsXCJpbnN0YW5jZUlkXCI6XCIxZjZkYzkwNi04MDNkLTQ2NTAtODNmNS03MmVhMWQ4ODEwMGJcIixcImV2ZW50SWRcIjpcImMyNDFlNmUyLWM5NTEtNDQwZC04YjYyLTUyYTZlYzM4MjE0MFwifSIsImlhdCI6MTY5OTQ1MDAxNn0.AfJHpzU54hY8M1oVB0KGe47GUSzOzkWBVpKTTWEXk5Y", "hostLink": "https://www.wixevents.com/oc?start=JWS.eyJraWQiOiJpb21iOUJ0eSIsImFsZyI6IkhTMjU2In0.eyJkYXRhIjoie1wiYWN0aW9uXCI6XCJzdGFydFwiLFwiaW5zdGFuY2VJZFwiOlwiMWY2ZGM5MDYtODAzZC00NjUwLTgzZjUtNzJlYTFkODgxMDBiXCIsXCJldmVudElkXCI6XCJjMjQxZTZlMi1jOTUxLTQ0MGQtOGI2Mi01MmE2ZWMzODIxNDBcIn0iLCJpYXQiOjE2OTk0NTAwMTZ9.VmvnxZHBL6cCyE0ZYRdAa6cCud8aNchTTrLJX0b-Mhs" } } } */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?