Skip to main content
POST
/
api
/
v2
/
affiliate
/
campaigns
Create affiliate campaign
curl --request POST \
  --url https://{domain}/api/v2/affiliate/campaigns \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "name": "Sample Campaign",
  "offer_id": 1,
  "commission_plan_id": 1,
  "traffic_source_id": 1,
  "landing_page_id": 1,
  "creative_id": null
}
'
import requests

url = "https://{domain}/api/v2/affiliate/campaigns"

payload = {
"name": "Sample Campaign",
"offer_id": 1,
"commission_plan_id": 1,
"traffic_source_id": 1,
"landing_page_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',
offer_id: 1,
commission_plan_id: 1,
traffic_source_id: 1,
landing_page_id: 1,
creative_id: null
})
};

fetch('https://{domain}/api/v2/affiliate/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/affiliate/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',
'offer_id' => 1,
'commission_plan_id' => 1,
'traffic_source_id' => 1,
'landing_page_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/affiliate/campaigns"

payload := strings.NewReader("{\n \"name\": \"Sample Campaign\",\n \"offer_id\": 1,\n \"commission_plan_id\": 1,\n \"traffic_source_id\": 1,\n \"landing_page_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/affiliate/campaigns")
.header("X-API-Key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Sample Campaign\",\n \"offer_id\": 1,\n \"commission_plan_id\": 1,\n \"traffic_source_id\": 1,\n \"landing_page_id\": 1,\n \"creative_id\": null\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://{domain}/api/v2/affiliate/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 \"offer_id\": 1,\n \"commission_plan_id\": 1,\n \"traffic_source_id\": 1,\n \"landing_page_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>",
      "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>"
      },
      "commission_plan": {
        "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

X-API-Key
string
header
required

Preferred authentication method. Pass the API key in the X-API-Key HTTP request header. The user account must have api_status enabled.

Body

application/json
name
string
required

Campaign name. Maximum 100 characters.

offer_id
integer
required

Offer ID. Must be accessible to the affiliate.

landing_page_id
integer
required

Landing page ID bound to the selected offer.

commission_plan_id
integer

Commission plan ID bound to the selected offer. Required on Brand and Marketplace platforms.

traffic_source_id
integer

Optional traffic source ID.

traffic_approach_id
integer

Optional traffic approach ID.

creative_id
integer | null

Optional creative ID bound to the selected offer.

status
enum<string>

Initial campaign status. Defaults to active if omitted.

Available options:
active,
paused
countries
integer[]

GeoNames country IDs to restrict the campaign to. Omit or pass an empty array for no restriction.

Response

Campaign created.

message
string
Example:

"Campaign created"

success
boolean
Example:

true

info
object