curl --request POST \
--url https://{domain}/api/v2/network/campaigns \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "Sample Campaign",
"affiliate_id": 1,
"offer_id": 1,
"landing_page_id": 1,
"traffic_source_id": 1,
"creative_id": null
}
'import requests
url = "https://{domain}/api/v2/network/campaigns"
payload = {
"name": "Sample Campaign",
"affiliate_id": 1,
"offer_id": 1,
"landing_page_id": 1,
"traffic_source_id": 1,
"creative_id": None
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Sample Campaign',
affiliate_id: 1,
offer_id: 1,
landing_page_id: 1,
traffic_source_id: 1,
creative_id: null
})
};
fetch('https://{domain}/api/v2/network/campaigns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{domain}/api/v2/network/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sample Campaign',
'affiliate_id' => 1,
'offer_id' => 1,
'landing_page_id' => 1,
'traffic_source_id' => 1,
'creative_id' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{domain}/api/v2/network/campaigns"
payload := strings.NewReader("{\n \"name\": \"Sample Campaign\",\n \"affiliate_id\": 1,\n \"offer_id\": 1,\n \"landing_page_id\": 1,\n \"traffic_source_id\": 1,\n \"creative_id\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{domain}/api/v2/network/campaigns")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sample Campaign\",\n \"affiliate_id\": 1,\n \"offer_id\": 1,\n \"landing_page_id\": 1,\n \"traffic_source_id\": 1,\n \"creative_id\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{domain}/api/v2/network/campaigns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sample Campaign\",\n \"affiliate_id\": 1,\n \"offer_id\": 1,\n \"landing_page_id\": 1,\n \"traffic_source_id\": 1,\n \"creative_id\": null\n}"
response = http.request(request)
puts response.read_body{
"message": "Campaign created",
"success": true,
"info": {
"campaign": {
"id": 123,
"hash": "<string>",
"name": "<string>",
"status": "active",
"created": 123,
"date_added": 123,
"date_updated": 123,
"countries": [
{
"id": 123,
"title": "<string>",
"code": "<string>"
}
],
"offer": {
"id": 123,
"title": "<string>"
},
"affiliate": {
"id": 123,
"title": "<string>"
},
"advertiser": {
"id": 123,
"title": "<string>"
},
"traffic_source": {
"id": 123,
"title": "<string>"
},
"traffic_approach": {
"id": 123,
"title": "<string>"
},
"landing_page": {
"id": 123,
"title": "<string>",
"offer_id": 123
},
"creative": {
"id": 123,
"title": "<string>"
}
}
}
}{
"message": "<string>",
"success": false,
"info": {
"errors": {}
}
}Create campaign
Creates a new campaign for the specified affiliate. The hash is generated server-side and cannot be set by the caller. If status is omitted the campaign is created as active.
curl --request POST \
--url https://{domain}/api/v2/network/campaigns \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"name": "Sample Campaign",
"affiliate_id": 1,
"offer_id": 1,
"landing_page_id": 1,
"traffic_source_id": 1,
"creative_id": null
}
'import requests
url = "https://{domain}/api/v2/network/campaigns"
payload = {
"name": "Sample Campaign",
"affiliate_id": 1,
"offer_id": 1,
"landing_page_id": 1,
"traffic_source_id": 1,
"creative_id": None
}
headers = {
"X-API-Key": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Sample Campaign',
affiliate_id: 1,
offer_id: 1,
landing_page_id: 1,
traffic_source_id: 1,
creative_id: null
})
};
fetch('https://{domain}/api/v2/network/campaigns', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{domain}/api/v2/network/campaigns",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Sample Campaign',
'affiliate_id' => 1,
'offer_id' => 1,
'landing_page_id' => 1,
'traffic_source_id' => 1,
'creative_id' => null
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"X-API-Key: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{domain}/api/v2/network/campaigns"
payload := strings.NewReader("{\n \"name\": \"Sample Campaign\",\n \"affiliate_id\": 1,\n \"offer_id\": 1,\n \"landing_page_id\": 1,\n \"traffic_source_id\": 1,\n \"creative_id\": null\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-API-Key", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{domain}/api/v2/network/campaigns")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sample Campaign\",\n \"affiliate_id\": 1,\n \"offer_id\": 1,\n \"landing_page_id\": 1,\n \"traffic_source_id\": 1,\n \"creative_id\": null\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{domain}/api/v2/network/campaigns")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"Sample Campaign\",\n \"affiliate_id\": 1,\n \"offer_id\": 1,\n \"landing_page_id\": 1,\n \"traffic_source_id\": 1,\n \"creative_id\": null\n}"
response = http.request(request)
puts response.read_body{
"message": "Campaign created",
"success": true,
"info": {
"campaign": {
"id": 123,
"hash": "<string>",
"name": "<string>",
"status": "active",
"created": 123,
"date_added": 123,
"date_updated": 123,
"countries": [
{
"id": 123,
"title": "<string>",
"code": "<string>"
}
],
"offer": {
"id": 123,
"title": "<string>"
},
"affiliate": {
"id": 123,
"title": "<string>"
},
"advertiser": {
"id": 123,
"title": "<string>"
},
"traffic_source": {
"id": 123,
"title": "<string>"
},
"traffic_approach": {
"id": 123,
"title": "<string>"
},
"landing_page": {
"id": 123,
"title": "<string>",
"offer_id": 123
},
"creative": {
"id": 123,
"title": "<string>"
}
}
}
}{
"message": "<string>",
"success": false,
"info": {
"errors": {}
}
}Authorizations
Preferred authentication method. Pass the API key in the X-API-Key HTTP request header. The user account must have api_status enabled.
Body
Campaign name. Maximum 100 characters.
ID of the affiliate this campaign belongs to. Must be within the caller's visibility scope.
ID of an active offer. Must be accessible to the selected affiliate.
ID of an active landing page belonging to the selected offer.
Optional traffic source ID.
Optional traffic approach ID.
Optional creative ID belonging to the selected offer.
Initial campaign status. Defaults to active if omitted.
active, paused GeoNames country IDs to restrict the campaign to. Omit or pass an empty array for no restriction.
Was this page helpful?