Add Host Page To A Campaign

Host Pages are comprised of 3 different objects: eventcreatepage, eventcreateform, and pagefollowup.

So we'll create and connect each of these in three different steps of adding the eventcreatepage, adding the eventcreateform, and adding the pagefollowup. Lastly, we'll examine the eventcreatepage once more to view the final created page.

1. Add The EventCreatePage

We first send a POST request to the eventcreatepage endpoint. Refer to the eventcreatepage schema for more details about the fields, filtering and ordering options available.

The required fields are name (the short name of the page), and campaign, which expects the URI of the associated campaign. However you probably also want to set title so that there is a page title associated with the host page.

POST /rest/v1/eventcreatepage/

{
        "campaign": "/rest/v1/campaign/175/",
        "name": "house-parties_host",
        "title": "House Parties - Host"
}

That results in an eventcreatepage with these default settings:

{
        "actions": "/rest/v1/eventcreateaction/?page=34848",
        "allow_multiple_responses": true,
        "campaign": "/rest/v1/campaign/175/",
        "campaign_title": "",
        "created_at": "2017-03-25T05:34:57",
        "eventcreateform": null,
        "fields": {},
        "followup": null,
        "goal": null,
        "goal_type": "actions",
        "hidden": false,
        "hosted_with": "/rest/v1/hostingplatform/1/",
        "id": 34848,
        "language": null,
        "list": "/rest/v1/list/1/",
        "multilingual_campaign": null,
        "name": "house-parties_host",
        "never_spam_check": false,
        "notes": "",
        "real_actions": true,
        "recognize": "once",
        "required_fields": [],
        "resource_uri": "/rest/v1/eventcreatepage/34848/",
        "status": "active",
        "tags": [],
        "title": "House Parties - Host",
        "type": "EventCreate",
        "updated_at": "2017-03-25T05:34:57",
        "url": ""
}

If you want any of the page settings to be different from the default, just pass them in as additional fields when creating the page, or PATCH them afterwards:

POST /rest/v1/eventcreatepage/

{
        "campaign": "/rest/v1/campaign/175/",
        "goal": 100,
        "name": "house-parties_host",
        "title": "House Parties - Host"
}

If successful, in the response header we'll get back a 201 CREATED status code and the location of the newly created host page:

201 CREATED
Location: https://roboticdogs.actionkit.com/rest/v1/eventcreatepage/34850/

2. Add The EventCreateForm

Next, we'll add an eventcreateform. Refer to the eventcreateform schema for more details about the fields, filtering and ordering options available.

At minimum, we need to send the URI of the Host Page in the page field and thank_you_text in our POST request. thank_you_text is required for all page forms, but isn't actually used for Host Pages. You can put any value in for that field.

Here's an example of an eventcreateform created with the minimum fields:

POST /rest/v1/eventcreateform/

{
        "page": "/rest/v1/eventcreatepage/34850/",
        "thank_you_text": "ty"
}

201 CREATED
Location: https://roboticdogs.actionkit.com/rest/v1/eventcreateform/144/

The created eventcreateform looks like this:

GET /rest/v1/eventcreateform/144/

{
        "client_hosted": false,
        "client_url": "",
        "created_at": "2017-03-25T05:40:46",
        "custom_field_html": "",
        "ground_rules": "",
        "host_requirements": "",
        "host_text": "",
        "id": 144,
        "page": "/rest/v1/eventcreatepage/34850/",
        "resource_uri": "/rest/v1/eventcreateform/144/",
        "templateset": "/rest/v1/templateset/713/",
        "thank_you_text": "ty",
        "tools_sidebar": "",
        "tools_text": "",
        "updated_at": "2017-03-25T05:40:46"
}

Just as with the eventcreatepage, if you wish to override the defaults, pass the field in the payload when you first create the eventcreateform.

3. Add The PageFollowup

And finally, we'll add the pagefollowup object. This endpoint requires the URI of the Host Page in the page field, and the URL for the after-action redirect in the url field.

You should also make sure to enable the confirmation email and to set the content of the confirmation email, as that is how the host gets the link to confirm their event. When creating a host page in the Admin this is done by default, and the confirmation email is prefilled with text from the templateset's event_email_created.html template.

To mimic that here, you'd first need to get the event_email_created.html template from the templateset used by this page. We have the templateset ID from the templateset field of the eventcreateform, and can thus retrieve the desired template by using this filter:

GET /rest/v1/template/?filename=event_email_created.html&templateset=713

{
        "code": 'Subject: Confirm your "{{ action.event.campaign.local_title }}" event {% load actionkit_tags %}
        <!-- event_email_created.html in the templateset contains the default confirmation email for hosts -->
        <p>Thanks for setting up a "{{ action.event.campaign.local_title }}" event. <b>Before anyone can sign up for your event, you must confirm it by clicking below to {% if not user.password %}set a password and{% endif %} log in to your host tools:</b></p>
        <p><a href="https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}">https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}</a></p>
        <p>Please <b>don't forward this email</b>: the link above is personalized, and can be used to manage your event or change your account password.</p>
         <p>Thanks again!</p>
         <!-- Replacement for unsubscribe -->
         <p><small>You're receiving this message because you set up a "{{ action.event.campaign.local_title }}" event. If you don't want to receive further emails about this event, you can cancel the event using the host tools linked above.</small></p> ',
        "code_hash": "a7b47b24498f63a46aba1f9dbbbd7797ab3f480cf3e62a012cb301ce8d3eb11d",
        "created_at": "2016-09-27T03:31:40",
        "filename": "event_email_created.html",
        "id": 11678,
        "resource_uri": "/rest/v1/template/11678/",
        "templateset": "/rest/v1/templateset/713/",
        "updated_at": "2017-01-06T22:57:48"
}

Then parse the code field of the response into the email_subject and email_body fields for your followup page.

POST /rest/v1/pagefollowup/

{
        "page": "/rest/v1/eventcreatepage/34850/",      // required
        "email_body": '{% load actionkit_tags %} <!-- event_email_created.html in the templateset contains the default confirmation email for hosts --> <p>Thanks for setting up a "{{ action.event.campaign.local_title }}" event. <b>Before anyone can sign up for your event, you must confirm it by clicking below to {% if not user.password %}set a password and{% endif %} log in to your host tools:</b></p> <p><a href="https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}">https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}</a></p> <p>Please <b>don't forward this email</b>: the link above is personalized, and can be used to manage your event or change your account password.</p> <p>Thanks again!</p> <!-- Replacement for unsubscribe --> <p><small>You're receiving this message because you set up a "{{ action.event.campaign.local_title }}" event. If you don't want to receive further emails about this event, you can cancel the event using the host tools linked above.</small></p>',
        "email_from_line": "/rest/v1/fromline/1/",
        "email_subject": 'Confirm your "{{ action.event.campaign.local_title }}" event',
        "email_wrapper": "/rest/v1/emailwrapper/1/",
        "send_email": true,
        "url": "/cms/thanks/house-parties_host"         // required
}

201 CREATED
Location: https://roboticdogs.actionkit.com/rest/v1/pagefollowup/1917/

This created the page followup object of:

GET /rest/v1/pagefollowup/1917/

{
        "email_body": '{% load actionkit_tags %} <!-- event_email_created.html in the templateset contains the default confirmation email for hosts --> <p>Thanks for setting up a "{{ action.event.campaign.local_title }}" event. <b>Before anyone can sign up for your event, you must confirm it by clicking below to {% if not user.password %}set a password and{% endif %} log in to your host tools:</b></p> <p><a href="https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}">https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}</a></p> <p>Please <b>don't forward this email</b>: the link above is personalized, and can be used to manage your event or change your account password.</p> <p>Thanks again!</p> <!-- Replacement for unsubscribe --> <p><small>You're receiving this message because you set up a "{{ action.event.campaign.local_title }}" event. If you don't want to receive further emails about this event, you can cancel the event using the host tools linked above.</small></p>',
        "email_custom_from": "",
        "email_from_line": "/rest/v1/fromline/1/",
        "email_subject": 'Confirm your "{{ action.event.campaign.local_title }}" event',
        "email_wrapper": "/rest/v1/emailwrapper/1/",
        "id": 1917,
        "notifications": [],
        "page": "/rest/v1/eventcreatepage/34850/",
        "resource_uri": "/rest/v1/pagefollowup/1917/",
        "send_email": true,
        "send_notifications": false,
        "send_pushes": false,
        "send_taf": false,
        "share_description": "",
        "share_image": "",
        "share_title": "",
        "taf_body": "",
        "taf_subject": "",
        "twitter_message": "",
        "url": "/cms/thanks/house-parties_host"
}

Checking The Host Page

Lastly, let's take a look to see how our Host Page record has changed.

GET /rest/v1/eventcreatepage/34850/

{
        "actions": "/rest/v1/eventcreateaction/?page=34850",
        "allow_multiple_responses": true,
        "campaign": "/rest/v1/campaign/177/",
        "campaign_title": "",
        "cms_form": "/rest/v1/eventcreateform/144/",
        "created_at": "2017-03-25T05:38:42",
        "eventcreateform": {
                "client_hosted": false,
                "client_url": "",
                "created_at": "2017-03-25T05:40:46",
                "custom_field_html": "",
                "ground_rules": "",
                "host_requirements": "",
                "host_text": "",
                "id": 144,
                "page": "/rest/v1/eventcreatepage/34850/",
                "resource_uri": "/rest/v1/eventcreateform/144/",
                "templateset": "/rest/v1/templateset/713/",
                "thank_you_text": "ty",
                "tools_sidebar": "",
                "tools_text": "",
                "updated_at": "2017-03-25T05:40:46"
        },
        "fields": {},
        "followup": {
                "email_body": '{% load actionkit_tags %} <!-- event_email_created.html in the templateset contains the default confirmation email for hosts --> <p>Thanks for setting up a "{{ action.event.campaign.local_title }}" event. <b>Before anyone can sign up for your event, you must confirm it by clicking below to {% if not user.password %}set a password and{% endif %} log in to your host tools:</b></p> <p><a href="https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}">https://{% client_ssl_domain %}/event/{{ action.event.campaign.local_name }}/{{ action.event.id }}/host/?i={{ user.password_change_token }}</a></p> <p>Please <b>don't forward this email</b>: the link above is personalized, and can be used to manage your event or change your account password.</p> <p>Thanks again!</p> <!-- Replacement for unsubscribe --> <p><small>You're receiving this message because you set up a "{{ action.event.campaign.local_title }}" event. If you don't want to receive further emails about this event, you can cancel the event using the host tools linked above.</small></p>',
                "email_custom_from": "",
                "email_from_line": "/rest/v1/fromline/1/",
                "email_subject": 'Confirm your "{{ action.event.campaign.local_title }}" event',
                "email_wrapper": "/rest/v1/emailwrapper/1/",
                "id": 1917,
                "notifications": [],
                "page": "/rest/v1/eventcreatepage/34850/",
                "resource_uri": "/rest/v1/pagefollowup/1917/",
                "send_email": true,
                "send_notifications": false,
                "send_pushes": false,
                "send_taf": false,
                "share_description": "",
                "share_image": "",
                "share_title": "",
                "taf_body": "",
                "taf_subject": "",
                "twitter_message": "",
                "url": "/cms/thanks/house-parties_host"
        },
        "goal": 100,
        "goal_type": "actions",
        "hidden": false,
        "hosted_with": "/rest/v1/hostingplatform/1/",
        "id": 34850,
        "language": null,
        "list": "/rest/v1/list/1/",
        "multilingual_campaign": null,
        "name": "house-parties_host3",
        "never_spam_check": false,
        "notes": "",
        "real_actions": true,
        "recognize": "once",
        "required_fields": [],
        "resource_uri": "/rest/v1/eventcreatepage/34850/",
        "status": "active",
        "tags": [],
        "title": "House Parties - Host",
        "type": "EventCreate",
        "updated_at": "2017-03-25T05:38:42",
        "url": ""
}

The Host Page now has the URI for the eventcreateform in the cms_form field, and the eventcreateform and followup fields now contain the values of the linked eventcreateform and pagefollowup objects.

Next, learn how to create an event for your campaign.