Creates an RSVP and adds the new guests to an event's guest list.
The createRsvp()
function returns a Promise that resolves to an RsvpResponse
when the guests in the specified form values have been added to the event's guest list.
The list of FormValue
objects you pass to
createRsvp()
must include a form value for the rsvpStatus
. Which statuses
you can return depends on the rsvpStatusOptions
returned from the
formData
property as follows:
"YES_AND_NO"
: Send an rsvpStatus
of "YES"
or "NO"
."YES_ONLY"
: Send an rsvpStatus
of "YES"
."OPEN_RSVP_WAITLIST"
: Send an rsvpStatus
of "WAITING"
to add a guest to the waitlist.When creating an RSVP with rsvpStatus
of "WAITING"
or "NO"
,
the list of FormValue
objects should
only contain items for "firstName"
, "lastName"
, "email"
, and "rsvpStatus"
.
No other fields should be passed.
When creating an RSVP that adds additional guests, format the guest names for submission in an array where each element is the full name of a guest.
When creating an RSVP that contains an address, the way you format the address information for submission depends on what type of input elements you use to gather that information as follows:
Note: To work with the Wix Events API, you need to publish your site.
function createRsvp(
eventId: string,
formValues: Array<FormValue>,
): Promise<RsvpResponse>;
ID of the event to create an RSVP for.
List of field names and values for an RSVP form.
import wixEventsFrontend from 'wix-events-frontend';
// ...
const eventId = // Get the event ID
// ...
let formValues = // get form values
wixEventsFrontend.rsvp.createRsvp(eventId, formValues)
.then((response) => {
let totalGuests = response.totalGuests; // 2
let firstGuestName = response.guests[0].fullName; // Jane Doe
})
.catch((error) => {
let message = error.message; // "Guest limit exceeded: only 1 person can RSVP"
let errorType = error.errorType; // "GUEST_LIMIT_REACHED"
});
/*
* Success response:
* {
* "anonymized": false,
* "contactId": "f1b9e9b3-5acb-4f15-ada8-e31a34a376ec",
* "createdDate": "2019-09-02T12:29:34.944Z",
* "email": "john.doe@somedomain.com",
* "eventId": "caad2acf-5c64-4eab-97f8-6710feac9151",
* "firstName": "John",
* "lastName": "Doe",
* "guests": [
* {
* "index": 0,
* "fullName": "John Doe",
* "id": 1
* }
* ],
* "id": "c71fc4d1-661e-473c-8b8c-74d97cf91b22",
* "memberId": "",
* "updatedDate": "2019-09-02T12:29:34.944Z",
* "rsvpForm": {
* "inputValues": [
* {
* "inputName": "firstName",
* "value": "John",
* "values": [],
* },
*
* ...
*
* {
* inputName: "custom",
* value: "",
* values: ["Gluten free", "Vegetarian"],
* }
* ]
* },
* "status": "YES"
* "totalGuests": 1
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.