curl -X POST https://api.ayrshare.com/api/ads/instagram/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]
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/instagram/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/instagram/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/instagram/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/instagram/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/instagram/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/instagram/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);
payload.put("locations", Map.of("countries", Arrays.asList("US")));
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/instagram/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",
"socialPostId": "1234567890",
"igPostId": "1234567890",
"platform": "instagram",
"startDate": "2026-03-26T22:30: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: accountId"
}
Instagram Ads
Boost Bài đăng
Boost một bài đăng bằng cách gửi nó đến nền tảng quảng cáo của Instagram
POST
/
ads
/
instagram
/
boost
curl -X POST https://api.ayrshare.com/api/ads/instagram/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]
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/instagram/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/instagram/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/instagram/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/instagram/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/instagram/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/instagram/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);
payload.put("locations", Map.of("countries", Arrays.asList("US")));
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/instagram/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",
"socialPostId": "1234567890",
"igPostId": "1234567890",
"platform": "instagram",
"startDate": "2026-03-26T22:30: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: accountId"
}
Boost một bài đăng Instagram hiện có để tạo một quảng cáo.
Endpoint này cho phép bạn chuyển đổi các bài đăng tự nhiên (organic) của mình thành các quảng cáo trả phí với các tham số nhắm mục tiêu, ngân sách và lịch trình tùy chỉnh.
Bộ chọn
Hãy thay các ID ví dụ bằng ID của riêng bạn. Đặt
- Ngân sách và số tiền đặt giá phải được chỉ định bằng USD với tối đa hai chữ số thập phân.
- Quảng cáo phải chạy ít nhất 30 giờ để đáp ứng yêu cầu của Instagram.
- Bạn có thể sử dụng endpoint interests để tìm ID sở thích dùng cho việc nhắm mục tiêu.
- Instagram có thể mất tối đa 24 giờ để xem xét và phê duyệt các bài đăng được boost.
- Nếu sử dụng
socialPostIdtrực tiếp (thay vìpostIdcủa Ayrshare), hãy đảm bảo đó là một ID bài đăng Instagram hợp lệ. - Nếu một lượt boost thất bại sau khi Facebook đã tạo chiến dịch của nó (ở bước nội dung quảng cáo, nhóm quảng cáo hoặc quảng cáo), chúng tôi sẽ cố gắng xóa chiến dịch đó. Nếu việc xóa cũng thất bại, chiến dịch trống vẫn còn trong tài khoản quảng cáo của bạn. Bạn có thể tìm và xóa nó trong Ads Manager.
Mục tiêu Quảng cáo (Ad Goals)
Mỗi quảng cáo phải có một mục tiêu. Mục tiêu quyết định cách quảng cáo sẽ được tối ưu hóa để hiển thị.engagement: Mục tiêu này nhằm tăng mức tương tác đồng thời đảm bảo rằng quảng cáo tiếp cận số lượng người dùng duy nhất tối đa. Nó cân bằng giữa khả năng hiển thị và tương tác, hiển thị quảng cáo cho càng nhiều người khác nhau càng tốt — những người có khả năng tương tác với quảng cáo.interactions: Được thiết kế để tăng cường các tương tác như thích, bình luận và chia sẻ trên quảng cáo. Instagram ưu tiên hiển thị quảng cáo cho những người dùng có nhiều khả năng tương tác với nó nhất.awareness_views: Tập trung vào việc tăng nhận diện thương hiệu bằng cách tối đa hóa số lần quảng cáo được hiển thị. Nó ưu tiên hiển thị quảng cáo càng nhiều lần càng tốt trong phạm vi ngân sách, bất kể độ phủ (reach) duy nhất.awareness_audience: Nhằm nâng cao nhận diện thương hiệu bằng cách tối đa hóa số người duy nhất xem quảng cáo. Nó đảm bảo rằng quảng cáo tiếp cận càng nhiều người dùng khác nhau càng tốt và tối đa hóa quy mô đối tượng duy nhất thay vì hiển thị nhiều lần cho cùng một đối tượng.
Quảng cáo Instagram yêu cầu một tài khoản Instagram Business được kết nối thông qua Facebook, một Trang Facebook liên kết, và quyền
ads_management. Hãy liên kết lại thông qua Facebook để cấp quyền này. Các tài khoản được kết nối bằng Instagram Login không thể sử dụng các endpoint quảng cáo này. Media ID và ID tài khoản Instagram được xác định từ tài khoản đã liên kết của bạn; không gửi instagram_user_id.socialPostId cũng chấp nhận bí danh dành riêng cho Instagram là igPostId. fbPostId chỉ áp dụng cho Facebook. Các phản hồi thành công bao gồm platform: "instagram", socialPostId, và igPostId.
Tham số Header
Tham số Body
string
Một khóa duy nhất, không rỗng cho yêu cầu boost này. Thử lại cùng một payload với cùng khóa này để tránh tạo quảng cáo trùng lặp. Sử dụng lại khóa với một payload hoặc nền tảng khác sẽ trả về HTTP 409. Một yêu cầu vẫn đang được xử lý cũng trả về 409; một reservation không khả dụng trả về 503 mà không tạo quảng cáo.
boolean
mặc định:false
Cho phép Meta chia sẻ ngân sách giữa các ad set trong chiến dịch.
string
bắt buộc
ID của tài khoản quảng cáo Instagram để boost bài đăng. ID tài khoản có thể được lấy từ
endpoint ad accounts.
string
bắt buộc
Tên cho quảng cáo của bạn (hiển thị trong Instagram Ad Manager) với định dạng
{adName} - {postId hoặc socialPostId} - {ngày hiện tại}.number
bắt buộc
Số tiền đặt giá tối đa bằng USD, dưới dạng một số dương với tối đa hai chữ số thập phân.
number
bắt buộc
Ngân sách hàng ngày bằng USD. Sử dụng một số dương với tối đa hai chữ số thập phân. Meta có thể áp dụng các mức tối thiểu bổ sung cho tài khoản và mục tiêu của bạn.
string
ID bài đăng xã hội Instagram của bài đăng cần boost, cho phép
bạn tạo quảng cáo từ một bài đăng được tạo trực tiếp trên Instagram. Đây là ID của bài đăng trên
Instagram, không phải của Ayrshare. Bắt buộc nếu
postId không được đặt.string
mặc định:"engagement"
Mục tiêu của quảng cáo. Giá trị:
engagement, interactions, awareness_views, và
awareness_audience. Xem chi tiết ad goals ở trên để
biết thêm thông tin.object
Nhắm mục tiêu các quốc gia với
{"countries": ["US", "CA"]} bằng cách sử dụng mã quốc gia. Bạn cũng có thể cung cấp các mảng regions và cities; xem regions và cities. Một đối tượng không chỉ định quốc gia, khu vực hoặc thành phố nào, chẳng hạn như {}, sẽ bị từ chối với mã 101; hãy bỏ locations để nhắm mục tiêu Hoa Kỳ.string
Ayrshare post ID của bài đăng cần boost. Bắt buộc nếu
socialPostId không được đặt.string
mặc định:"active"
Trạng thái của quảng cáo. Giá trị:
active và paused.Bạn có thể thay đổi trạng thái của quảng cáo sau này bằng cách sử dụng endpoint update ad.object
Theo dõi quảng cáo bằng Meta Pixel.
Hiện child attributes
Hiện child attributes
number
bắt buộc
ID của Meta Pixel để theo dõi quảng cáo.
{
"pixelId": 1234567890
}
array
Thêm thẻ UTM vào URL quảng cáo.Ví dụ, nếu URL liên kết là
{
"urlTags": ["utm_source=ayrshare", "utm_medium=social", "utm_campaign=ayrshare-social"]
}
https://www.mysite.com/my-post và các URL tag được thêm là:utm_source=ayrshare, utm_medium=social, và utm_campaign=ayrshare-social.URL quảng cáo sẽ là:
https://www.mysite.com/my-post?utm_source=ayrshare&utm_medium=social&utm_campaign=ayrshare-social.array
Meta yêu cầu các nhà quảng cáo trong các danh mục quảng cáo đặc biệt phải tự xác định danh mục chiến dịch của mình.Nếu doanh nghiệp của bạn thuộc một trong các danh mục này, bạn phải chọn danh mục phù hợp khi boost bài đăng.Các giá trị sau được hỗ trợ:
housing: Quảng cáo quảng bá hoặc liên kết trực tiếp đến cơ hội nhà ở hoặc dịch vụ liên quan, bao gồm nhưng không giới hạn: danh sách bán hoặc cho thuê nhà/căn hộ, bảo hiểm nhà, bảo hiểm thế chấp, các khoản vay thế chấp, dịch vụ sửa chữa nhà và dịch vụ định giá hoặc vốn chủ sở hữu nhà ở.financial_product_services: Quảng cáo quảng bá hoặc liên kết trực tiếp đến các sản phẩm và dịch vụ tài chính, bao gồm cả tín dụng.employment: Quảng cáo quảng bá hoặc liên kết trực tiếp đến cơ hội việc làm, bao gồm nhưng không giới hạn: công việc bán thời gian hoặc toàn thời gian, thực tập hoặc các chương trình chứng chỉ chuyên môn. Các quảng cáo liên quan thuộc danh mục này bao gồm quảng bá bảng tin việc làm hoặc hội chợ việc làm, dịch vụ tổng hợp hoặc quảng cáo mô tả các phúc lợi mà công ty có thể cung cấp, bất kể có lời mời làm việc cụ thể hay không.issues_elections_politics: Quảng cáo được tạo bởi, thay mặt cho, hoặc về một ứng cử viên cho chức vụ công, một nhân vật chính trị, một đảng chính trị, hoặc vận động cho kết quả của một cuộc bầu cử cho chức vụ công. Điều này cũng bao gồm quảng cáo về bất kỳ cuộc bầu cử, trưng cầu dân ý hoặc sáng kiến bỏ phiếu nào, bao gồm các chiến dịch bầu cử “Hãy đi bỏ phiếu”. Quảng cáo được quản lý như quảng cáo chính trị hoặc về các vấn đề xã hội tại bất kỳ nơi nào quảng cáo được đặt. Nếu chọn các vấn đề, bầu cử hoặc chính trị, bạn phải chọn quốc gia mà bạn muốn chạy các quảng cáo này. Bạn phải được ủy quyền để chạy quảng cáo về các vấn đề xã hội, bầu cử hoặc chính trị tại quốc gia được chỉ định.
locations: các quốc gia bạn liệt kê, cộng với quốc gia của từng khu vực và thành phố. Vì vậy, một lượt boost housing nhắm đến một thành phố ở Vương quốc Anh sẽ được thiết lập cho Vương quốc Anh mà không cần thêm gì vào yêu cầu của bạn. Nếu không có locations, quảng cáo sẽ chạy ở Hoa Kỳ và chiến dịch được thiết lập cho Hoa Kỳ.Meta cũng đặt bán kính tối thiểu quanh mỗi thành phố cho các danh mục này. Một thành phố ở Vương quốc Anh với bán kính 17 kilômét đã bị từ chối với #2909039, yêu cầu ít nhất 25 kilômét (15 dặm), vì vậy hãy dùng 25 kilômét trở lên.Meta yêu cầu các nhà quảng cáo phải xác định đúng danh mục chiến dịch của mình.
Meta sử dụng người xem xét và học máy để xác định các loại quảng cáo này.
Nếu bạn gửi cho chúng tôi một
specialAdCategories không chính xác, có nguy cơ quảng cáo của bạn sẽ bị tạm dừng cho đến khi chiến dịch được điều chỉnh.string
Cá nhân hoặc tổ chức thụ hưởng từ quảng cáo. Được đặt cùng với
dsaPayor. Sử dụng endpoint DSA recommendations để nhận gợi ý.string
Cá nhân hoặc tổ chức chi trả cho quảng cáo. Được đặt cùng với
dsaBeneficiary.string
Ngày và giờ kết thúc theo định dạng ISO 8601 (phải cách thời điểm bắt đầu ít nhất 30 giờ), ví dụ
2025-03-01T00:00:00Z.Nếu không được đặt, quảng cáo sẽ chạy vô thời hạn và có ngày kết thúc là ongoing.object
Loại trừ các vị trí bằng cách sử dụng cùng cấu trúc
countries, regions, và cities như locations.string
mặc định:"all"
Giới tính của đối tượng. Giá trị:
all, male, female.array
Các sở thích mục tiêu của quảng cáo dưới dạng một mảng interest
ids của Instagram.
number
mặc định:65
Độ tuổi tối đa để nhắm mục tiêu quảng cáo (mặc định: 65).
number
mặc định:18
Độ tuổi tối thiểu để nhắm mục tiêu quảng cáo (mặc định: 18).
string
Ngày và giờ bắt đầu theo định dạng ISO 8601, ví dụ
2025-03-01T00:00:00Z.Nếu không được đặt, quảng cáo sẽ bắt đầu ngay lập tức.startDate và endDate theo lịch trình bạn dự định; các ngày trong ví dụ chỉ mang tính minh họa.
Ngân sách chiến dịch
Để đặt ngân sách ở cấp chiến dịch thay vì nhóm quảng cáo, hãy gửibudget.level: "campaign" trong dạng lồng nhau. Khi đó nhóm quảng cáo không có ngân sách riêng. Tính năng này hoạt động với cả ngân sách hằng ngày và ngân sách trọn đời.
{
"accountId": "123456789",
"postId": "Ut1fWU6XkqkMayHGnJZ",
"goal": "engagement",
"budget": { "amount": 50, "type": "lifetime", "level": "campaign" },
"schedule": { "start": "2026-11-01T00:00:00Z", "end": "2026-11-08T00:00:00Z" },
"platformOptions": { "instagram": { "adName": "November boost", "bidAmount": 2 } }
}
budget.level:adSet(mặc định) hoặccampaign. Không thể kết hợp ngân sách chiến dịch vớiadSetBudgetSharingEnabled. Gửi cả hai sẽ bị từ chối với lỗi400vàcode: 101.- Phản hồi bổ sung
budgetLevel: "campaign"cho ngân sách chiến dịch. Ngân sách nhóm quảng cáo không trả vềbudgetLevel, vì vậy hãy coi trường bị thiếu làadSet. - Trong Lịch sử,
budgetDailyhiển thị ngân sách hằng ngày của chiến dịch đối với quảng cáo có ngân sách chiến dịch hằng ngày. Nếu nhiều quảng cáo dùng chung một ngân sách chiến dịch, mỗi quảng cáo hiển thị toàn bộ ngân sách chiến dịch chứ không phải phần của nó. Lịch sử không hiển thị ngân sách trọn đời, dù ở cấp chiến dịch hay nhóm quảng cáo. Khi ngân sách trọn đời của chiến dịch đã được chi hết, mọi quảng cáo trong chiến dịch đó sẽ hiển thịdeliveryStatus: "COMPLETED"sau lần cập nhật hằng đêm tiếp theo, kể cả quảng cáo đang được lên lịch hoặc đang chờ xét duyệt. Quảng cáo bị từ chối vẫn giữ trạng tháiREJECTED.
Boost vào một chiến dịch hoặc nhóm quảng cáo hiện có
Theo mặc định, mỗi lượt boost tạo chiến dịch, nhóm quảng cáo và quảng cáo riêng. Để thêm lượt boost vào một chiến dịch hoặc nhóm quảng cáo bạn đang chạy trong Meta, hãy gửi dạng lồng nhau vớiattachTo.
attachTo.campaignId: lượt boost tạo một nhóm quảng cáo và quảng cáo mới bên trong chiến dịch đó. Gửibudget,targetingvàbidAmountnhư bình thường: chúng áp dụng cho nhóm quảng cáo mới.attachTo.adSetId: lượt boost chỉ tạo quảng cáo, bên trong nhóm quảng cáo đó. Đồng thời gửiattachTo.campaignId, là chiến dịch chứa nhóm quảng cáo đó. Bỏ quabudget,targetingvàplatformOptions.instagram.bidAmount: nhóm quảng cáo giữ thiết lập riêng của nó. Gửi bất kỳ trường nào trong số đó sẽ trả về lỗi400vớicode: 101.
{
"accountId": "123456789",
"postId": "Ut1fWU6XkqkMayHGnJZ",
"goal": "engagement",
"attachTo": { "campaignId": "120210000000000001", "adSetId": "120210000000000002" },
"platformOptions": { "instagram": { "adName": "November boost" } }
}
- Chiến dịch hoặc nhóm quảng cáo phải thuộc tài khoản quảng cáo được chỉ định bởi
accountIdvà không được thuộc về các lượt boost của người dùng khác. Nếu không, yêu cầu sẽ trả về lỗi400. Một lượt boost Instagram cũng không thể gắn vào chiến dịch do một lượt boost Facebook tạo ra, và ngược lại. - Không thể kết hợp
attachTovớibudget.level: "campaign",specialAdCategorieshoặcadSetBudgetSharingEnabled, vì các trường này được đặt trên một chiến dịch mới. Gửi chúng sẽ trả vềcode: 101. - Việc tạm dừng hoặc kích hoạt lượt boost chỉ thay đổi những gì lượt boost đã tạo: quảng cáo, và nhóm quảng cáo nếu lượt boost đã tạo nó. Chiến dịch hoặc nhóm quảng cáo bạn chỉ định trong
attachTogiữ trạng thái riêng của nó. Quảng cáo chỉ chạy khi chiến dịch và nhóm quảng cáo phía trên nó đang hoạt động. Điều này cũng áp dụng khi Ayrshare tạm dừng quảng cáo của bạn, ví dụ khi một profile bị xóa. - Nếu lượt boost thất bại, chiến dịch hoặc nhóm quảng cáo được chỉ định trong
attachTosẽ không bao giờ bị xóa. - Nếu nhóm quảng cáo bạn gắn vào nằm trong một chiến dịch nắm giữ ngân sách (ngân sách chiến dịch), Lịch sử báo cáo lượt boost giống như mọi quảng cáo có ngân sách chiến dịch:
budgetDailyhiển thị toàn bộ ngân sách chiến dịch chứ không phải phần của lượt boost, và khi ngân sách trọn đời của chiến dịch đã được chi hết, mọi quảng cáo mà Ayrshare theo dõi trong chiến dịch đó sẽ hiển thịdeliveryStatus: "COMPLETED"sau lần cập nhật hằng đêm tiếp theo, kể cả quảng cáo đang được lên lịch hoặc đang chờ xét duyệt. Quảng cáo bị từ chối vẫn giữ trạng tháiREJECTED.
curl -X POST https://api.ayrshare.com/api/ads/instagram/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]
}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/instagram/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/instagram/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/instagram/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/instagram/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/instagram/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/instagram/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);
payload.put("locations", Map.of("countries", Arrays.asList("US")));
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/instagram/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",
"socialPostId": "1234567890",
"igPostId": "1234567890",
"platform": "instagram",
"startDate": "2026-03-26T22:30: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: accountId"
}