# Campaign Examples

Before you try out any code from here, fetch an API Key! Then replace <api-key> with the token you received.

# Create a Campaign

Before you create a campaign, you should get a Country Code!

# Create a RON Campaign

Postman example: tonic-showcase/Campaign/create ron campaign

This will create an active RON campaign called DONUT_CAMPAIGN with a URL linking to a GIF. It will target desktop users from the US with a Windows computer and will last from the 5th of October 2016 until the 5th of October 2020. Only non-adult traffic will be sent to the campaign.

curl -X POST \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: d59c452f-8083-4713-bfc6-3b990e8011bc' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "DONUT-CAMPAIGN",
    "ad_type": "ppr",
    "campaign_type": "ron",
    "budget_spread": false,
    "cpc": 0.03,
    "url": "http://gph.is/2cpbE6Y",
    "status": "active",
    "budget": 3,
    "targeting": {
        "country": "US",
        "traffic_category": "non-adult",
        "device": ["desktop"],
        "os": ["windows"]
    },
    "time_settings": {
        "start_date": "2016-10-05 00:00:00",
        "end_date": "2020-10-05 00:00:00"
    }
}'

# Create a Keyword Campaign

Postman example: tonic-showcase/Campaign/create keyword campaign

This time we will create a keyword targeted campaign which will only receive traffic from Macintosh users browsing with Safari, with a bid of $0.03, for traffic matching keywords sweets, sugar, and bonbon. Again, it will last from the 5th of November 2016 until the 5th of November 2020 and only non-adult traffic will be sent to the campaign.

curl -X POST \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 8edc3246-7b32-4b3f-9982-c68ef46d6e86' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "BONBON-CAMPAIGN",
    "ad_type": "ppr",
    "campaign_type": "keyword",
    "budget_spread": false,
    "cpc": 0.03,
    "url": "http://gph.is/2cpbE6Y",
    "status": "active",
    "budget": 3,
    "targeting": {
        "country": "US",
        "traffic_category": "non-adult",
        "keywords": ["sweets", "sugar", "bonbon"],
        "device": ["desktop"],
        "browsers": ["safari"],
        "os": ["macintosh"]
    },
    "time_settings": {
        "start_date": "2016-10-05 00:00:00",
        "end_date": "2020-10-05 00:00:00"
    }
}'

# Create a Category Campaign

Now we want to create a campaign based on categories. Before we create a campaign, we should get a list of categories:

Postman example: tonic-showcase/Categories/list categories

curl -X GET \
  https://api.advertiser.tonic.com/v1/categories \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 099edd57-a330-495b-bbc4-42f71b648b22' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache'

This will return a list of all categories we have (just a small subset is included here):

[
    {
        "category_id": 1,
        "category": "Apparel & Clothing",
        "adult": 0
    },
    {
        "category_id": 2,
        "category": "Beauty & Cosmetics",
        "adult": 0
    },
    {
        "category_id": 3,
        "category": "Computers",
        "adult": 0
    },
    {
        "category_id": 4,
        "category": "Consumer Electronics",
        "adult": 0
    },
    {
        "category_id": 5,
        "category": "Family",
        "adult": 0
    },
    {
        "category_id": 6,
        "category": "Finance",
        "adult": 0
    },
    {
        "category_id": 7,
        "category": "Food",
        "adult": 0
	}
]

Postman example: tonic-showcase/Campaign/create category campaign

We want to create a campaign with the category Food, so we reference it with ID 7. For this campaign we will set our cpc to $0.20 and our budget to $50.00. We are not certain if we want to have this campaign live so we will set the status to paused. As soon as we set the campaign to active, it will start.

curl -X POST \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 81139f5a-348d-49b9-977e-caef4182f880' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "CHOCOLATE-CAMPAIGN",
    "ad_type": "ppr",
    "campaign_type": "category",
    "budget_spread": false,
    "cpc": 0.2,
    "url": "http://gph.is/2cpbE6Y",
    "status": "paused",
    "budget": 50,
    "targeting": {
        "country": "US",
        "traffic_category": "non-adult",
        "categories": [7],
        "device": ["desktop"],
        "browsers": ["safari"],
        "os": ["macintosh"]
    }
}'

# Create a mobile Campaign

To create a campaign targeting mobile devices we need to get a list of available carriers first.

As our campaign will be targeted to Germany, we only want German (DE) carriers.

Postman example: tonic-showcase/Carriers/list carriers

curl -X GET \
  'https://api.advertiser.tonic.com/v1/carriers?country=DE' \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 605cf93e-aedb-4f09-841a-6a8e45ef874a' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache'

It will return a list of carriers:

[
    {
        "carrier_id": 112,
        "name": "T-Mobile",
        "identifier": "tmob_de",
        "country": "de"
    },
    {
        "carrier_id": 113,
        "name": "Vodafone",
        "identifier": "voda_de",
        "country": "de"
    },
    {
        "carrier_id": 114,
        "name": "E-Plus",
        "identifier": "eplu_de",
        "country": "de"
    },
    {
        "carrier_id": 116,
        "name": "o2",
        "identifier": "o2_de",
        "country": "de"
    },
    {
        "carrier_id": 117,
        "name": "AIRDATA",
        "identifier": "aird_de",
        "country": "de"
    },
    {
        "carrier_id": 784,
        "name": "Debitel",
        "identifier": "debi_de",
        "country": "de"
    },
    {
        "carrier_id": 1876,
        "name": "Others",
        "identifier": "other_de",
        "country": "de"
    }
]

Postman example: tonic-showcase/Campaign/create campaign mobile devices

The following cURL command will create a mobile targeted campaign, with all German carriers, for android, ios and blackberry devices that use Firefox as a browser. Also, we want adult traffic for this campaign.

curl -X POST \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 44ad3ae6-61cc-4225-aa5e-a03a4238950e' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "BROWNIE-CAMPAIGN",
    "ad_type": "ppr",
    "campaign_type": "category",
    "budget_spread": false,
    "cpc": 0.2,
    "url": "http://gph.is/2cpbE6Y",
    "status": "active",
    "budget": 50,
    "targeting": {
        "country": "DE",
        "traffic_category": "adult",
        "categories": [7],
        "device": ["mobile", "tablet"],
        "carriers": [
        	"tmob_de",
        	"voda_de",
        	"eplu_de",
        	"o2_de",
        	"aird_de",
        	"debi_de",
        	"other_de"
        ],
        "browsers": ["firefox"],
        "os": ["android", "ios", "blackberry"]
    }
}'

# Create a Campaign with Source-ID Black-/Whitelisting

Postman example: tonic-showcase/Campaign/create campaign whitelisting

For our Jell-O campaign, we only want traffic from two Source-IDs.

curl -X POST \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: c4ae7817-abe2-4207-8b2a-2e6610139f2d' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "JELLO-CAMPAIGN",
    "ad_type": "ppr",
    "campaign_type": "keyword",
    "budget_spread": false,
    "cpc": 0.03,
    "url": "http://gph.is/2cpbE6Y",
    "status": "active",
    "budget": 3,
    "targeting": {
        "country": "US",
        "traffic_category": "non-adult",
        "keywords": ["sweets", "sugar", "jello"],
        "device": ["desktop"],
        "browsers": ["internet_explorer"],
        "os": ["windows"]
    },
    "whitelisting": true,
    "source_ids": [
    	"50250f2c978c8f2218000001",
    	"50250fced56cc0aa1f000001"
    ],
    "time_settings": {
        "start_date": "2016-10-05 00:00:00",
        "end_date": "2020-10-05 00:00:00"
    }
}'

If we switched "whitelisting": true to "whitelisting": false, the campaign would accept all traffic, except for these two Source-IDs (the Source-IDs would be effectively blacklisted).

# Create a Campaign with Source-ID Bidding

Postman example: tonic-showcase/Campaign/create campaign source-id bidding

It is possible to bid on specific Source-IDs. Here is an example how to do this:

curl -X POST \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: cc5bc7de-1536-4458-b9ff-0736cdb5f24b' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
    "campaign_name": "LOLLIPOP-CAMPAIGN",
    "ad_type": "ppr",
    "campaign_type": "keyword",
    "budget_spread": false,
    "cpc": 0.03,
    "url": "http://gph.is/2cpbE6Y",
    "status": "active",
    "budget": 30,
    "targeting": {
        "country": "US",
        "traffic_category": "non-adult",
        "keywords": ["sweets", "sugar", "lollipop"],
        "device": ["desktop"],
        "browsers": ["chrome"],
        "os": ["others"]
    },
    "time_settings": {
        "start_date": "2016-10-05 00:00:00",
        "end_date": "2020-10-05 00:00:00"
    },
    "specific_source_ids": [
    	{
    		"source_id": "50250f2c978c8f2218000001",
    		"cpc": 0.4
    	},
    	{
    		"source_id": "50250fced56cc0aa1f000001",
    		"cpc": 0.02
    	}
    ]
}'

# Edit a Campaign

Postman example: tonic-showcase/Campaign/list campaigns

Before editing, it makes sense to list all campaigns.

curl -X GET \
  https://api.advertiser.tonic.com/v1/campaigns \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -H 'Postman-Token: 785b1ae1-b2d0-4def-be82-5fc3e0ea15d8' \
  -H 'api-key: b6e06ab944148d5b674f257fab096e7c807141a6948480e3eabd28ae83b78a1c76a433a5dc2b57455bf0b396be5ce123a0db62779d5d48674ef941eb98c0255d' \
  -H 'cache-control: no-cache'

# Change CPC

Postman example: tonic-showcase/Campaign/edit campaign set cpc

Change the cost per click:

curl -X PATCH \
  https://api.advertiser.tonic.com/v1/campaigns/5c13b6204f45dd62587d2ee1 \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 46fdd14c-3466-478c-a4b6-463b4e7f45e9' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
	"cpc": 0.03
}'

# Change Keywords

Postman example: tonic-showcase/Campaign/edit campaign set keywords

Set keywords for a campaign:

curl -X PATCH \
  https://api.advertiser.tonic.com/v1/campaigns/5c13b6204f45dd62587d2ee1 \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: b28a7b19-0ca4-4758-9533-5e8b94dd8a0e' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
	"targeting": {
		"keywords": ["something"]
	}
}'

# Change URL

Postman example: tonic-showcase/Campaign/edit campaign set url

Change the URL of a campaign:

curl -X PATCH \
  https://api.advertiser.tonic.com/v1/campaigns/5c13b6204f45dd62587d2ee1 \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 8986c533-a29f-4973-90ae-7b7e27ed131b' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
	"url": "https://gph.is/10WWACh"
}'

# Change Status

Postman example: tonic-showcase/Campaign/edit campaign set status

Change the status of a campaign:

curl -X PATCH \
  https://api.advertiser.tonic.com/v1/campaigns/%3Ccampaign-id%3E \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: cc5d4f2b-c8bf-4af4-881b-58f6734d4755' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
	"status": "paused"
}'

# Change Black-/Whitelist

Postman example: tonic-showcase/Campaign/edit campaign set whitelist

Add a whitelist to a campaign:

curl -X PATCH \
  https://api.advertiser.tonic.com/v1/campaigns/5c13b6204f45dd62587d2ee1 \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: 9f6c437a-73c9-47a8-80b0-fc65fb6a9063' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
	"whitelisting": true,
	"source_ids": [
		"50250f2c978c8f2218000001",
    	"50250fced56cc0aa1f000001"
	]
}'

# Change Source-ID Bidding

Postman example: tonic-showcase/Campaign/edit campaign set source-id bidding

Set bids on specific Source-IDs:

curl -X PATCH \
  https://api.advertiser.tonic.com/v1/campaigns/5c13b6204f45dd62587d2ee1 \
  -H 'Content-Type: application/json' \
  -H 'Postman-Token: bde80a52-a68b-4e82-9bd5-205d875f2ac6' \
  -H 'api-key: <api-key>' \
  -H 'cache-control: no-cache' \
  -d '{
	"specific_source_ids": [
		{
    		"source_id": "50250f2c978c8f2218000001",
    		"cpc": 0.4
    	},
    	{
    		"source_id": "50250fced56cc0aa1f000001",
    		"cpc": 0.02
    	}
	]
}'
Last Updated: 10/19/2020, 10:11:43 AM