Create or update a Facebook ad set
http
PUT https://services.leadconnectorhq.com/ad-publishing/facebook/adsetsAuthorization
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
Authorization | string | Yes | Bearer token generated from the Leadway portal. See Authentication. | |
Version | string | Yes | 2021-07-28 | API version. |
Body
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
id | string | No | adset_123 | Ad set identifier |
locationId | string | Yes | loc_abc123 | Account identifier |
name | string | No | Targeting Group A | Ad set name |
pageId | string | No | 123456789 | Facebook page ID |
instagramActorId | string | No | ig_123 | Instagram actor ID |
messagingPlatforms | string | No | Messaging platforms Possible values: 'WHATSAPP', 'MESSENGER', 'INSTAGRAM_DIRECT' | |
whatsappNumber | string | No | +1234567890 | WhatsApp phone number |
audience | object | No | Targeting audience configuration including geo-accounts, locales, placements, and custom audiences | |
budget | object | No | Ad set budget config | |
conversionLocation | string | No | website | Conversion account |
customEventType | string | No | Purchase | Custom event type |
pixelId | string | No | px_123 | Conversion pixel ID |
campaignId | string | Yes | camp_123 | Parent campaign ID |
Responses
200 - Response
400 - Bad Request
json
{}422 - Unprocessable Entity
json
{}Example
curl -X PUT 'https://services.leadconnectorhq.com/ad-publishing/facebook/adsets' \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Version: 2021-07-28' \
-H 'Content-Type: application/json' \
-d '{
"id": "adset_123",
"locationId": "loc_abc123",
"name": "Targeting Group A",
"pageId": "123456789",
"instagramActorId": "ig_123",
"messagingPlatforms": "WHATSAPP",
"whatsappNumber": "+1234567890",
"conversionLocation": "website",
"customEventType": "Purchase",
"pixelId": "px_123",
"campaignId": "camp_123"
}'const response = await fetch('https://services.leadconnectorhq.com/ad-publishing/facebook/adsets', {
method: 'PUT',
headers: {
Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
Version: '2021-07-28',
'Content-Type': 'application/json',
},
body: JSON.stringify({"id": "adset_123", "locationId": "loc_abc123", "name": "Targeting Group A", "pageId": "123456789", "instagramActorId": "ig_123", "messagingPlatforms": "WHATSAPP", "whatsappNumber": "+1234567890", "conversionLocation": "website", "customEventType": "Purchase", "pixelId": "px_123", "campaignId": "camp_123"}),
});
const data = await response.json();import os, requests
response = requests.request(
'PUT',
'https://services.leadconnectorhq.com/ad-publishing/facebook/adsets',
headers={
'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
'Version': '2021-07-28',
'Content-Type': 'application/json',
},
json={"id": "adset_123", "locationId": "loc_abc123", "name": "Targeting Group A", "pageId": "123456789", "instagramActorId": "ig_123", "messagingPlatforms": "WHATSAPP", "whatsappNumber": "+1234567890", "conversionLocation": "website", "customEventType": "Purchase", "pixelId": "px_123", "campaignId": "camp_123"},
)
data = response.json()<?php
$ch = curl_init('https://services.leadconnectorhq.com/ad-publishing/facebook/adsets');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
'Version: 2021-07-28',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode({'id': 'adset_123', 'locationId': 'loc_abc123', 'name': 'Targeting Group A', 'pageId': '123456789', 'instagramActorId': 'ig_123', 'messagingPlatforms': 'WHATSAPP', 'whatsappNumber': '+1234567890', 'conversionLocation': 'website', 'customEventType': 'Purchase', 'pixelId': 'px_123', 'campaignId': 'camp_123'}),
]);
$data = json_decode(curl_exec($ch), true);