Create Campaign

Create Campaign

POST https://api.ocamba.com/v2/adex/campaigns
Creates a new campaign object

Request schema

body
curl -X POST \
 "https://api.ocamba.com/v2/adex/campaigns" \
  -H "Authorization: Bearer {TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
  "name": "example_campaign_name",
  "description": "This is my first campaign.",
  "status": "active",
  "pricing_model": "cpc",
  "account_id": "10073337",
  "targeting": {
    "countries": {
      "items": [
        "RS"
      ],
      "lists": [
        "1838"
      ],
      "op": "in"
    },
    "regions": {
      "items": [
        "2661876"
      ],
      "lists": [
        "2934"
      ],
      "op": "in"
    },
    "subids": {
      "items": [
        "fut_t10_18-24-MULTI_GG"
      ],
      "lists": [
        "1835"
      ],
      "op": "in"
    },
    "ip": {
      "items": [
        "123.523.123.4"
      ],
      "lists": [
        "2691"
      ],
      "op": "in"
    },
    "pages": {
      "items": [
        "ocamba.com"
      ],
      "lists": [
        "2725"
      ],
      "op": "in"
    },
    "containers": {
      "items": [
        "1303"
      ],
      "op": "in"
    },
    "device_types": {
      "items": [
        "console"
      ],
      "op": "in"
    },
    "device_manufacturers": {
      "items": [
        "13"
      ],
      "op": "in"
    },
    "os": {
      "items": [
        {
          "id": "12",
          "op": "in",
          "versions": [
            "10.0"
          ]
        }
      ]
    },
    "browsers": {
      "items": [
        {
          "id": "10",
          "op": "in",
          "versions": [
            "10.0"
          ]
        }
      ]
    },
    "connections": {
      "items": [
        "1"
      ],
      "op": "nin"
    },
    "time": {
      "items": [
        "[0,15,30,45 12,13,14 * 6 1]"
      ],
      "op": "in"
    },
    "device_tracking": 1,
    "has_user_data": 1
  },
  "metadata": {
    "key1": "value1",
    "key2": "value2"
  },
  "create_time": "2021-10-29 12:47:00",
  "update_time": "2021-10-30 14:27:26"
}'
const url = 'https://api.ocamba.com/v2/adex/campaigns';
const options = {
  method: 'POST',
  headers: {
    Authorization: "Bearer {TOKEN}",
    'Content-Type': "application/json"
  },
  body: JSON.stringify(
    {
      "name": "example_campaign_name",
      "description": "This is my first campaign.",
      "status": "active",
      "pricing_model": "cpc",
      "account_id": "10073337",
      "targeting": {
        "countries": {
          "items": [
            "RS"
          ],
          "lists": [
            "1838"
          ],
          "op": "in"
        },
        "regions": {
          "items": [
            "2661876"
          ],
          "lists": [
            "2934"
          ],
          "op": "in"
        },
        "subids": {
          "items": [
            "fut_t10_18-24-MULTI_GG"
          ],
          "lists": [
            "1835"
          ],
          "op": "in"
        },
        "ip": {
          "items": [
            "123.523.123.4"
          ],
          "lists": [
            "2691"
          ],
          "op": "in"
        },
        "pages": {
          "items": [
            "ocamba.com"
          ],
          "lists": [
            "2725"
          ],
          "op": "in"
        },
        "containers": {
          "items": [
            "1303"
          ],
          "op": "in"
        },
        "device_types": {
          "items": [
            "console"
          ],
          "op": "in"
        },
        "device_manufacturers": {
          "items": [
            "13"
          ],
          "op": "in"
        },
        "os": {
          "items": [
            {
              "id": "12",
              "op": "in",
              "versions": [
                "10.0"
              ]
            }
          ]
        },
        "browsers": {
          "items": [
            {
              "id": "10",
              "op": "in",
              "versions": [
                "10.0"
              ]
            }
          ]
        },
        "connections": {
          "items": [
            "1"
          ],
          "op": "nin"
        },
        "time": {
          "items": [
            "[0,15,30,45 12,13,14 * 6 1]"
          ],
          "op": "in"
        },
        "device_tracking": 1,
        "has_user_data": 1
      },
      "metadata": {
        "key1": "value1",
        "key2": "value2"
      },
      "create_time": "2021-10-29 12:47:00",
      "update_time": "2021-10-30 14:27:26"
    }
  )
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
$ch = curl_init("https://api.ocamba.com/v2/adex/campaigns");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
  "Authorization: Bearer {TOKEN}",
  "Content-Type: application/json"
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode(
  [
    "name" => "example_campaign_name",
    "description" => "This is my first campaign.",
    "status" => "active",
    "pricing_model" => "cpc",
    "account_id" => "10073337",
    "targeting" => [
      "countries" => [
        "items" => [
          "RS"
        ],
        "lists" => [
          "1838"
        ],
        "op" => "in"
      ],
      "regions" => [
        "items" => [
          "2661876"
        ],
        "lists" => [
          "2934"
        ],
        "op" => "in"
      ],
      "subids" => [
        "items" => [
          "fut_t10_18-24-MULTI_GG"
        ],
        "lists" => [
          "1835"
        ],
        "op" => "in"
      ],
      "ip" => [
        "items" => [
          "123.523.123.4"
        ],
        "lists" => [
          "2691"
        ],
        "op" => "in"
      ],
      "pages" => [
        "items" => [
          "ocamba.com"
        ],
        "lists" => [
          "2725"
        ],
        "op" => "in"
      ],
      "containers" => [
        "items" => [
          "1303"
        ],
        "op" => "in"
      ],
      "device_types" => [
        "items" => [
          "console"
        ],
        "op" => "in"
      ],
      "device_manufacturers" => [
        "items" => [
          "13"
        ],
        "op" => "in"
      ],
      "os" => [
        "items" => [
          [
            "id" => "12",
            "op" => "in",
            "versions" => [
              "10.0"
            ]
          ]
        ]
      ],
      "browsers" => [
        "items" => [
          [
            "id" => "10",
            "op" => "in",
            "versions" => [
              "10.0"
            ]
          ]
        ]
      ],
      "connections" => [
        "items" => [
          "1"
        ],
        "op" => "nin"
      ],
      "time" => [
        "items" => [
          "[0,15,30,45 12,13,14 * 6 1]"
        ],
        "op" => "in"
      ],
      "device_tracking" => 1,
      "has_user_data" => 1
    ],
    "metadata" => [
      "key1" => "value1",
      "key2" => "value2"
    ],
    "create_time" => "2021-10-29 12:47:00",
    "update_time" => "2021-10-30 14:27:26"
  ]
));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);

Responses

201 Created

{
  "id": "1001231",
  "company_id": "2233113",
  "account_id": "10073337",
  "creator_id": "1000323",
  "name": "example_campaign_name",
  "description": "This is my first campaign.",
  "status": "active",
  "type": "internal",
  "pricing_model": "cpc",
  "score": 50,
  "targeting": {
    "countries": {
      "items": [
        "RS"
      ],
      "lists": [
        "1838"
      ],
      "op": "in"
    },
    "regions": {
      "items": [
        "2661876"
      ],
      "lists": [
        "2934"
      ],
      "op": "in"
    },
    "subids": {
      "items": [
        "fut_t10_18-24-MULTI_GG"
      ],
      "lists": [
        "1835"
      ],
      "op": "in"
    },
    "ip": {
      "items": [
        "123.523.123.4"
      ],
      "lists": [
        "2691"
      ],
      "op": "in"
    },
    "pages": {
      "items": [
        "ocamba.com"
      ],
      "lists": [
        "2725"
      ],
      "op": "in"
    },
    "containers": {
      "items": [
        "1303"
      ],
      "op": "in"
    },
    "device_types": {
      "items": [
        "console"
      ],
      "op": "in"
    },
    "device_manufacturers": {
      "items": [
        "13"
      ],
      "op": "in"
    },
    "os": {
      "items": [
        {
          "id": "12",
          "op": "in",
          "versions": [
            "10.0"
          ]
        }
      ]
    },
    "browsers": {
      "items": [
        {
          "id": "10",
          "op": "in",
          "versions": [
            "10.0"
          ]
        }
      ]
    },
    "connections": {
      "items": [
        "1"
      ],
      "op": "nin"
    },
    "time": {
      "items": [
        "[0,15,30,45 12,13,14 * 6 1]"
      ],
      "op": "in"
    },
    "device_tracking": 1,
    "has_user_data": 1
  },
  "metadata": {
    "key1": "value1",
    "key2": "value2"
  },
  "create_time": "2021-10-29 12:47:00",
  "update_time": "2021-10-30 14:27:26"
}
Responses

Info
If external_demand_id is supplied the type of campaign will be external, otherwise it will be internal. If external_demand_id is supplied the pricing model of the external demand must match the pricing model of the campaign.
Note
We recommend using containers instead of tags, as tags are deprecated. If both parameters are sent, containers will take priority.