Dynamic Ad
curl --request POST \
--url https://public.plai.io/meta/create_campaign \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"userId": "<string>",
"campaignName": "<string>",
"status": "<string>",
"budget": 123,
"startDate": "<string>",
"endDate": "<string>",
"url": "<string>",
"specialAdCategories": [
"<string>"
],
"specialAdCountries": [
"<string>"
],
"utmParams": "<string>",
"adSetName": "<string>",
"gender": "<string>",
"ages": {
"minAge": 123,
"maxAge": 123
},
"locations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"excludedLocations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"proximityTargeting": [
{
"countryName": "<string>",
"distance_unit": "<string>",
"latitude": "<string>",
"longitude": "<string>",
"radius": 123
}
],
"interests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"narrowInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"furtherInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"targetLocales": [
123
],
"audienceId": [
"<string>"
],
"excludedAudienceIds": [
"<string>"
],
"manualPlacements": true,
"facebook_positions": [
"<string>"
],
"instagram_positions": [
"<string>"
],
"messenger_positions": [
"<string>"
],
"userDevices": [
"<string>"
],
"userOS": [
"<string>"
],
"campaignType": "<string>",
"images": [
{
"url": "<string>"
}
],
"videos": [
{
"video_id": "<string>",
"thumbnail_url": "<string>"
}
],
"primaryText": [
{
"text": "<string>"
}
],
"headlines": [
{
"text": "<string>"
}
],
"leadsFormId": "<string>",
"callToAction": "<string>"
}
'import requests
url = "https://public.plai.io/meta/create_campaign"
payload = {
"userId": "<string>",
"campaignName": "<string>",
"status": "<string>",
"budget": 123,
"startDate": "<string>",
"endDate": "<string>",
"url": "<string>",
"specialAdCategories": ["<string>"],
"specialAdCountries": ["<string>"],
"utmParams": "<string>",
"adSetName": "<string>",
"gender": "<string>",
"ages": {
"minAge": 123,
"maxAge": 123
},
"locations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"excludedLocations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"proximityTargeting": [
{
"countryName": "<string>",
"distance_unit": "<string>",
"latitude": "<string>",
"longitude": "<string>",
"radius": 123
}
],
"interests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"narrowInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"furtherInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"targetLocales": [123],
"audienceId": ["<string>"],
"excludedAudienceIds": ["<string>"],
"manualPlacements": True,
"facebook_positions": ["<string>"],
"instagram_positions": ["<string>"],
"messenger_positions": ["<string>"],
"userDevices": ["<string>"],
"userOS": ["<string>"],
"campaignType": "<string>",
"images": [{ "url": "<string>" }],
"videos": [
{
"video_id": "<string>",
"thumbnail_url": "<string>"
}
],
"primaryText": [{ "text": "<string>" }],
"headlines": [{ "text": "<string>" }],
"leadsFormId": "<string>",
"callToAction": "<string>"
}
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({
userId: '<string>',
campaignName: '<string>',
status: '<string>',
budget: 123,
startDate: '<string>',
endDate: '<string>',
url: '<string>',
specialAdCategories: ['<string>'],
specialAdCountries: ['<string>'],
utmParams: '<string>',
adSetName: '<string>',
gender: '<string>',
ages: {minAge: 123, maxAge: 123},
locations: [
{
id: '<string>',
type: '<string>',
distance_unit: '<string>',
radius: 123,
countryCode: '<string>',
countryName: '<string>'
}
],
excludedLocations: [
{
id: '<string>',
type: '<string>',
distance_unit: '<string>',
radius: 123,
countryCode: '<string>',
countryName: '<string>'
}
],
proximityTargeting: [
{
countryName: '<string>',
distance_unit: '<string>',
latitude: '<string>',
longitude: '<string>',
radius: 123
}
],
interests: [{id: '<string>', name: '<string>', type: '<string>'}],
narrowInterests: [{id: '<string>', name: '<string>', type: '<string>'}],
furtherInterests: [{id: '<string>', name: '<string>', type: '<string>'}],
targetLocales: [123],
audienceId: ['<string>'],
excludedAudienceIds: ['<string>'],
manualPlacements: true,
facebook_positions: ['<string>'],
instagram_positions: ['<string>'],
messenger_positions: ['<string>'],
userDevices: ['<string>'],
userOS: ['<string>'],
campaignType: '<string>',
images: [{url: '<string>'}],
videos: [{video_id: '<string>', thumbnail_url: '<string>'}],
primaryText: [{text: '<string>'}],
headlines: [{text: '<string>'}],
leadsFormId: '<string>',
callToAction: '<string>'
})
};
fetch('https://public.plai.io/meta/create_campaign', 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://public.plai.io/meta/create_campaign",
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([
'userId' => '<string>',
'campaignName' => '<string>',
'status' => '<string>',
'budget' => 123,
'startDate' => '<string>',
'endDate' => '<string>',
'url' => '<string>',
'specialAdCategories' => [
'<string>'
],
'specialAdCountries' => [
'<string>'
],
'utmParams' => '<string>',
'adSetName' => '<string>',
'gender' => '<string>',
'ages' => [
'minAge' => 123,
'maxAge' => 123
],
'locations' => [
[
'id' => '<string>',
'type' => '<string>',
'distance_unit' => '<string>',
'radius' => 123,
'countryCode' => '<string>',
'countryName' => '<string>'
]
],
'excludedLocations' => [
[
'id' => '<string>',
'type' => '<string>',
'distance_unit' => '<string>',
'radius' => 123,
'countryCode' => '<string>',
'countryName' => '<string>'
]
],
'proximityTargeting' => [
[
'countryName' => '<string>',
'distance_unit' => '<string>',
'latitude' => '<string>',
'longitude' => '<string>',
'radius' => 123
]
],
'interests' => [
[
'id' => '<string>',
'name' => '<string>',
'type' => '<string>'
]
],
'narrowInterests' => [
[
'id' => '<string>',
'name' => '<string>',
'type' => '<string>'
]
],
'furtherInterests' => [
[
'id' => '<string>',
'name' => '<string>',
'type' => '<string>'
]
],
'targetLocales' => [
123
],
'audienceId' => [
'<string>'
],
'excludedAudienceIds' => [
'<string>'
],
'manualPlacements' => true,
'facebook_positions' => [
'<string>'
],
'instagram_positions' => [
'<string>'
],
'messenger_positions' => [
'<string>'
],
'userDevices' => [
'<string>'
],
'userOS' => [
'<string>'
],
'campaignType' => '<string>',
'images' => [
[
'url' => '<string>'
]
],
'videos' => [
[
'video_id' => '<string>',
'thumbnail_url' => '<string>'
]
],
'primaryText' => [
[
'text' => '<string>'
]
],
'headlines' => [
[
'text' => '<string>'
]
],
'leadsFormId' => '<string>',
'callToAction' => '<string>'
]),
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://public.plai.io/meta/create_campaign"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"campaignName\": \"<string>\",\n \"status\": \"<string>\",\n \"budget\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"url\": \"<string>\",\n \"specialAdCategories\": [\n \"<string>\"\n ],\n \"specialAdCountries\": [\n \"<string>\"\n ],\n \"utmParams\": \"<string>\",\n \"adSetName\": \"<string>\",\n \"gender\": \"<string>\",\n \"ages\": {\n \"minAge\": 123,\n \"maxAge\": 123\n },\n \"locations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"excludedLocations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"proximityTargeting\": [\n {\n \"countryName\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"latitude\": \"<string>\",\n \"longitude\": \"<string>\",\n \"radius\": 123\n }\n ],\n \"interests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"narrowInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"furtherInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"targetLocales\": [\n 123\n ],\n \"audienceId\": [\n \"<string>\"\n ],\n \"excludedAudienceIds\": [\n \"<string>\"\n ],\n \"manualPlacements\": true,\n \"facebook_positions\": [\n \"<string>\"\n ],\n \"instagram_positions\": [\n \"<string>\"\n ],\n \"messenger_positions\": [\n \"<string>\"\n ],\n \"userDevices\": [\n \"<string>\"\n ],\n \"userOS\": [\n \"<string>\"\n ],\n \"campaignType\": \"<string>\",\n \"images\": [\n {\n \"url\": \"<string>\"\n }\n ],\n \"videos\": [\n {\n \"video_id\": \"<string>\",\n \"thumbnail_url\": \"<string>\"\n }\n ],\n \"primaryText\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"headlines\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"leadsFormId\": \"<string>\",\n \"callToAction\": \"<string>\"\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://public.plai.io/meta/create_campaign")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"campaignName\": \"<string>\",\n \"status\": \"<string>\",\n \"budget\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"url\": \"<string>\",\n \"specialAdCategories\": [\n \"<string>\"\n ],\n \"specialAdCountries\": [\n \"<string>\"\n ],\n \"utmParams\": \"<string>\",\n \"adSetName\": \"<string>\",\n \"gender\": \"<string>\",\n \"ages\": {\n \"minAge\": 123,\n \"maxAge\": 123\n },\n \"locations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"excludedLocations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"proximityTargeting\": [\n {\n \"countryName\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"latitude\": \"<string>\",\n \"longitude\": \"<string>\",\n \"radius\": 123\n }\n ],\n \"interests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"narrowInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"furtherInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"targetLocales\": [\n 123\n ],\n \"audienceId\": [\n \"<string>\"\n ],\n \"excludedAudienceIds\": [\n \"<string>\"\n ],\n \"manualPlacements\": true,\n \"facebook_positions\": [\n \"<string>\"\n ],\n \"instagram_positions\": [\n \"<string>\"\n ],\n \"messenger_positions\": [\n \"<string>\"\n ],\n \"userDevices\": [\n \"<string>\"\n ],\n \"userOS\": [\n \"<string>\"\n ],\n \"campaignType\": \"<string>\",\n \"images\": [\n {\n \"url\": \"<string>\"\n }\n ],\n \"videos\": [\n {\n \"video_id\": \"<string>\",\n \"thumbnail_url\": \"<string>\"\n }\n ],\n \"primaryText\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"headlines\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"leadsFormId\": \"<string>\",\n \"callToAction\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.plai.io/meta/create_campaign")
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 \"userId\": \"<string>\",\n \"campaignName\": \"<string>\",\n \"status\": \"<string>\",\n \"budget\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"url\": \"<string>\",\n \"specialAdCategories\": [\n \"<string>\"\n ],\n \"specialAdCountries\": [\n \"<string>\"\n ],\n \"utmParams\": \"<string>\",\n \"adSetName\": \"<string>\",\n \"gender\": \"<string>\",\n \"ages\": {\n \"minAge\": 123,\n \"maxAge\": 123\n },\n \"locations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"excludedLocations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"proximityTargeting\": [\n {\n \"countryName\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"latitude\": \"<string>\",\n \"longitude\": \"<string>\",\n \"radius\": 123\n }\n ],\n \"interests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"narrowInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"furtherInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"targetLocales\": [\n 123\n ],\n \"audienceId\": [\n \"<string>\"\n ],\n \"excludedAudienceIds\": [\n \"<string>\"\n ],\n \"manualPlacements\": true,\n \"facebook_positions\": [\n \"<string>\"\n ],\n \"instagram_positions\": [\n \"<string>\"\n ],\n \"messenger_positions\": [\n \"<string>\"\n ],\n \"userDevices\": [\n \"<string>\"\n ],\n \"userOS\": [\n \"<string>\"\n ],\n \"campaignType\": \"<string>\",\n \"images\": [\n {\n \"url\": \"<string>\"\n }\n ],\n \"videos\": [\n {\n \"video_id\": \"<string>\",\n \"thumbnail_url\": \"<string>\"\n }\n ],\n \"primaryText\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"headlines\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"leadsFormId\": \"<string>\",\n \"callToAction\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"results": {
"success": true,
"campaign": {
"leadFormId": "<string>",
"campaignId": "<string>",
"adId": [
"<string>"
],
"adGroupId": "<string>"
},
"error": "<string>"
}
}Leads
Dynamic Ad
This endpoint is used to create a campaign for leads dynamic ads. Lead generation ads are ad campaigns designed to collect contact information (like name, email, phone number) directly from users on Meta platforms without needing them to leave the app.
Dynamic Ad
curl --request POST \
--url https://public.plai.io/meta/create_campaign \
--header 'Content-Type: application/json' \
--header 'x-api-key: <api-key>' \
--data '
{
"userId": "<string>",
"campaignName": "<string>",
"status": "<string>",
"budget": 123,
"startDate": "<string>",
"endDate": "<string>",
"url": "<string>",
"specialAdCategories": [
"<string>"
],
"specialAdCountries": [
"<string>"
],
"utmParams": "<string>",
"adSetName": "<string>",
"gender": "<string>",
"ages": {
"minAge": 123,
"maxAge": 123
},
"locations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"excludedLocations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"proximityTargeting": [
{
"countryName": "<string>",
"distance_unit": "<string>",
"latitude": "<string>",
"longitude": "<string>",
"radius": 123
}
],
"interests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"narrowInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"furtherInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"targetLocales": [
123
],
"audienceId": [
"<string>"
],
"excludedAudienceIds": [
"<string>"
],
"manualPlacements": true,
"facebook_positions": [
"<string>"
],
"instagram_positions": [
"<string>"
],
"messenger_positions": [
"<string>"
],
"userDevices": [
"<string>"
],
"userOS": [
"<string>"
],
"campaignType": "<string>",
"images": [
{
"url": "<string>"
}
],
"videos": [
{
"video_id": "<string>",
"thumbnail_url": "<string>"
}
],
"primaryText": [
{
"text": "<string>"
}
],
"headlines": [
{
"text": "<string>"
}
],
"leadsFormId": "<string>",
"callToAction": "<string>"
}
'import requests
url = "https://public.plai.io/meta/create_campaign"
payload = {
"userId": "<string>",
"campaignName": "<string>",
"status": "<string>",
"budget": 123,
"startDate": "<string>",
"endDate": "<string>",
"url": "<string>",
"specialAdCategories": ["<string>"],
"specialAdCountries": ["<string>"],
"utmParams": "<string>",
"adSetName": "<string>",
"gender": "<string>",
"ages": {
"minAge": 123,
"maxAge": 123
},
"locations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"excludedLocations": [
{
"id": "<string>",
"type": "<string>",
"distance_unit": "<string>",
"radius": 123,
"countryCode": "<string>",
"countryName": "<string>"
}
],
"proximityTargeting": [
{
"countryName": "<string>",
"distance_unit": "<string>",
"latitude": "<string>",
"longitude": "<string>",
"radius": 123
}
],
"interests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"narrowInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"furtherInterests": [
{
"id": "<string>",
"name": "<string>",
"type": "<string>"
}
],
"targetLocales": [123],
"audienceId": ["<string>"],
"excludedAudienceIds": ["<string>"],
"manualPlacements": True,
"facebook_positions": ["<string>"],
"instagram_positions": ["<string>"],
"messenger_positions": ["<string>"],
"userDevices": ["<string>"],
"userOS": ["<string>"],
"campaignType": "<string>",
"images": [{ "url": "<string>" }],
"videos": [
{
"video_id": "<string>",
"thumbnail_url": "<string>"
}
],
"primaryText": [{ "text": "<string>" }],
"headlines": [{ "text": "<string>" }],
"leadsFormId": "<string>",
"callToAction": "<string>"
}
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({
userId: '<string>',
campaignName: '<string>',
status: '<string>',
budget: 123,
startDate: '<string>',
endDate: '<string>',
url: '<string>',
specialAdCategories: ['<string>'],
specialAdCountries: ['<string>'],
utmParams: '<string>',
adSetName: '<string>',
gender: '<string>',
ages: {minAge: 123, maxAge: 123},
locations: [
{
id: '<string>',
type: '<string>',
distance_unit: '<string>',
radius: 123,
countryCode: '<string>',
countryName: '<string>'
}
],
excludedLocations: [
{
id: '<string>',
type: '<string>',
distance_unit: '<string>',
radius: 123,
countryCode: '<string>',
countryName: '<string>'
}
],
proximityTargeting: [
{
countryName: '<string>',
distance_unit: '<string>',
latitude: '<string>',
longitude: '<string>',
radius: 123
}
],
interests: [{id: '<string>', name: '<string>', type: '<string>'}],
narrowInterests: [{id: '<string>', name: '<string>', type: '<string>'}],
furtherInterests: [{id: '<string>', name: '<string>', type: '<string>'}],
targetLocales: [123],
audienceId: ['<string>'],
excludedAudienceIds: ['<string>'],
manualPlacements: true,
facebook_positions: ['<string>'],
instagram_positions: ['<string>'],
messenger_positions: ['<string>'],
userDevices: ['<string>'],
userOS: ['<string>'],
campaignType: '<string>',
images: [{url: '<string>'}],
videos: [{video_id: '<string>', thumbnail_url: '<string>'}],
primaryText: [{text: '<string>'}],
headlines: [{text: '<string>'}],
leadsFormId: '<string>',
callToAction: '<string>'
})
};
fetch('https://public.plai.io/meta/create_campaign', 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://public.plai.io/meta/create_campaign",
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([
'userId' => '<string>',
'campaignName' => '<string>',
'status' => '<string>',
'budget' => 123,
'startDate' => '<string>',
'endDate' => '<string>',
'url' => '<string>',
'specialAdCategories' => [
'<string>'
],
'specialAdCountries' => [
'<string>'
],
'utmParams' => '<string>',
'adSetName' => '<string>',
'gender' => '<string>',
'ages' => [
'minAge' => 123,
'maxAge' => 123
],
'locations' => [
[
'id' => '<string>',
'type' => '<string>',
'distance_unit' => '<string>',
'radius' => 123,
'countryCode' => '<string>',
'countryName' => '<string>'
]
],
'excludedLocations' => [
[
'id' => '<string>',
'type' => '<string>',
'distance_unit' => '<string>',
'radius' => 123,
'countryCode' => '<string>',
'countryName' => '<string>'
]
],
'proximityTargeting' => [
[
'countryName' => '<string>',
'distance_unit' => '<string>',
'latitude' => '<string>',
'longitude' => '<string>',
'radius' => 123
]
],
'interests' => [
[
'id' => '<string>',
'name' => '<string>',
'type' => '<string>'
]
],
'narrowInterests' => [
[
'id' => '<string>',
'name' => '<string>',
'type' => '<string>'
]
],
'furtherInterests' => [
[
'id' => '<string>',
'name' => '<string>',
'type' => '<string>'
]
],
'targetLocales' => [
123
],
'audienceId' => [
'<string>'
],
'excludedAudienceIds' => [
'<string>'
],
'manualPlacements' => true,
'facebook_positions' => [
'<string>'
],
'instagram_positions' => [
'<string>'
],
'messenger_positions' => [
'<string>'
],
'userDevices' => [
'<string>'
],
'userOS' => [
'<string>'
],
'campaignType' => '<string>',
'images' => [
[
'url' => '<string>'
]
],
'videos' => [
[
'video_id' => '<string>',
'thumbnail_url' => '<string>'
]
],
'primaryText' => [
[
'text' => '<string>'
]
],
'headlines' => [
[
'text' => '<string>'
]
],
'leadsFormId' => '<string>',
'callToAction' => '<string>'
]),
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://public.plai.io/meta/create_campaign"
payload := strings.NewReader("{\n \"userId\": \"<string>\",\n \"campaignName\": \"<string>\",\n \"status\": \"<string>\",\n \"budget\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"url\": \"<string>\",\n \"specialAdCategories\": [\n \"<string>\"\n ],\n \"specialAdCountries\": [\n \"<string>\"\n ],\n \"utmParams\": \"<string>\",\n \"adSetName\": \"<string>\",\n \"gender\": \"<string>\",\n \"ages\": {\n \"minAge\": 123,\n \"maxAge\": 123\n },\n \"locations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"excludedLocations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"proximityTargeting\": [\n {\n \"countryName\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"latitude\": \"<string>\",\n \"longitude\": \"<string>\",\n \"radius\": 123\n }\n ],\n \"interests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"narrowInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"furtherInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"targetLocales\": [\n 123\n ],\n \"audienceId\": [\n \"<string>\"\n ],\n \"excludedAudienceIds\": [\n \"<string>\"\n ],\n \"manualPlacements\": true,\n \"facebook_positions\": [\n \"<string>\"\n ],\n \"instagram_positions\": [\n \"<string>\"\n ],\n \"messenger_positions\": [\n \"<string>\"\n ],\n \"userDevices\": [\n \"<string>\"\n ],\n \"userOS\": [\n \"<string>\"\n ],\n \"campaignType\": \"<string>\",\n \"images\": [\n {\n \"url\": \"<string>\"\n }\n ],\n \"videos\": [\n {\n \"video_id\": \"<string>\",\n \"thumbnail_url\": \"<string>\"\n }\n ],\n \"primaryText\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"headlines\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"leadsFormId\": \"<string>\",\n \"callToAction\": \"<string>\"\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://public.plai.io/meta/create_campaign")
.header("x-api-key", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"userId\": \"<string>\",\n \"campaignName\": \"<string>\",\n \"status\": \"<string>\",\n \"budget\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"url\": \"<string>\",\n \"specialAdCategories\": [\n \"<string>\"\n ],\n \"specialAdCountries\": [\n \"<string>\"\n ],\n \"utmParams\": \"<string>\",\n \"adSetName\": \"<string>\",\n \"gender\": \"<string>\",\n \"ages\": {\n \"minAge\": 123,\n \"maxAge\": 123\n },\n \"locations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"excludedLocations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"proximityTargeting\": [\n {\n \"countryName\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"latitude\": \"<string>\",\n \"longitude\": \"<string>\",\n \"radius\": 123\n }\n ],\n \"interests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"narrowInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"furtherInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"targetLocales\": [\n 123\n ],\n \"audienceId\": [\n \"<string>\"\n ],\n \"excludedAudienceIds\": [\n \"<string>\"\n ],\n \"manualPlacements\": true,\n \"facebook_positions\": [\n \"<string>\"\n ],\n \"instagram_positions\": [\n \"<string>\"\n ],\n \"messenger_positions\": [\n \"<string>\"\n ],\n \"userDevices\": [\n \"<string>\"\n ],\n \"userOS\": [\n \"<string>\"\n ],\n \"campaignType\": \"<string>\",\n \"images\": [\n {\n \"url\": \"<string>\"\n }\n ],\n \"videos\": [\n {\n \"video_id\": \"<string>\",\n \"thumbnail_url\": \"<string>\"\n }\n ],\n \"primaryText\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"headlines\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"leadsFormId\": \"<string>\",\n \"callToAction\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://public.plai.io/meta/create_campaign")
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 \"userId\": \"<string>\",\n \"campaignName\": \"<string>\",\n \"status\": \"<string>\",\n \"budget\": 123,\n \"startDate\": \"<string>\",\n \"endDate\": \"<string>\",\n \"url\": \"<string>\",\n \"specialAdCategories\": [\n \"<string>\"\n ],\n \"specialAdCountries\": [\n \"<string>\"\n ],\n \"utmParams\": \"<string>\",\n \"adSetName\": \"<string>\",\n \"gender\": \"<string>\",\n \"ages\": {\n \"minAge\": 123,\n \"maxAge\": 123\n },\n \"locations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"excludedLocations\": [\n {\n \"id\": \"<string>\",\n \"type\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"radius\": 123,\n \"countryCode\": \"<string>\",\n \"countryName\": \"<string>\"\n }\n ],\n \"proximityTargeting\": [\n {\n \"countryName\": \"<string>\",\n \"distance_unit\": \"<string>\",\n \"latitude\": \"<string>\",\n \"longitude\": \"<string>\",\n \"radius\": 123\n }\n ],\n \"interests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"narrowInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"furtherInterests\": [\n {\n \"id\": \"<string>\",\n \"name\": \"<string>\",\n \"type\": \"<string>\"\n }\n ],\n \"targetLocales\": [\n 123\n ],\n \"audienceId\": [\n \"<string>\"\n ],\n \"excludedAudienceIds\": [\n \"<string>\"\n ],\n \"manualPlacements\": true,\n \"facebook_positions\": [\n \"<string>\"\n ],\n \"instagram_positions\": [\n \"<string>\"\n ],\n \"messenger_positions\": [\n \"<string>\"\n ],\n \"userDevices\": [\n \"<string>\"\n ],\n \"userOS\": [\n \"<string>\"\n ],\n \"campaignType\": \"<string>\",\n \"images\": [\n {\n \"url\": \"<string>\"\n }\n ],\n \"videos\": [\n {\n \"video_id\": \"<string>\",\n \"thumbnail_url\": \"<string>\"\n }\n ],\n \"primaryText\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"headlines\": [\n {\n \"text\": \"<string>\"\n }\n ],\n \"leadsFormId\": \"<string>\",\n \"callToAction\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"results": {
"success": true,
"campaign": {
"leadFormId": "<string>",
"campaignId": "<string>",
"adId": [
"<string>"
],
"adGroupId": "<string>"
},
"error": "<string>"
}
}Request Body
string
required
User ID, If not already created, make a user on create user
page first. If already created,
retrieve the user ID from get profile
page.
string
required
Descriptive name for the campaign
string
default:"PAUSED"
Status of the campaignSupported values are:
ACTIVE, PAUSEDnumber
required
Campaigns daily budget amount.
string
Start Date Format:
YYYY-MM-DD, use to schedule the campaign to start at a
specific date.string
End Date Format:
YYYY-MM-DD, use to schedule the campaign to end at a
specific date.string
required
Your Website URL
string[]
Special ad categories =
HOUSING, FINANCIAL_PRODUCTS_SERVICES,
EMPLOYMENTHOUSING: Ads related to property sales, rentals, or home-related services.FINANCIAL_PRODUCTS_SERVICES: Ads promoting credit cards, loans, insurance, or other financial services.
-EMPLOYMENT: Ads offering job opportunities or recruitment-related services.
string[]
Special Ad Countries is required if specialAdCategories is provided.
US,UKstring
UTM tracking parameters template, expected variables that can be used in it:
{{campaign.id}},{{adset.id}},{{ad.id}},{{campaign.name}},{{adset.name}},{{ad.name}}Targeting Parameters
string
Name of the ad set audience
string
If Special Ad Category is provided, then age targeting will be ignored.
1 for male, 2 for female, and if you want to target all
genders skip this parameterobject
object[]
required
The locations parameter must include only locations within the country specified in the
specialAdCountries field. For example, if you set specialAdCountries to US, then all locations added must be within the United States. Adding locations from other countries will result in an error.If Audience ID is provided, then location targeting is optional
Show Location Targeting Object
Show Location Targeting Object
string
required
Facebook location ID
string
required
Location types:
country, region, zip, country_group, neighborhood, citystring
Use Distance Unit when type is
citymile or km)number
Use Radius when type is
citystring
ISO 3166-1 alpha-2 country codes e.g:
US,UKstring
Country Name
object[]
Areas where you don’t want your ads to appear. Get excluded locations data
from here
object[]
Targets people within a specific radius of a location. You have to get the
proximity targeting data on your own.
object[]
object[]
object[]
boolean
default:false
Set to
false to use Advantage+ placements (recommended).If you set to
true, you have to provide facebook_positions,
instagram_positions, messenger_positionsstring[]
Facebook ad placements =
feed, right_hand_column, marketplace,
video_feeds, story, search, instream_video, facebook_reels,
facebook_reels_overlay, profile_feed, notificationstring[]
Instagram ad placements =
stream, story, explore, explore_home,
reels, profile_feed, ig_search, profile_reelsstring[]
Messenger ad placements =
messenger_home, storystring[]
Device targeting, you have to send the device name in string array, you can
get the list of devices from
here
Make sure to choose right operating system for the device.
- for eg. If the user device is iphone, then you have to send
iosin user operating system.
string[]
Operating system targeting, you have to send the os platform in string
array, you can get the list of operating systems from
here
Dynamic Ads Parameters
string
required
For Lead Goal, campaignType is
LEAD_GENERATIONobject[]
You can add up to 10 total images and videos in one dynamic ad, atlease 1 image is required if video is not provided.
- Minimum Image Size: 400x400px
- Supported Aspect Ratios: 1:1, 16:9, 9:16
Show Image Assets Array
Show Image Assets Array
string
required
URL for image asset
object[]
object[]
You can add up to 5 primary text variations, atleast 1 primary text is
required
Show Primary Text Array
Show Primary Text Array
string
required
Main ad copy text
object[]
You can include up to 5 headline variations.
Show Headline Variations Array
Show Headline Variations Array
string
required
Headline text variation
Headline max length is 255 characters. however, for non-English
languages, the limit is determined by the number of bytes rather than
the number of visible characters
string
required
Supported call to action types are
LEARN_MORE, SIGN_UP, DOWNLOAD,
APPLY_NOW, SUBSCRIBE, GET_QUOTE, BOOK_TRAVELResponse
boolean
Indicates that the HTTP response was successful (status code 200 OK).
object
Show Results Object
Show Results Object
boolean
Indicates whether the specific operation or API action was
successful.
object
string
Error string if something went wrong