Book a Campaign
This example illustrates how to create and target a campaign (or reservation), and associate it with an ad copy. In combination with the Import Content from a URL (REST) use case, it shows the complete set of operations required to ingest content, schedule it and have it appear on the targeted player systems. See also Campaigns.
Note: The ID#s we use in these samples are for illustration purposes. They are invalid. Be sure to use your own ID#s for your integrations. Also, in our examples, we use the api-sandbox endpoint and HTTP token.
You will need to use the following methods to book a campaign (or reservation). Note that you will need the ID#s from the responses as values for parameters in the next steps in sequence.
To book a campaign (REST):
- Create a campaign/reservation. Use the POST /reservation/v22/add method.
- Using the ID# of your new campaign/reservation as the parent, associate a criterion with your campaign. Use the POST /resource_criteria/v7/add method.
-
Next, target the reservation to specific display units. Do this by using the reservation ID# and resource_criteria ID# to create a skin_slot. A skin_slot is a link between a loop slot and a frame which, in turn, sits in a day part. Use the POST /reservation/v22/add_skin_slots method.
Note: As is, the request will target all display units in the domain; however, by specifying criteria, containers and Boolean operators, you can fine-grain the targeting.
- After you create the skin_slots, add content to the campaign/reservation first by fetching the default_schedule_id of the campaign/reservation we just created. Use the GET /reservation/v22/many method.
- Create the bundle that will hold the content. Use the POST /bundle/v12/add method.
- Using a valid content ID#, associate a specific piece of content with the bundle. Use the POST /bundle_content/v5/add method.
- Promote the campaign. Use both the PUT /reservation/v22/many and /reservation/v22 methods.
Create a campaign or reservation. You will use the response from this request as the parent_id in Step 2: Associate Criterion with the Campaign.
Request
curl -X POST \
https://api-sandbox.broadsign.com:10889/rest/reservation/v22/add \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache' \
-d '{
"domain_id": 123456789,
"name": "cURL Campaign reservation",
"container_id": 12345,
"duration_msec": 10000,
"start_date": "2017-10-28",
"end_date": "2017-12-18",
"start_time": "00:00:00",
"end_time": "23:59:59"
}'
Response
{
"reservation": [
{
"id": 987654321
}
]
}
Next, we will associate a criterion with the campaign.
Using the ID# of your new campaign/reservation (987654321 in our example) as the parent, associate a criterion with your campaign.
Request
curl -X POST \
https://api-sandbox.broadsign.com:10889/rest/resource_criteria/v7/add \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache' \
-d '{
"parent_id": 987654321,
"criteria_id": 23,
"type": 5,
"domain_id": 123456789
}'
Response
{
"resource_criteria": [
{
"id": 555
}
]
}
Next, we will target the campaign/reservation to specific display units.
Target the reservation to specific display units. Do this by using the reservation ID# and resource_criteria ID# to create a skin_slot. A skin_slot is a link between a loop slot and a frame which, in turn, sits in a day part.
We will use the following responses from steps 1 and 2:
- id: The reservation ID#. In our example, it is: 987654321.
- du_or_criteria: The resource_criteria. In our example, it is 555.
Request
curl -X POST \
https://api-sandbox.broadsign.com:10889/rest/reservation/v22/add_skin_slots \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"domain_id": 123456789,
"id": 987654321,
"sub_elements": {
"du_or_criteria": [ { "id": 23 } ]
}
}'
Response
{
"reservation": [
{
"id": 987654321
}
]
}
Next, we take the steps required to add content to the reservation. First, we will fetch the default_schedule_id of the reservation we just created.
Use the reservation ID# from Step 1. In our example, it is: 987654321.
Request
curl -X GET \
'https://localhost:10889/rest/reservation/v22/by_id?ids=987654321&domain_id=123456789' \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache'
Response
The response gives us the ID# of the default_schedule_id: 1731. We will use it in the parent_id parameter of Step 5: Create a Bundle.
{
"not_modified_since": "2017-10-27T17:55:12Z",
"reservation": [
{
"active": true,
"auto_synchronize_bundles": false,
"bmb_host_id": 0,
"booking_state": 0,
"booking_state_calculated_on": "",
"container_id": 12345,
"creation_tm": "2017-10-27T17:13:20",
"creation_user_id": 2,
"day_of_week_mask": 127,
"default_attributes": "",
"default_bundle_weight": 0,
"default_category_id": 0,
"default_fullscreen": false,
"default_interactivity_timeout": 0,
"default_interactivity_trigger_id": 0,
"default_schedule_id": 1731,
"default_secondary_sep_category_ids": "",
"default_segment_category_id": 0,
"default_trigger_category_id": 0,
"domain_id": 123456789,
"duration_msec": 10000,
"end_date": "2017-12-18",
"end_time": "23:59:59",
"estimated_reps": 0,
"goal_amount": 0,
"goal_reached_on_tm": "",
"goal_unit": 0,
"has_goal": false,
"id": 987654321,
"media_package_id": 0,
"name": "cURL Campaign reservation",
"pacing_period": 0,
"pacing_target": 0,
"parent_id": 0,
"promoter_user_id": 0,
"promotion_time": "",
"reps_calculated_on": "",
"saturation": 1,
"start_date": "2017-10-28",
"start_time": "00:00:00",
"state": 0
}
]
}
Next, we will create the bundle to hold the content. Use the default_schedule_id from the response in Step 4 in the parent_id parameter in the request.
Request
curl -X POST \
https://localhost:10889/rest/bundle/v12/add \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"domain_id": 123456789,
"parent_id": 1731,
"name": "BroadSign_1280_720"
}'
Response
{
"bundle": [
{
"id": 1751
}
]
}
Next, we will associate a specific content_id to the bundle. Be sure that the content ID# is valid. Use the bundle id from the response in Step 5 in the parent_id parameter in the request.
Request
curl -X POST \
https://localhost:10889/rest/bundle_content/v5/add \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"content_id": 1727,
"domain_id": 123456789,
"parent_id": 1751
}'
Response
{
"bundle_content": [
{
"id": 1752
}
]
}
Finally, we will promote the campaign. First, we will list it then we will update it.
Request
curl -X GET \
'https://localhost:10889/rest/reservation/v22/by_id?ids=987654321&domain_id=123456789' \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache'
Response
{
"not_modified_since": "2017-10-27T18:13:11Z",
"reservation": [
{
"active": true,
"auto_synchronize_bundles": false,
"bmb_host_id": 0,
"booking_state": 0,
"booking_state_calculated_on": "",
"container_id": 12345,
"creation_tm": "2017-10-27T17:13:20",
"creation_user_id": 2,
"day_of_week_mask": 127,
"default_attributes": "",
"default_bundle_weight": 0,
"default_category_id": 0,
"default_fullscreen": false,
"default_interactivity_timeout": 0,
"default_interactivity_trigger_id": 0,
"default_schedule_id": 1731,
"default_secondary_sep_category_ids": "",
"default_segment_category_id": 0,
"default_trigger_category_id": 0,
"domain_id": 123456789,
"duration_msec": 10000,
"end_date": "2017-12-18",
"end_time": "23:59:59",
"estimated_reps": 0,
"goal_amount": 0,
"goal_reached_on_tm": "",
"goal_unit": 0,
"has_goal": false,
"id": 987654321,
"media_package_id": 0,
"name": "cURL Campaign reservation",
"pacing_period": 0,
"pacing_target": 0,
"parent_id": 0,
"promoter_user_id": 0,
"promotion_time": "",
"reps_calculated_on": "",
"saturation": 1,
"start_date": "2017-10-28",
"start_time": "00:00:00",
"state": 0
}
]
}
Request
curl -X PUT \
https://localhost:10889/rest/reservation/v22 \
-H 'authorization: Bearer YourAPIKeyHere' \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-d '{
"active": true,
"auto_synchronize_bundles": false,
"bmb_host_id": 0,
"container_id": 12345,
"default_attributes": "",
"default_bundle_weight": 0,
"default_category_id": 0,
"default_fullscreen": false,
"default_interactivity_timeout": 0,
"default_interactivity_trigger_id": 0,
"default_secondary_sep_category_ids": "",
"default_segment_category_id": 0,
"default_trigger_category_id": 0,
"domain_id": 123456789,
"goal_amount": 0,
"goal_unit": 0,
"has_goal": false,
"id": 987654321,
"name": "cURL Campaign reservation",
"pacing_period": 0,
"pacing_target": 0,
"parent_id": 0,
"state": 1
}'
Response
{
""not_modified_since": "2017-10-27T18:13:11Z",
"reservation": [
{
"id": 987654321
}
]
}