curl -X POST https://api.ayrshare.com/api/ads/facebook/boost \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": { "countries": ["US"] },
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": [1234567890, 1234567891]
}'
curl -X POST https://api.ayrshare.com/api/ads/facebook/boost \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "Nurse Practitioner Hiring",
"status": "active",
"goal": "traffic",
"callToAction": {
"type": "APPLY_NOW",
"link": "https://example.com/careers/nurse-practitioner",
"linkTitle": "Apply today"
},
"specialAdCategories": ["employment"],
"minAge": 18,
"maxAge": 65,
"locations": { "countries": ["US"] },
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z"
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/boost", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_KEY}`
},
body: JSON.stringify({
postId: "1234567890",
accountId: "1234567890",
adName: "My Ad",
status: "active",
goal: "engagement",
minAge: 18,
maxAge: 65,
locations: { countries: ["US"] },
budget: 100,
bidAmount: 1,
startDate: "2025-03-01T00:00:00Z",
endDate: "2025-03-07T23:59:59Z",
interests: [1234567890, 1234567891]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
API_KEY = "API_KEY"
url = "https://api.ayrshare.com/api/ads/facebook/boost"
payload = {
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": {"countries": ["US"]},
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": [1234567890, 1234567891]
}
response = requests.post(url, headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json=payload)
print(response.json())
<?php
$API_KEY = "API_KEY";
$payload = [
"postId" => "1234567890",
"accountId" => "1234567890",
"adName" => "My Ad",
"status" => "active",
"goal" => "engagement",
"minAge" => 18,
"maxAge" => 65,
"locations" => ["countries" => ["US"]],
"budget" => 100,
"bidAmount" => 1,
"startDate" => "2025-03-01T00:00:00Z",
"endDate" => "2025-03-07T23:59:59Z",
"interests" => [1234567890, 1234567891]
];
$ch = curl_init("https://api.ayrshare.com/api/ads/facebook/boost");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . $API_KEY
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
print_r($result);
curl_close($ch);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string API_KEY = "API_KEY";
var payload = new
{
postId = "1234567890",
accountId = "1234567890",
adName = "My Ad",
status = "active",
goal = "engagement",
minAge = 18,
maxAge = 65,
locations = new { countries = new[] { "US" } },
budget = 100,
bidAmount = 1,
startDate = "2025-03-01T00:00:00Z",
endDate = "2025-03-07T23:59:59Z",
interests = new[] { 1234567890, 1234567891 }
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", API_KEY);
var content = new StringContent(
JsonSerializer.Serialize(payload),
Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync("https://api.ayrshare.com/api/ads/facebook/boost", content);
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiKey := "API_KEY"
payload := map[string]interface{}{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": map[string]interface{}{"countries": []string{"US"}},
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": []int{1234567890, 1234567891},
}
jsonData, err := json.Marshal(payload)
if err != nil {
fmt.Println("Error marshaling JSON:", err)
return
}
req, err := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/facebook/boost", bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+apiKey)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(body))
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
public class BoostPost {
public static void main(String[] args) {
String API_KEY = "API_KEY";
String url = "https://api.ayrshare.com/api/ads/facebook/boost";
Map<String, Object> payload = new HashMap<>();
payload.put("postId", "1234567890");
payload.put("accountId", "1234567890");
payload.put("adName", "My Ad");
payload.put("status", "active");
payload.put("goal", "engagement");
payload.put("minAge", 18);
payload.put("maxAge", 65);
Map<String, Object> locations = new HashMap<>();
locations.put("countries", Arrays.asList("US"));
payload.put("locations", locations);
payload.put("budget", 100);
payload.put("bidAmount", 1);
payload.put("startDate", "2025-03-01T00:00:00Z");
payload.put("endDate", "2025-03-07T23:59:59Z");
payload.put("interests", Arrays.asList(1234567890, 1234567891));
try {
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(payload);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + API_KEY)
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'uri'
require 'json'
API_KEY = "API_KEY"
uri = URI.parse("https://api.ayrshare.com/api/ads/facebook/boost")
payload = {
postId: "1234567890",
accountId: "1234567890",
adName: "My Ad",
status: "active",
goal: "engagement",
minAge: 18,
maxAge: 65,
locations: { countries: ["US"] },
budget: 100,
bidAmount: 1,
startDate: "2025-03-01T00:00:00Z",
endDate: "2025-03-07T23:59:59Z",
interests: [1234567890, 1234567891]
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{API_KEY}"
request.body = payload.to_json
response = http.request(request)
puts response.body
{
"status": "success",
"adId": "120217670757750410",
"adName": "API Post - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
"adStatus": "active",
"bidAmount": 10,
"budget": 100,
"endDate": "2026-03-28T22:30:00Z",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement...",
"type": "engagement"
},
"interests": [
"6003195554098"
],
"locations": { "countries": ["US"] },
"maxAge": 65,
"minAge": 18,
"postId": "DE6gpw8kxlonHy2b7Lo",
"startDate": "2026-03-26T22:30:00Z"
}
{
"status": "success",
"adId": "120217670757750411",
"adName": "Nurse Practitioner Hiring - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
"adStatus": "active",
"bidAmount": 1,
"budget": 100,
"callToAction": {
"type": "APPLY_NOW",
"link": "https://example.com/careers/nurse-practitioner",
"linkTitle": "Apply today"
},
"endDate": "2025-03-07T23:59:59Z",
"goal": {
"title": "Drive Traffic",
"description": "Sends people from the boosted post to a destination off Facebook...",
"type": "traffic"
},
"locations": { "countries": ["US"] },
"maxAge": 65,
"minAge": 18,
"postId": "DE6gpw8kxlonHy2b7Lo",
"startDate": "2025-03-01T00:00:00Z"
}
{
"action": "boost post",
"status": "error",
"code": 369,
"message": "Unable to boost post. Please try again or contact us if the issue persists.",
"details": "The accountId likely does not exist. Please check the accountId and try again."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "Missing required fields: budget"
}
Facebook Ads
Boost Post
पोस्ट को Facebook के ad platform पर सबमिट करके boost करें
POST
/
ads
/
facebook
/
boost
curl -X POST https://api.ayrshare.com/api/ads/facebook/boost \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": { "countries": ["US"] },
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": [1234567890, 1234567891]
}'
curl -X POST https://api.ayrshare.com/api/ads/facebook/boost \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "Nurse Practitioner Hiring",
"status": "active",
"goal": "traffic",
"callToAction": {
"type": "APPLY_NOW",
"link": "https://example.com/careers/nurse-practitioner",
"linkTitle": "Apply today"
},
"specialAdCategories": ["employment"],
"minAge": 18,
"maxAge": 65,
"locations": { "countries": ["US"] },
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z"
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/boost", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_KEY}`
},
body: JSON.stringify({
postId: "1234567890",
accountId: "1234567890",
adName: "My Ad",
status: "active",
goal: "engagement",
minAge: 18,
maxAge: 65,
locations: { countries: ["US"] },
budget: 100,
bidAmount: 1,
startDate: "2025-03-01T00:00:00Z",
endDate: "2025-03-07T23:59:59Z",
interests: [1234567890, 1234567891]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
API_KEY = "API_KEY"
url = "https://api.ayrshare.com/api/ads/facebook/boost"
payload = {
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": {"countries": ["US"]},
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": [1234567890, 1234567891]
}
response = requests.post(url, headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json=payload)
print(response.json())
<?php
$API_KEY = "API_KEY";
$payload = [
"postId" => "1234567890",
"accountId" => "1234567890",
"adName" => "My Ad",
"status" => "active",
"goal" => "engagement",
"minAge" => 18,
"maxAge" => 65,
"locations" => ["countries" => ["US"]],
"budget" => 100,
"bidAmount" => 1,
"startDate" => "2025-03-01T00:00:00Z",
"endDate" => "2025-03-07T23:59:59Z",
"interests" => [1234567890, 1234567891]
];
$ch = curl_init("https://api.ayrshare.com/api/ads/facebook/boost");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . $API_KEY
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
print_r($result);
curl_close($ch);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string API_KEY = "API_KEY";
var payload = new
{
postId = "1234567890",
accountId = "1234567890",
adName = "My Ad",
status = "active",
goal = "engagement",
minAge = 18,
maxAge = 65,
locations = new { countries = new[] { "US" } },
budget = 100,
bidAmount = 1,
startDate = "2025-03-01T00:00:00Z",
endDate = "2025-03-07T23:59:59Z",
interests = new[] { 1234567890, 1234567891 }
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", API_KEY);
var content = new StringContent(
JsonSerializer.Serialize(payload),
Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync("https://api.ayrshare.com/api/ads/facebook/boost", content);
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiKey := "API_KEY"
payload := map[string]interface{}{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": map[string]interface{}{"countries": []string{"US"}},
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": []int{1234567890, 1234567891},
}
jsonData, err := json.Marshal(payload)
if err != nil {
fmt.Println("Error marshaling JSON:", err)
return
}
req, err := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/facebook/boost", bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+apiKey)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(body))
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
public class BoostPost {
public static void main(String[] args) {
String API_KEY = "API_KEY";
String url = "https://api.ayrshare.com/api/ads/facebook/boost";
Map<String, Object> payload = new HashMap<>();
payload.put("postId", "1234567890");
payload.put("accountId", "1234567890");
payload.put("adName", "My Ad");
payload.put("status", "active");
payload.put("goal", "engagement");
payload.put("minAge", 18);
payload.put("maxAge", 65);
Map<String, Object> locations = new HashMap<>();
locations.put("countries", Arrays.asList("US"));
payload.put("locations", locations);
payload.put("budget", 100);
payload.put("bidAmount", 1);
payload.put("startDate", "2025-03-01T00:00:00Z");
payload.put("endDate", "2025-03-07T23:59:59Z");
payload.put("interests", Arrays.asList(1234567890, 1234567891));
try {
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(payload);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + API_KEY)
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'uri'
require 'json'
API_KEY = "API_KEY"
uri = URI.parse("https://api.ayrshare.com/api/ads/facebook/boost")
payload = {
postId: "1234567890",
accountId: "1234567890",
adName: "My Ad",
status: "active",
goal: "engagement",
minAge: 18,
maxAge: 65,
locations: { countries: ["US"] },
budget: 100,
bidAmount: 1,
startDate: "2025-03-01T00:00:00Z",
endDate: "2025-03-07T23:59:59Z",
interests: [1234567890, 1234567891]
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{API_KEY}"
request.body = payload.to_json
response = http.request(request)
puts response.body
{
"status": "success",
"adId": "120217670757750410",
"adName": "API Post - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
"adStatus": "active",
"bidAmount": 10,
"budget": 100,
"endDate": "2026-03-28T22:30:00Z",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement...",
"type": "engagement"
},
"interests": [
"6003195554098"
],
"locations": { "countries": ["US"] },
"maxAge": 65,
"minAge": 18,
"postId": "DE6gpw8kxlonHy2b7Lo",
"startDate": "2026-03-26T22:30:00Z"
}
{
"status": "success",
"adId": "120217670757750411",
"adName": "Nurse Practitioner Hiring - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
"adStatus": "active",
"bidAmount": 1,
"budget": 100,
"callToAction": {
"type": "APPLY_NOW",
"link": "https://example.com/careers/nurse-practitioner",
"linkTitle": "Apply today"
},
"endDate": "2025-03-07T23:59:59Z",
"goal": {
"title": "Drive Traffic",
"description": "Sends people from the boosted post to a destination off Facebook...",
"type": "traffic"
},
"locations": { "countries": ["US"] },
"maxAge": 65,
"minAge": 18,
"postId": "DE6gpw8kxlonHy2b7Lo",
"startDate": "2025-03-01T00:00:00Z"
}
{
"action": "boost post",
"status": "error",
"code": 369,
"message": "Unable to boost post. Please try again or contact us if the issue persists.",
"details": "The accountId likely does not exist. Please check the accountId and try again."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "Missing required fields: budget"
}
एक ad बनाने के लिए मौजूदा Facebook पोस्ट को boost करें।
यह endpoint आपको कस्टम targeting, बजट और scheduling parameters के साथ आपके organic पोस्ट्स को paid विज्ञापनों में परिवर्तित करने की अनुमति देता है।
- Budget और bid राशियाँ USD में अधिकतम दो दशमलव स्थानों तक निर्दिष्ट की जानी चाहिए।
- Facebook की आवश्यकता को पूरा करने के लिए ad कम से कम 30 घंटे चलना चाहिए।
- Targeting के लिए interest ID खोजने के लिए आप interests endpoint का उपयोग कर सकते हैं।
- Facebook को boosted पोस्ट्स की समीक्षा और अनुमोदन में 24 घंटे तक लग सकते हैं।
- यदि
fbPostIdका सीधे उपयोग कर रहे हैं (AyrsharepostIdके बजाय), तो सुनिश्चित करें कि यह एक वैध Facebook post ID है। - अगर Facebook द्वारा campaign बनाए जाने के बाद (creative, ad set या ad चरण पर) कोई boost विफल हो जाता है, तो हम उस campaign को हटाने की कोशिश करते हैं। अगर हटाना भी विफल हो जाता है, तो खाली campaign आपके ad account में बना रहता है। आप इसे Ads Manager में ढूंढकर हटा सकते हैं।
जब तक ये दोनों शर्तें पूरी नहीं होतीं, Meta विज्ञापन को अस्वीकार कर देता है:
- विज्ञापन खाते में भुगतान का तरीका। Meta के बिलिंग और भुगतान में एक भुगतान तरीका जोड़ें और उसे उस विज्ञापन खाते से जोड़ें जिसे आप
accountIdमें भेजते हैं। केवल बिज़नेस पोर्टफ़ोलियो में सहेजा गया भुगतान तरीका पर्याप्त नहीं है। - व्यक्तिगत विज्ञापन चालू हों (EU, EEA और स्विट्ज़रलैंड)। यदि आपके Facebook Page से लिंक किए गए Facebook या Instagram खाते के स्वामी ने कम व्यक्तिगत विज्ञापन देखना चुना है, या बिना विज्ञापनों के Meta इस्तेमाल करने की सदस्यता ली है, तो Meta उस खाते या Page को विज्ञापन चलाने नहीं देता। स्वामी Accounts Center → विज्ञापन प्राथमिकताएँ → विज्ञापन अनुभव में फिर से व्यक्तिगत विज्ञापन चुन सकते हैं या सदस्यता रद्द कर सकते हैं। और जानें.
Ad Goals
प्रत्येक ad का एक goal होना चाहिए। Goal यह निर्धारित करता है कि ad को display के लिए किस प्रकार optimize किया जाएगा।engagement: यह goal engagement बढ़ाने का प्रयास करता है और साथ ही यह सुनिश्चित करता है कि ad अधिकतम संख्या में unique उपयोगकर्ताओं तक पहुँचे। यह visibility को engagement के साथ संतुलित करता है, ad को अधिक से अधिक विभिन्न लोगों को दिखाता है जो इसके साथ interact कर सकते हैं।interactions: ad पर interactions जैसे likes, comments, और shares को बढ़ाने के लिए डिज़ाइन किया गया। Facebook उन उपयोगकर्ताओं को ad दिखाने को प्राथमिकता देता है जिनके इसके साथ engage होने की सबसे अधिक संभावना है।awareness_views: ad को दिखाए जाने की अधिकतम संख्या के माध्यम से ब्रांड जागरूकता बढ़ाने पर केंद्रित है। यह unique reach की परवाह किए बिना, बजट के भीतर ad को अधिक से अधिक बार दिखाने को प्राथमिकता देता है।awareness_audience: ad को देखने वाले unique लोगों की संख्या को अधिकतम करके ब्रांड जागरूकता बढ़ाने का लक्ष्य रखता है। यह सुनिश्चित करता है कि ad अधिक से अधिक विभिन्न उपयोगकर्ताओं तक पहुँचे और एक ही audience को कई बार दिखाने के बजाय unique audience के आकार को अधिकतम करे।traffic: लोगों को Facebook से बाहर आपकी चुनी हुई destination पर भेजता है, जैसे आपकी वेबसाइट, कोई landing page, या कोई job posting। Facebook on-platform engagement के बजाय link clicks के लिए optimize करता है। यह एकमात्र goal है जोcallToActionबटन का समर्थन करता है।
Header Parameters
Body Parameters
string
आवश्यक
उस Facebook ad account की ID जिस पर पोस्ट को boost करना है। Account ID को
ad accounts endpoint से प्राप्त किया जा सकता है।
string
आवश्यक
आपके ad का नाम (Facebook Ad Manager में दिखाई देता है)
{adName} - {postId or fbPostId} - {current date} फ़ॉर्मैट के साथ।number
आवश्यक
USD में अधिकतम bid राशि। न्यूनतम bid राशि $1.00 है।
number
आवश्यक
USD में दैनिक बजट। न्यूनतम बजट $1.00 है।
string
आवश्यक
Boost करने के लिए पोस्ट की Facebook social post ID, जो आपको
सीधे Facebook पर बनाए गए पोस्ट से एक ad बनाने की अनुमति देती है। यह Facebook पर पोस्ट की ID है,
Ayrshare की नहीं। यदि
postId सेट नहीं है तो आवश्यक है।string
डिफ़ॉल्ट:"engagement"
आवश्यक
ad का goal। मान:
engagement, interactions, awareness_views,
awareness_audience, और traffic। अधिक जानकारी के लिए ऊपर ad goals details देखें।object
arrays के object के साथ ad locations को target करें:
countries, regions, cities।
ऐसा object जिसमें कोई देश, क्षेत्र या शहर नहीं दिया गया हो, जैसे {}, code 101 के साथ अस्वीकार कर दिया जाता है; US को target करने के लिए locations को छोड़ दें।दिखाएं child attributes
दिखाएं child attributes
array
देश कोड की सूची।
{
"countries": ["US", "CA"]
}
array
Regions के लिए Facebook का region
key मान आवश्यक है। अधिक जानकारी के लिए regions endpoint देखें।{
"regions": [{ "key": "3886" }]
}
array
Cities के लिए आवश्यक:
key (Facebook से), radius, और distance_unit।
radius शहर के आस-पास की दूरी है: 10–50 miles या 17–80 kilometers।
distance_unit mile या kilometer है।
अधिक जानकारी के लिए cities endpoint देखें।{
"cities": [
{ "key": "2420605", "radius": 25, "distance_unit": "mile" }
]
}
string
आवश्यक
Boost करने के लिए पोस्ट की Ayrshare post ID। यदि
fbPostId सेट नहीं है तो आवश्यक है।string
डिफ़ॉल्ट:"active"
आवश्यक
ad का status। मान:
active और paused।आप बाद में update ad endpoint का उपयोग करके ad का status बदल सकते हैं।boolean
डिफ़ॉल्ट:false
Meta के campaign-level ad set budget sharing को नियंत्रित करता है।
Meta अब campaign-level बजट के बिना बनाए गए हर campaign पर इस wire field की आवश्यकता रखता है, इसलिए Ayrshare इसे हमेशा भेजता है — backward compatibility के लिए डिफ़ॉल्ट
false है।Meta को समग्र प्रदर्शन को optimize करने के लिए एक ही campaign में अन्य ad sets के बीच ad set के बजट का लगभग 20% साझा करने देने के लिए true पर सेट करें। विवरण के लिए Meta का ad campaign group reference देखें।object
Boosted पोस्ट में एक call-to-action बटन जोड़ें, जैसे Apply Now या Shop Now। बटन
link में आपके द्वारा दिया गया URL खोलता है, या destination के साथ, इसके बजाय एक Messenger, WhatsApp या Instagram Direct chat खोलता है (लिंक के बजाय बातचीत खोलें देखें)।{
"callToAction": {
"type": "APPLY_NOW",
"link": "https://www.mysite.com/careers/social-media-manager",
"linkTitle": "Social Media Manager"
}
}
दिखाएं child attributes
दिखाएं child attributes
string
आवश्यक
बटन का label। मान:
LEARN_MORE, APPLY_NOW, SIGN_UP, SHOP_NOW, BOOK_TRAVEL,
GET_QUOTE, CONTACT_US, DOWNLOAD, और SUBSCRIBE।इनपुट में case-insensitive है, इसलिए apply_now, Apply_Now, और APPLY_NOW सभी स्वीकार किए जाते हैं।
destination के साथ, इसके बजाय messaging बटन का उपयोग करें: MESSAGE_PAGE, WHATSAPP_MESSAGE, या
INSTAGRAM_MESSAGE।string
वह destination जिसे बटन खोलता है। एक absolute
http या https URL होना चाहिए। Relative paths,
mailto: लिंक, और malformed URLs अस्वीकार कर दिए जाते हैं। जब तक destination सेट न हो, यह आवश्यक है।string
बटन के साथ प्रदर्शित होने वाली वैकल्पिक headline।
string
लिंक के बजाय एक chat खोलें:
messenger, whatsapp, या instagramDm। केवल nested form में। देखें
लिंक के बजाय बातचीत खोलें।लिंक खोलने वाला
callToAction केवल traffic ad goal के साथ समर्थित है। destination वाला बटन इसके बजाय engagement या interactions का उपयोग करता है, जैसा कि लिंक के बजाय बातचीत खोलें में बताया गया है।
लिंक बटन को engagement, interactions, awareness_views, या awareness_audience के साथ भेजने पर compatible goals के नाम बताते हुए code: 101 के साथ 400 लौटाया जाता है।
पहले यह मान किसी भी goal पर स्वीकार कर लिया जाता था और फिर चुपचाप नज़रअंदाज़ कर दिया जाता था, जिससे बिना बटन वाला ad बनता था।callToAction.link destination URL प्रदान करता है। जब Meta मौजूदा पोस्ट पर call to action को बटन के रूप में render करता है, तो urlTags उस बटन के लिंक में जुड़ जाते हैं। बिना callToAction के goal: "traffic" की अनुमति है और यह बिना बटन वाला traffic ad बनाता है।आपके द्वारा भेजा गया callToAction boost प्रतिक्रिया में type को upper-case करके वापस लौटाया जाता है — Post Boosted with a Call to Action उदाहरण देखें — और बाद में ad पर Get Boosted Ads द्वारा भी लौटाया जाता है।लिंक के बजाय Messenger, WhatsApp या Instagram Direct chat खोलने के लिए, लिंक के बजाय बातचीत खोलें देखें।object
Facebook Pixel का उपयोग करके ad को track करें।
दिखाएं child attributes
दिखाएं child attributes
number
आवश्यक
Ad को track करने के लिए Facebook Pixel की ID।
{
"pixelId": 1234567890
}
array
ad URL में UTM tags जोड़ें।उदाहरण के लिए यदि linking URL
{
"urlTags": ["utm_source=ayrshare", "utm_medium=social", "utm_campaign=ayrshare-social"]
}
https://www.mysite.com/my-post है और जोड़े गए URL tags हैं:utm_source=ayrshare, utm_medium=social, और utm_campaign=ayrshare-social।Ad URL होगा:
https://www.mysite.com/my-post?utm_source=ayrshare&utm_medium=social&utm_campaign=ayrshare-social।array
Meta special ad categories में विज्ञापनदाताओं से अपनी campaign category स्वयं-पहचान करने की आवश्यकता रखता है।यदि आपका व्यवसाय इनमें से किसी एक श्रेणी में है, तो अपनी पोस्ट को boost करते समय आपको उपयुक्त श्रेणी चुननी होगी।निम्नलिखित मान समर्थित हैं:
housing: ऐसे ads जो आवास के अवसर या संबंधित सेवा को promote करते हैं या सीधे लिंक करते हैं, जिनमें घर या अपार्टमेंट की बिक्री या किराए, homeowners insurance, mortgage insurance, mortgage loans, housing repairs और home equity या appraisal सेवाओं के लिए listings शामिल हैं, लेकिन इन्हीं तक सीमित नहीं हैं।financial_product_services: ऐसे ads जो credit सहित financial products और services offer को promote करते हैं या सीधे लिंक करते हैं।financial_products_servicesएक समतुल्य spelling के रूप में स्वीकार किया जाता है, औरcreditइस श्रेणी के Meta के पुराने नाम के रूप में स्वीकार किया जाता है — तीनों Meta तक एक ही श्रेणी के रूप में पहुँचते हैं, इसलिए आपके पास जो भी पहले से हो, वही भेजें।employment: ऐसे ads जो किसी employment अवसर को promote करते हैं या सीधे लिंक करते हैं, जिसमें part- या full-time jobs, internships या professional certification programs शामिल हैं, लेकिन इन्हीं तक सीमित नहीं हैं। इस श्रेणी में आने वाले संबंधित ads में किसी विशिष्ट नौकरी की पेशकश की परवाह किए बिना, job boards या fairs, aggregation services, या किसी कंपनी द्वारा प्रदान किए जा सकने वाले perks का विवरण देने वाले ads के promotions शामिल हैं।none: डिफ़ॉल्ट। घोषित करता है कि campaign किसी भी special ad category में नहीं है। इसे स्पष्ट रूप से भेजनाspecialAdCategoriesको पूरी तरह छोड़ देने के बराबर है, और इसे इसलिए स्वीकार किया जाता है ताकि हमेशा यह फ़ील्ड भेजने वाला caller बिना special-casing के “कोई श्रेणी नहीं” कह सके।issues_elections_politics: ऐसे ads जो सार्वजनिक पद के लिए उम्मीदवार, राजनीतिक शख्सियत, राजनीतिक दल द्वारा, उनकी ओर से या उनके बारे में बनाए गए हैं या सार्वजनिक पद के लिए चुनाव के परिणाम की वकालत करते हैं। इसमें किसी भी चुनाव, referendum या ballot initiative के बारे में ads भी शामिल हैं, जिनमें “Go out and vote” चुनाव अभियान शामिल हैं। जहाँ ad रखा जा रहा है वहाँ राजनीतिक विज्ञापन के रूप में विनियमित ads या सामाजिक मुद्दों के बारे में ads। यदि issues, elections, या politics का चयन कर रहे हैं, तो आपको उस देश का चयन करना होगा जिसमें आप ये ads चलाना चाहते हैं। आपको निर्दिष्ट देश में सामाजिक मुद्दों, चुनावों, या राजनीति के बारे में ads चलाने के लिए अधिकृत होना आवश्यक है।
400 और code: 101 के साथ अस्वीकार किया जाता है। पहले unrecognized मान को चुपचाप हटा दिया जाता था और campaign uncategorized के रूप में बना दी जाती थी, इसलिए एक typo से कोई regulated ad बिना किसी घोषित श्रेणी के चलता रह जाता था।उस error message में स्वीकृत मानों की सूची Meta के upper-case रूप में लिखी होती है और ऊपर बताई गई वैकल्पिक spellings के नाम भी देती है, इसलिए वह NONE, HOUSING, FINANCIAL_PRODUCTS_SERVICES, EMPLOYMENT, ISSUES_ELECTIONS_POLITICS, FINANCIAL_PRODUCT_SERVICES, CREDIT के रूप में पढ़ी जाती है। ये यहाँ सूचीबद्ध वही पाँच श्रेणियाँ हैं — FINANCIAL_PRODUCT_SERVICES और CREDIT financial_product_services के समतुल्य हैं, अतिरिक्त श्रेणियाँ नहीं। यही message interests endpoint द्वारा भी लौटाया जाता है।किसी श्रेणी को दोहराना, या एक ही श्रेणी की दो spellings भेजना जैसे ["credit", "financial_product_services"], स्वीकार किया जाता है और Meta तक पहुँचने से पहले एक ही श्रेणी में समेट दिया जाता है। खाली मान 400 और code: 101 के साथ अस्वीकार किया जाता है।इन श्रेणियों में से किसी एक के लिए Meta द्वारा अनुमत interest ID खोजने के लिए, वही मान interests endpoint को पास करें।Meta को उन देशों की भी जानकारी चाहिए जिनमें special category ad चलता है। Ayrshare इन्हें locations से लेता है: आपके द्वारा सूचीबद्ध देश, साथ ही हर region और city का देश। इसलिए UK के किसी city को target करने वाला housing boost आपके request में कुछ भी अतिरिक्त जोड़े बिना UK के लिए set up हो जाता है। locations के बिना ad US में चलता है, और campaign US के लिए set up होता है।Meta इन categories के लिए हर city के आसपास एक न्यूनतम radius भी तय करता है। 17 किलोमीटर radius वाले एक UK city को #2909039 के साथ अस्वीकार कर दिया गया, जो कम से कम 25 किलोमीटर (15 मील) की मांग करता है, इसलिए 25 किलोमीटर या उससे अधिक का उपयोग करें।Meta उन विज्ञापनदाताओं से आवश्यकता रखता है जिन्होंने अपनी campaign category स्वयं-पहचानी है।
Meta इस प्रकार के ads की पहचान करने के लिए मानव समीक्षकों और machine-learning का उपयोग करता है।
यदि आप हमें एक गलत
specialAdCategory भेजते हैं, तो जोखिम है कि आपके ads तब तक रोक दिए जाएंगे जब तक campaign समायोजित नहीं हो जाती।string
ISO 8601 फ़ॉर्मैट में समाप्ति तिथि और समय (start के बाद कम से कम 30 घंटे होना चाहिए), उदाहरण के लिए
2025-03-01T00:00:00Z।यदि सेट नहीं है, तो ad अनिश्चित काल तक चलेगा और उसकी end date ongoing होगी।object
countries, regions, और cities के arrays वाले object का उपयोग करके locations को exclude करें।दिखाएं child attributes
दिखाएं child attributes
array
Exclude करने के लिए देश कोड की सूची।
{
"countries": ["US", "CA"]
}
array
Regions के लिए Facebook का region
key मान आवश्यक है। अधिक जानकारी के लिए regions endpoint देखें।{
"regions": [{ "key": "3886" }]
}
array
Cities के लिए आवश्यक:
key (Facebook से), radius, और distance_unit।
radius शहर के आस-पास की दूरी है: 10–50 miles या 17–80 kilometers।
distance_unit mile या kilometer है।
अधिक जानकारी के लिए cities endpoint देखें।{
"cities": [
{ "key": "2420605", "radius": 25, "distance_unit": "mile" }
]
}
string
डिफ़ॉल्ट:"all"
Audience का लिंग। मान:
all, male, female।array
Facebook interest ids के array के रूप में ad के target interests।
number
डिफ़ॉल्ट:65
Ad को target करने के लिए अधिकतम आयु (डिफ़ॉल्ट: 65)।
number
डिफ़ॉल्ट:18
Ad को target करने के लिए न्यूनतम आयु (डिफ़ॉल्ट: 18)।
string
ISO 8601 फ़ॉर्मैट में प्रारंभ तिथि और समय, उदाहरण के लिए
2025-03-01T00:00:00Z।यदि सेट नहीं है, तो ad तुरंत शुरू हो जाएगा।string
EU देशों के लिए Digital Services Act (DSA) अनुपालन हेतु ad का beneficiary। यदि दोनों में से कोई एक प्रदान किया जाता है
तो
dsaPayor के साथ सेट किया जाना चाहिए। अधिक जानकारी के लिए कृपया हमारी DSA
guide देखें।string
EU देशों के लिए Digital Services Act (DSA) अनुपालन हेतु ad का payor। यदि दोनों में से कोई एक प्रदान किया जाता है
तो
dsaBeneficiary के साथ सेट किया जाना चाहिए।Campaign पर बजट
बजट को ad set के बजाय campaign पर रखने के लिए, nested form मेंbudget.level: "campaign" भेजें। तब ad set का अपना कोई बजट नहीं होता। यह daily और lifetime दोनों budgets के साथ काम करता है।
{
"accountId": "123456789",
"postId": "Ut1fWU6XkqkMayHGnJZ",
"goal": "traffic",
"budget": { "amount": 50, "type": "lifetime", "level": "campaign" },
"schedule": { "start": "2026-11-01T00:00:00Z", "end": "2026-11-08T00:00:00Z" },
"platformOptions": { "facebook": { "adName": "November boost", "bidAmount": 2 } }
}
budget.level:adSet(डिफ़ॉल्ट) याcampaign। campaign budget कोadSetBudgetSharingEnabledके साथ नहीं जोड़ा जा सकता। दोनों भेजने पर अनुरोध400औरcode: 101के साथ अस्वीकार कर दिया जाता है।- campaign budget के लिए response में
budgetLevel: "campaign"जुड़ता है। ad set budgetbudgetLevelनहीं लौटाता, इसलिए अनुपस्थित field कोadSetमानें। - History में, daily campaign budget वाले ad के लिए
budgetDailycampaign का daily budget दिखाता है। यदि कई ads एक ही campaign budget साझा करते हैं, तो हर ad अपना हिस्सा नहीं, बल्कि पूरा campaign budget दिखाता है। History lifetime budgets नहीं दिखाता, न campaign पर और न ad set पर। lifetime campaign budget खर्च हो जाने पर, अगले nightly update के बाद उस campaign का हर addeliveryStatus: "COMPLETED"दिखाता है, जिसमें scheduled या review में मौजूद ad भी शामिल है। rejected adREJECTEDही रहता है।
किसी मौजूदा campaign या ad set में boost करें
डिफ़ॉल्ट रूप से हर boost अपना campaign, ad set और ad बनाता है। boost को Meta में पहले से चल रहे अपने किसी campaign या ad set में जोड़ने के लिए,attachTo के साथ nested form भेजें।
attachTo.campaignId: boost उस campaign के अंदर एक नया ad set और ad बनाता है।budget,targetingऔरbidAmountसामान्य रूप से भेजें: ये नए ad set पर लागू होते हैं।attachTo.adSetId: boost उस ad set के अंदर केवल ad बनाता है। साथ मेंattachTo.campaignIdभी भेजें, यानी वह campaign जिससे ad set संबंधित है।budget,targetingऔरplatformOptions.facebook.bidAmountन भेजें: ad set अपने ही मान रखता है। इनमें से कोई भी भेजने परcode: 101के साथ400लौटता है।
{
"accountId": "123456789",
"postId": "Ut1fWU6XkqkMayHGnJZ",
"goal": "engagement",
"attachTo": { "campaignId": "120210000000000001", "adSetId": "120210000000000002" },
"platformOptions": { "facebook": { "adName": "November boost" } }
}
- campaign या ad set उसी ad account में होना चाहिए जिसकी ID
accountIdमें दी गई है, और वह किसी अन्य उपयोगकर्ता के boosts का नहीं होना चाहिए। अन्यथा अनुरोध400लौटाता है। कोई Facebook boost ऐसे campaign से भी नहीं जुड़ सकता जिसे किसी Instagram boost ने बनाया हो, और इसका उलटा भी लागू होता है। attachToकोbudget.level: "campaign",specialAdCategoriesयाadSetBudgetSharingEnabledके साथ नहीं जोड़ा जा सकता, क्योंकि ये नए campaign पर सेट होते हैं। इन्हें भेजने परcode: 101लौटता है।- boost को रोकने या सक्रिय करने से केवल वही बदलता है जो boost ने बनाया था: ad, और ad set यदि उसे boost ने बनाया था।
attachToमें आपके द्वारा दिया गया campaign या ad set अपना status बनाए रखता है। ad केवल तभी चलता है जब उसके ऊपर का campaign और ad set सक्रिय हों। यह तब भी लागू होता है जब Ayrshare आपके ads रोकता है, उदाहरण के लिए जब कोई profile हटाई जाती है। - यदि boost विफल हो जाता है, तो
attachToमें दिया गया campaign या ad set कभी नहीं हटाया जाता। - यदि आप जिस ad set से जोड़ते हैं वह ऐसे campaign में है जिसके पास बजट है (campaign budget), तो History boost को campaign budget वाले किसी भी ad की तरह रिपोर्ट करता है:
budgetDailyboost का हिस्सा नहीं, बल्कि पूरा campaign budget दिखाता है, और lifetime campaign budget खर्च हो जाने पर, अगले nightly update के बाद उस campaign में Ayrshare द्वारा ट्रैक किया गया हर addeliveryStatus: "COMPLETED"दिखाता है, जिसमें scheduled या review में मौजूद ad भी शामिल है। rejected adREJECTEDही रहता है।
लिंक के बजाय बातचीत खोलें
boost का बटन वेब पेज के बजाय आपके व्यवसाय के साथ एक chat खोल सकता है।callToAction.destination के साथ nested form भेजें, और callToAction.link को छोड़ दें।
destination | खोलता है | callToAction.type |
|---|---|---|
messenger | Messenger | MESSAGE_PAGE |
whatsapp | WHATSAPP_MESSAGE | |
instagramDm | Instagram Direct | INSTAGRAM_MESSAGE |
{
"accountId": "123456789",
"postId": "Ut1fWU6XkqkMayHGnJZ",
"goal": "engagement",
"budget": { "amount": 20 },
"callToAction": { "type": "WHATSAPP_MESSAGE", "destination": "whatsapp" },
"platformOptions": { "facebook": { "adName": "Chat with us", "bidAmount": 2 } }
}
engagementयाinteractionsad goal का उपयोग करें। तब ad बातचीत के लिए optimize किया जाता है: Meta इसे उन लोगों को दिखाता है जिनके chat शुरू करने की संभावना है। अन्य goalscode: 101के साथ400लौटाते हैं।callToAction.typeको destination से मेल खाना चाहिए, जैसा कि तालिका में है। कोई भी casing स्वीकार की जाती है।callToAction.linkऔरcallToAction.linkTitleकोdestinationके साथ नहीं भेजा जा सकता, क्योंकि बटन पेज नहीं, बल्कि chat खोलता है।destinationके बिना,linkअभी भी आवश्यक है।- लोग आपकी profile से जुड़े account को संदेश भेजते हैं।
whatsappके लिए, उसके Facebook Page का Meta में एक WhatsApp Business नंबर से जुड़ा होना आवश्यक है। destinationकोattachTo.adSetIdके साथ नहीं जोड़ा जा सकता: मौजूदा ad set अपना पहले से मौजूद destination बनाए रखता है।attachTo.campaignIdके साथ, campaign का Meta काOUTCOME_ENGAGEMENTobjective होना चाहिए; अन्यथा अनुरोधcode: 101के साथ400लौटाता है।- response, और Get Boosted Ads,
callToActionको उसकेdestinationके साथ लौटाते हैं।
curl -X POST https://api.ayrshare.com/api/ads/facebook/boost \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": { "countries": ["US"] },
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": [1234567890, 1234567891]
}'
curl -X POST https://api.ayrshare.com/api/ads/facebook/boost \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-d '{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "Nurse Practitioner Hiring",
"status": "active",
"goal": "traffic",
"callToAction": {
"type": "APPLY_NOW",
"link": "https://example.com/careers/nurse-practitioner",
"linkTitle": "Apply today"
},
"specialAdCategories": ["employment"],
"minAge": 18,
"maxAge": 65,
"locations": { "countries": ["US"] },
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z"
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/boost", {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${API_KEY}`
},
body: JSON.stringify({
postId: "1234567890",
accountId: "1234567890",
adName: "My Ad",
status: "active",
goal: "engagement",
minAge: 18,
maxAge: 65,
locations: { countries: ["US"] },
budget: 100,
bidAmount: 1,
startDate: "2025-03-01T00:00:00Z",
endDate: "2025-03-07T23:59:59Z",
interests: [1234567890, 1234567891]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
API_KEY = "API_KEY"
url = "https://api.ayrshare.com/api/ads/facebook/boost"
payload = {
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": {"countries": ["US"]},
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": [1234567890, 1234567891]
}
response = requests.post(url, headers={"Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json"}, json=payload)
print(response.json())
<?php
$API_KEY = "API_KEY";
$payload = [
"postId" => "1234567890",
"accountId" => "1234567890",
"adName" => "My Ad",
"status" => "active",
"goal" => "engagement",
"minAge" => 18,
"maxAge" => 65,
"locations" => ["countries" => ["US"]],
"budget" => 100,
"bidAmount" => 1,
"startDate" => "2025-03-01T00:00:00Z",
"endDate" => "2025-03-07T23:59:59Z",
"interests" => [1234567890, 1234567891]
];
$ch = curl_init("https://api.ayrshare.com/api/ads/facebook/boost");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
"Content-Type: application/json",
"Authorization: Bearer " . $API_KEY
]);
$response = curl_exec($ch);
$result = json_decode($response, true);
print_r($result);
curl_close($ch);
using System;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
class Program
{
static async Task Main()
{
string API_KEY = "API_KEY";
var payload = new
{
postId = "1234567890",
accountId = "1234567890",
adName = "My Ad",
status = "active",
goal = "engagement",
minAge = 18,
maxAge = 65,
locations = new { countries = new[] { "US" } },
budget = 100,
bidAmount = 1,
startDate = "2025-03-01T00:00:00Z",
endDate = "2025-03-07T23:59:59Z",
interests = new[] { 1234567890, 1234567891 }
};
using var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", API_KEY);
var content = new StringContent(
JsonSerializer.Serialize(payload),
Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync("https://api.ayrshare.com/api/ads/facebook/boost", content);
var responseBody = await response.Content.ReadAsStringAsync();
Console.WriteLine(responseBody);
}
}
package main
import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
func main() {
apiKey := "API_KEY"
payload := map[string]interface{}{
"postId": "1234567890",
"accountId": "1234567890",
"adName": "My Ad",
"status": "active",
"goal": "engagement",
"minAge": 18,
"maxAge": 65,
"locations": map[string]interface{}{"countries": []string{"US"}},
"budget": 100,
"bidAmount": 1,
"startDate": "2025-03-01T00:00:00Z",
"endDate": "2025-03-07T23:59:59Z",
"interests": []int{1234567890, 1234567891},
}
jsonData, err := json.Marshal(payload)
if err != nil {
fmt.Println("Error marshaling JSON:", err)
return
}
req, err := http.NewRequest("POST", "https://api.ayrshare.com/api/ads/facebook/boost", bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Authorization", "Bearer "+apiKey)
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error sending request:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response:", err)
return
}
fmt.Println(string(body))
}
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.databind.ObjectMapper;
public class BoostPost {
public static void main(String[] args) {
String API_KEY = "API_KEY";
String url = "https://api.ayrshare.com/api/ads/facebook/boost";
Map<String, Object> payload = new HashMap<>();
payload.put("postId", "1234567890");
payload.put("accountId", "1234567890");
payload.put("adName", "My Ad");
payload.put("status", "active");
payload.put("goal", "engagement");
payload.put("minAge", 18);
payload.put("maxAge", 65);
Map<String, Object> locations = new HashMap<>();
locations.put("countries", Arrays.asList("US"));
payload.put("locations", locations);
payload.put("budget", 100);
payload.put("bidAmount", 1);
payload.put("startDate", "2025-03-01T00:00:00Z");
payload.put("endDate", "2025-03-07T23:59:59Z");
payload.put("interests", Arrays.asList(1234567890, 1234567891));
try {
ObjectMapper objectMapper = new ObjectMapper();
String requestBody = objectMapper.writeValueAsString(payload);
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + API_KEY)
.POST(HttpRequest.BodyPublishers.ofString(requestBody))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
require 'net/http'
require 'uri'
require 'json'
API_KEY = "API_KEY"
uri = URI.parse("https://api.ayrshare.com/api/ads/facebook/boost")
payload = {
postId: "1234567890",
accountId: "1234567890",
adName: "My Ad",
status: "active",
goal: "engagement",
minAge: 18,
maxAge: 65,
locations: { countries: ["US"] },
budget: 100,
bidAmount: 1,
startDate: "2025-03-01T00:00:00Z",
endDate: "2025-03-07T23:59:59Z",
interests: [1234567890, 1234567891]
}
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.request_uri)
request["Content-Type"] = "application/json"
request["Authorization"] = "Bearer #{API_KEY}"
request.body = payload.to_json
response = http.request(request)
puts response.body
{
"status": "success",
"adId": "120217670757750410",
"adName": "API Post - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
"adStatus": "active",
"bidAmount": 10,
"budget": 100,
"endDate": "2026-03-28T22:30:00Z",
"goal": {
"title": "Get More Engagement",
"description": "This goal seeks to increase engagement...",
"type": "engagement"
},
"interests": [
"6003195554098"
],
"locations": { "countries": ["US"] },
"maxAge": 65,
"minAge": 18,
"postId": "DE6gpw8kxlonHy2b7Lo",
"startDate": "2026-03-26T22:30:00Z"
}
{
"status": "success",
"adId": "120217670757750411",
"adName": "Nurse Practitioner Hiring - DE6gpw8kxlonHy2b7Lo - 2025-03-26T23:42:43",
"adStatus": "active",
"bidAmount": 1,
"budget": 100,
"callToAction": {
"type": "APPLY_NOW",
"link": "https://example.com/careers/nurse-practitioner",
"linkTitle": "Apply today"
},
"endDate": "2025-03-07T23:59:59Z",
"goal": {
"title": "Drive Traffic",
"description": "Sends people from the boosted post to a destination off Facebook...",
"type": "traffic"
},
"locations": { "countries": ["US"] },
"maxAge": 65,
"minAge": 18,
"postId": "DE6gpw8kxlonHy2b7Lo",
"startDate": "2025-03-01T00:00:00Z"
}
{
"action": "boost post",
"status": "error",
"code": 369,
"message": "Unable to boost post. Please try again or contact us if the issue persists.",
"details": "The accountId likely does not exist. Please check the accountId and try again."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "Missing required fields: budget"
}