Create A New Campaign

To create a campaign, we send a POST request to the campaign endpoint.

Simple Setup Using Default Settings

The simplest is to create the campaign with the minimum required field, name like so:

POST /rest/v1/campaign/

{   "name": "house-parties" }

That results in a campaign with these default settings:

{
        "allow_private": true,
        "created_at": "2017-03-25T04:23:27",
        "default_event_size": 50,
        "default_title": "",
        "eventcreatepages": [],
        "events": "/rest/v1/event/?campaign=175",
        "eventsignuppages": [],
        "hidden": false,
        "id": 175,
        "max_event_size": null,
        "name": "house-parties",
        "public_create_page": true,
        "public_search_page": true,
        "require_email_confirmation": true,
        "require_staff_approval": false,
        "resource_uri": "/rest/v1/campaign/175/",
        "show_address1": false,
        "show_attendee_count": false,
        "show_city": true,
        "show_directions": false,
        "show_public_description": true,
        "show_state": true,
        "show_title": true,
        "show_venue": true,
        "show_zip": true,
        "starts_at": null,
        "title": "",
        "updated_at": "2017-03-25T04:23:27",
        "use_start_date": true,
        "use_start_time": true,
        "use_title": true
}

Creating A Campaign With Customized Settings

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

POST /rest/v1/campaign/

{
        "name": "house-parties",
        "require_staff_approval": true,
        "title": "House Parties"
}

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

201 CREATED

Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Sat, 25 Mar 2017 04:14:23 GMT
Location: https://roboticdogs.actionkit.com/rest/v1/campaign/177/
Server: nginx
Set-Cookie: sid=bwdqs02rvawy41q33fw3d88ryibo7qjh; expires=Sat, 25-Mar-2017 12:14:23 GMT; httponly; Max-Age=28800; Path=/
Vary: Accept,Cookie,Accept-Encoding,User-Agent
X-Machine-Id: ip-10-50-1-36
Content-Length: 20
Connection: keep-alive

And when you go the Campaign list page in the Admin, you can see that the campaign was created with the new settings:

../../../_images/API-create-campaign.png

Next Steps

Now that you've created your Campaign, you'll want to set up Host and Attendee pages so that you can create events and add signups to your events.

Check out other examples for adding Host Pages, adding Attendee Pages, and adding signups to events.