Add An Event To A CampaignΒΆ
Event creation is the action of a user submitting the event create page.
Thus, like all actions, it can be best addressed through the API by using generic action processing to create the action on the Host Page. The action processor provides validation, such as checking that the start date/time are in the future, and that the maximum attendees for the event is less than the maximum set by the campaign.
Crucially, the action processor creates the eventcreateaction
, and without that, some ActionKit features like "Act as host" in the Admin will not work.
Here's an example of an event creation request to the action processor, though the exact fields required depend upon the settings of the campaign and event host page:
POST /rest/v1/action/
{
"page": "house-parties-host", // page name -- required for all actions
"email": "[email protected]", // email of the action taker -- required for all actions
"event_address1": "123 Main Street",
"event_host_ground_rules": "1",
"event_host_requirements": "1",
"event_max_attendees": "100",
"event_postal": "94110",
"event_public_description": "This party is the best house party of all.",
"event_starts_at_ampm": "pm",
"event_starts_at_date": "04/01/2017",
"event_starts_at_time": "08:00",
"event_title": "My House Party",
"event_venue": "My House"
}
The event creation validation tries to find a location for the event, and so you need to provide not just the address line of the event, but as much of the rest of the address as is required to find the coordinates of the event location.
Also note that in order to create an event, three separate "starts_at" fields are required, following the format inputed on the public-facing event creation page. Those are "event_starts_at_ampm", "event_starts_at_date" and "event_starts_at_time".
Here's the response:
201 CREATED
{
"akid": ".2082925._GkEBg",
"created_at": "2017-03-27T21:59:44.985980",
"created_user": false,
"event": "/rest/v1/event/300/",
"fields": {},
"id": 2662367,
"ip_address": "50.0.192.156",
"is_forwarded": false,
"link": null,
"mailing": null,
"opq_id": "",
"page": "/rest/v1/eventcreatepage/20279/",
"redirect_url": "/cms/thanks/house-parties_create?action_id=2662367&akid=.2082925._GkEBg&ar=1&email=host%40example.com&rd=1&taf=1",
"referring_mailing": null,
"referring_user": null,
"resource_uri": "/rest/v1/eventcreateaction/2662367/",
"source": "restful_api",
"status": "complete",
"subscribed_user": false,
"taf_emails_sent": null,
"type": "EventCreate",
"updated_at": "2017-03-27T21:59:45.125679",
"user": "/rest/v1/user/2082925/"
}
Note
If you created the event creation page ("Host Page") through the API, be sure that you've also configured the confirmation email settings in the pagefollowup object. Host pages created through the API do not get a confirmation email by default (ones created through the Admin do) and the confirmation email with information on how to confirm their event would not be sent.
The linked event
resource is the event that was just created by this POST request. Let's take a look:
GET /rest/v1/event/300/
{
"address1": "123 Main Street",
"address2": "",
"attendee_count": 0,
"campaign": "/rest/v1/campaign/159/",
"city": "San Francisco",
"confirmed_at": null,
"approved_at": null,
"country": "United States",
"created_at": "2017-03-27T21:59:45",
"creator": "/rest/v1/user/2082925/",
"directions": "",
"ends_at": null,
"ends_at_utc": null,
"fields": [],
"host_is_confirmed": false,
"id": 300,
"is_approved": false,
"is_private": false,
"latitude": 37.7868,
"longitude": -122.396,
"max_attendees": 100,
"note_to_attendees": "",
"notes": "",
"phone": "",
"plus4": "",
"postal": "94110",
"public_description": "the best",
"region": "",
"resource_uri": "/rest/v1/event/300/",
"signups": [
"/rest/v1/eventsignup/467/"
],
"starts_at": "2017-04-01T20:00:00",
"starts_at_utc": "2017-04-02T03:00:00",
"state": "CA",
"status": "active",
"title": "My House Party",
"updated_at": "2017-03-27T21:59:45",
"venue": "My House",
"zip": "94110"
}
Looks good! Next, let's look at how you can update the settings or status of an event.