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
投稿をブースト
投稿をFacebookの広告プラットフォームに送信してブーストします
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"
}
既存のFacebook投稿をブーストして広告を作成します。
このエンドポイントを使用すると、オーガニック投稿をカスタムターゲティング、予算、スケジュールパラメータを持つ有料広告に変換できます。
- 予算と入札額は、小数点以下2桁までのUSDで指定する必要があります。
- Facebookの要件に対応するため、広告は少なくとも30時間実行する必要があります。
- ターゲティング用の関心IDを見つけるには、関心エンドポイントを使用できます。
- Facebookがブースト投稿を確認・承認するまでに最大24時間かかることがあります。
fbPostIdを直接使用する場合(AyrshareのpostIdの代わりに)、有効なFacebook投稿IDであることを確認してください。- Facebook がキャンペーンを作成した後(クリエイティブ、広告セット、広告のいずれかのステップ)にブーストが失敗した場合、 Ayrshare はそのキャンペーンの削除を試みます。削除にも失敗した場合、空のキャンペーンは広告アカウントに残ります。 広告マネージャー(Ads Manager)で見つけて削除できます。
次の 2 つがそろうまで、Meta は広告を拒否します。
- 広告アカウントに支払い方法があること。 Meta の請求と支払いで支払い方法を追加し、
accountIdで送信する広告アカウントに割り当ててください。ビジネスポートフォリオにのみ保存された支払い方法では不十分です。 - パーソナライズ広告がオンになっていること(EU、EEA、スイス)。 Facebookページにリンクされた Facebook または Instagram アカウントの所有者がパーソナライズを抑えた広告を選択している場合、または広告なしで Meta を利用するサブスクリプションに登録している場合、Meta はそのアカウントとページによる広告の配信を許可しません。所有者はアカウントセンター → 広告設定 → 広告体験でパーソナライズ広告に戻すか、サブスクリプションを解約できます。詳しくはこちら。
広告の目標
各広告には目標が必要です。目標は、広告がどのように表示に最適化されるかを決定します。engagement: この目標は、広告が最大数のユニークユーザーに到達することを保証しながらエンゲージメントを向上させます。可視性とエンゲージメントのバランスを取り、広告に反応する可能性のあるできるだけ多くの人々に広告を表示します。interactions: いいね、コメント、シェアなど、広告へのインタラクションを促進するように設計されています。Facebookは広告に最も関わりそうなユーザーに広告を表示することを優先します。awareness_views: 広告が表示される回数を最大化することで、ブランド認知度を高めることに重点を置きます。ユニークリーチに関係なく、予算内でできるだけ多くの回数広告を表示することを優先します。awareness_audience: 広告を見るユニークユーザー数を最大化することで、ブランド認知度を向上させることを目指します。広告ができるだけ多くの異なるユーザーに到達することを保証し、同じオーディエンスに複数回表示するのではなく、ユニークオーディエンスのサイズを最大化します。traffic: ウェブサイト、ランディングページ、求人情報など、選択した移動先へFacebookの外にユーザーを誘導します。Facebookはプラットフォーム上のエンゲージメントではなくリンククリックに最適化します。これはcallToActionボタンをサポートする唯一の目標です。
ヘッダーパラメータ
ボディパラメータ
string
必須
投稿をブーストするFacebook広告アカウントのID。アカウントIDは広告アカウントエンドポイントから取得できます。
string
必須
広告の名前(Facebook広告マネージャーに表示されます)。形式は
{adName} - {postId or fbPostId} - {current date}となります。number
必須
最大入札額(USD)。最小入札額は$1.00です。
number
必須
日次予算(USD)。最小予算は$1.00です。
string
必須
ブーストする投稿のFacebookソーシャル投稿ID。Facebookで直接作成された投稿から広告を作成できます。これはFacebook上の投稿のIDであり、AyrshareのIDではありません。
postIdが設定されていない場合は必須です。string
デフォルト:"engagement"
必須
広告の目標。値:
engagement、interactions、awareness_views、awareness_audience、traffic。詳細については上記の広告の目標の詳細をご覧ください。object
配列のオブジェクトでターゲット広告の場所を指定します:
countries、regions、cities。
{}のように国、地域、都市のいずれも指定していないオブジェクトは、コード101で拒否されます。米国をターゲットにするにはlocationsを省略してください。表示 child attributes
表示 child attributes
array
国コードのリスト。
{
"countries": ["US", "CA"]
}
string
必須
ブーストする投稿のAyrshare投稿ID。
fbPostIdが設定されていない場合は必須です。string
デフォルト:"active"
必須
広告のステータス。値:
activeおよびpaused。後で広告更新エンドポイントを使用して広告のステータスを変更できます。boolean
デフォルト:false
Metaのキャンペーンレベルの広告セット予算共有を制御します。
Metaは現在、キャンペーンレベルの予算なしで作成されたすべてのキャンペーンでこのワイヤーフィールドを必須としているため、Ayrshareは常にこれを送信します — 後方互換性のためデフォルトは
falseです。全体的なパフォーマンスを最適化するために、同じキャンペーン内の他の広告セット間で広告セットの予算の約20%までをMetaが共有できるようにするには、trueに設定します。詳細については、Metaの広告キャンペーングループリファレンスをご覧ください。object
ブースト投稿に、Apply Now(今すぐ応募)やShop Now(今すぐ購入)などのコールトゥアクションボタンを追加します。ボタンは
linkで指定したURLを開きます。destinationを使用すると、代わりにMessenger、WhatsApp、またはInstagram Directのチャットを開きます(リンクの代わりに会話を開くをご覧ください)。{
"callToAction": {
"type": "APPLY_NOW",
"link": "https://www.mysite.com/careers/social-media-manager",
"linkTitle": "Social Media Manager"
}
}
表示 child attributes
表示 child attributes
string
必須
ボタンのラベル。値:
LEARN_MORE、APPLY_NOW、SIGN_UP、SHOP_NOW、BOOK_TRAVEL、GET_QUOTE、CONTACT_US、DOWNLOAD、SUBSCRIBE。入力時は大文字・小文字を区別しないため、apply_now、Apply_Now、APPLY_NOWはすべて受け付けられます。
destinationを使用する場合は、代わりにメッセージボタン(MESSAGE_PAGE、WHATSAPP_MESSAGE、または
INSTAGRAM_MESSAGE)を使用してください。string
ボタンが開く移動先。絶対
httpまたはhttps URLである必要があります。相対パス、mailto:リンク、不正な形式のURLは拒否されます。destinationが設定されていない場合は必須です。string
ボタンと共に表示される任意の見出し。
string
リンクの代わりにチャットを開きます:
messenger、whatsapp、またはinstagramDm。ネスト形式のみ。
リンクの代わりに会話を開くをご覧ください。リンクを開く
callToActionはtraffic広告目標でのみサポートされます。destinationを指定したボタンは、リンクの代わりに会話を開くで説明しているとおり、代わりにengagementまたはinteractionsを使用します。
リンクボタンをengagement、interactions、awareness_views、awareness_audienceと共に送信すると、互換性のある目標を示すcode: 101付きの400が返されます。
以前は、この値はどの目標でも受け付けられた後に暗黙的に無視され、ボタンのない広告が作成されていました。callToAction.linkは移動先URLを指定します。Metaが既存の投稿上でコールトゥアクションをボタンとして表示する場合、urlTagsはそのボタンリンクに追加されます。callToActionなしのgoal: "traffic"も許可されており、ボタンのないトラフィック広告が作成されます。送信したcallToActionは、typeが大文字化された状態でブーストのレスポンスにエコーバックされます(Post Boosted with a Call to Actionの例をご覧ください)。また、その後はブーストされた広告エンドポイントからも広告上に返されます。リンクの代わりにMessenger、WhatsApp、またはInstagram Directのチャットを開くには、リンクの代わりに会話を開くをご覧ください。object
Facebook Pixelを使用して広告を追跡します。
表示 child attributes
表示 child attributes
number
必須
広告を追跡するFacebook PixelのID。
{
"pixelId": 1234567890
}
array
広告URLにUTMタグを追加します。例えば、リンクURLが
{
"urlTags": ["utm_source=ayrshare", "utm_medium=social", "utm_campaign=ayrshare-social"]
}
https://www.mysite.com/my-postで、追加されたURLタグが次のとおりの場合:utm_source=ayrshare、utm_medium=social、utm_campaign=ayrshare-social。広告URLは次のようになります:
https://www.mysite.com/my-post?utm_source=ayrshare&utm_medium=social&utm_campaign=ayrshare-social。array
Metaは、特別広告カテゴリの広告主に対して、キャンペーンカテゴリを自己識別するよう要求します。あなたのビジネスがこれらのカテゴリの1つに該当する場合、投稿をブーストする際に適切なカテゴリを選択する必要があります。以下の値がサポートされています:
housing: 住宅の機会または関連サービスを宣伝または直接リンクする広告(住宅またはアパートの売買・賃貸のリスト、住宅所有者保険、住宅ローン保険、住宅ローン、住宅修理、住宅担保または鑑定サービスなどを含むがこれらに限定されない)。financial_product_services: クレジットを含む金融商品およびサービスの提供を宣伝または直接リンクする広告。financial_products_servicesは同等の綴りとして受け付けられ、creditもこのカテゴリのMetaにおける旧称として受け付けられます — 3つの値はいずれも同じカテゴリとしてMetaに到達するため、お手元にある値をそのまま送信できます。employment: 雇用機会を宣伝または直接リンクする広告(パートタイムまたはフルタイムの仕事、インターンシップ、または専門資格プログラムを含むがこれらに限定されない)。このカテゴリに該当する関連広告には、求人掲示板や求人フェアの宣伝、集約サービス、または特定の求人提供に関係なく企業が提供する福利厚生を詳述する広告が含まれます。none: デフォルト。キャンペーンがどの特別広告カテゴリにも該当しないことを宣言します。明示的に送信することはspecialAdCategoriesを完全に省略することと同等であり、常にこのフィールドを送信する呼び出し側が特別扱いなしで「カテゴリなし」を表明できるように受け付けられています。issues_elections_politics: 公職候補者、政治家、政党について、またはそれらのために作成された広告、または公職選挙の結果を主張する広告。これには、選挙、国民投票、または住民投票イニシアチブに関する広告も含まれ、「投票に行こう」選挙キャンペーンも含まれます。広告が掲載される場所での政治広告または社会問題に関する広告として規制される広告。問題、選挙、または政治を選択する場合、これらの広告を実行したい国を選択する必要があります。指定された国で社会問題、選挙、または政治に関する広告を実行するには、認証を受ける必要があります。
code: 101付きの400で拒否されます。以前は、認識されない値は暗黙的に破棄され、キャンペーンはカテゴリ未指定のまま作成されていたため、タイプミスがあると規制対象の広告がカテゴリを宣言しないまま実行され続けていました。このエラーメッセージ内の受け付けられる値の一覧はMetaの大文字形式で記述され、上記の別の綴りも含まれるため、NONE, HOUSING, FINANCIAL_PRODUCTS_SERVICES, EMPLOYMENT, ISSUES_ELECTIONS_POLITICS, FINANCIAL_PRODUCT_SERVICES, CREDITと表示されます。これらはここに記載されている5つのカテゴリと同じものです — FINANCIAL_PRODUCT_SERVICESとCREDITはfinancial_product_servicesと同等の値であり、追加のカテゴリではありません。関心エンドポイントも同一のメッセージを返します。カテゴリの重複や、["credit", "financial_product_services"]のような同一カテゴリの2つの綴りの送信は受け付けられ、Metaに到達する前に単一のカテゴリにまとめられます。空の値はcode: 101付きの400で拒否されます。これらのカテゴリのいずれかに対してMetaが許可する関心IDを見つけるには、同じ値を関心エンドポイントに渡してください。Meta は、特別広告カテゴリの広告を配信する国の情報も必要とします。Ayrshare は locations からそれらの国を取得します。指定した国に加えて、各地域と各都市の国も含まれます。そのため、英国の都市をターゲットにした housing のブーストは、リクエストに何も追加しなくても英国向けに設定されます。locations を指定しない場合、広告は米国で配信され、キャンペーンも米国向けに設定されます。Meta はこれらのカテゴリについて、各都市の周囲に最小半径も設定しています。半径 17 キロメートルの英国の都市は #2909039 で拒否されました。このエラーは少なくとも 25 キロメートル(15 マイル)を求めるため、25 キロメートル以上を使用してください。Metaは、キャンペーンカテゴリを自己識別した広告主を要求します。
Metaは人間のレビュアーと機械学習を使用して、これらの種類の広告を識別します。
誤った
specialAdCategoryを送信した場合、キャンペーンが調整されるまで広告が一時停止されるリスクがあります。string
ISO 8601形式の終了日時(開始から少なくとも30時間後である必要があります)。例:
2025-03-01T00:00:00Z。設定されていない場合、広告は無期限に実行され、終了日はongoingとなります。object
countries、regions、citiesの配列を持つオブジェクトを使用して場所を除外します。表示 child attributes
表示 child attributes
array
除外する国コードのリスト。
{
"countries": ["US", "CA"]
}
string
デフォルト:"all"
オーディエンスの性別。値:
all、male、female。number
デフォルト:65
広告のターゲティングの最大年齢(デフォルト: 65)。
number
デフォルト:18
広告のターゲティングの最小年齢(デフォルト: 18)。
string
ISO 8601形式の開始日時。例:
2025-03-01T00:00:00Z。設定されていない場合、広告はすぐに開始されます。string
EU諸国向けのデジタルサービス法(DSA)コンプライアンスのための広告の受益者。いずれかが提供されている場合、
dsaPayorと共に設定する必要があります。詳細についてはDSAガイドをご覧ください。string
EU諸国向けのデジタルサービス法(DSA)コンプライアンスのための広告の支払者。いずれかが提供されている場合、
dsaBeneficiaryと共に設定する必要があります。キャンペーン予算
予算を広告セットではなくキャンペーンで保持するには、ネスト形式でbudget.level: "campaign" を送信してください。この場合、広告セットは独自の予算を持ちません。日次予算と通算予算のどちらでも使用できます。
{
"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。キャンペーン予算はadSetBudgetSharingEnabledと組み合わせることはできません。両方を送信すると、code: 101とともに400が返されます。- キャンペーン予算の場合、レスポンスに
budgetLevel: "campaign"が追加されます。広告セット予算の場合はbudgetLevelが返されないため、フィールドがない場合はadSetとして扱ってください。 - 履歴では、日次キャンペーン予算を使用する広告の
budgetDailyにキャンペーンの日次予算が表示されます。複数の広告が 1 つのキャンペーン予算を共有している場合、各広告には自身の配分ではなくキャンペーン予算全体が表示されます。履歴には、キャンペーンと広告セットのどちらの通算予算も表示されません。通算キャンペーン予算が使い切られると、次回の夜間更新後に、そのキャンペーン内のすべての広告(配信予定の広告や審査中の広告を含む)にdeliveryStatus: "COMPLETED"が表示されます。却下された広告はREJECTEDのままです。
既存のキャンペーンまたは広告セットにブーストする
デフォルトでは、ブーストごとに独自のキャンペーン、広告セット、広告が作成されます。Meta ですでに運用しているキャンペーンまたは広告セットにブーストを追加するには、attachTo を含むネスト形式で送信してください。
attachTo.campaignId: ブーストはそのキャンペーン内に新しい広告セットと広告を作成します。budget、targeting、bidAmountは通常どおり送信してください。これらは新しい広告セットに適用されます。attachTo.adSetId: ブーストはその広告セット内に広告のみを作成します。広告セットが属するキャンペーンのattachTo.campaignIdも送信してください。budget、targeting、platformOptions.facebook.bidAmountは省略してください。広告セットは独自の設定を維持します。これらのいずれかを送信すると、code: 101とともに400が返されます。
{
"accountId": "123456789",
"postId": "Ut1fWU6XkqkMayHGnJZ",
"goal": "engagement",
"attachTo": { "campaignId": "120210000000000001", "adSetId": "120210000000000002" },
"platformOptions": { "facebook": { "adName": "November boost" } }
}
- キャンペーンまたは広告セットは
accountIdで指定した広告アカウント内にあり、かつ他のユーザーのブーストに属していない必要があります。そうでない場合、リクエストは400を返します。また、Facebook のブーストは Instagram のブーストが作成したキャンペーンに追加できず、その逆も同様です。 attachToは、新しいキャンペーンに設定されるbudget.level: "campaign"、specialAdCategories、adSetBudgetSharingEnabledと組み合わせることはできません。これらを送信するとcode: 101が返されます。- ブーストを一時停止または有効化しても、変更されるのはブーストが作成したもの(広告と、ブーストが作成した場合は広告セット)のみです。
attachToで指定したキャンペーンまたは広告セットは独自のステータスを維持します。広告は、その上位のキャンペーンと広告セットが有効な間のみ配信されます。これは、プロフィールが削除された場合など、Ayrshare が広告を一時停止する場合にも適用されます。 - ブーストが失敗しても、
attachToで指定したキャンペーンまたは広告セットが削除されることはありません。 - 追加先の広告セットが予算を保持するキャンペーン(キャンペーン予算)内にある場合、履歴はキャンペーン予算を使用する他の広告と同様にブーストを報告します。
budgetDailyにはブーストの配分ではなくキャンペーン予算全体が表示され、通算キャンペーン予算が使い切られると、次回の夜間更新後に、そのキャンペーン内で Ayrshare が追跡しているすべての広告にdeliveryStatus: "COMPLETED"が表示されます。これには配信予定の広告や審査中の広告も含まれます。却下された広告はREJECTEDのままです。
リンクの代わりに会話を開く
ブーストのボタンで、ウェブページの代わりにお客様のビジネスとのチャットを開くことができます。callToAction.destination を含むネスト形式で送信し、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またはinteractionsの広告目標を使用してください。広告は会話向けに最適化され、Meta はチャットを開始する可能性が高いユーザーに広告を表示します。その他の目標ではcode: 101とともに400が返されます。callToAction.typeは、表のとおり destination と一致する必要があります。大文字・小文字は問いません。- ボタンはページではなくチャットを開くため、
callToAction.linkとcallToAction.linkTitleはdestinationと一緒に送信できません。destinationがない場合、linkは引き続き必須です。 - ユーザーは、プロフィールにリンクされたアカウントにメッセージを送信します。
whatsappの場合、そのアカウントの Facebook Page に Meta で WhatsApp Business の電話番号が接続されている必要があります。 destinationはattachTo.adSetIdと組み合わせることはできません。既存の広告セットはすでに設定されている destination を維持します。attachTo.campaignIdを使用する場合、キャンペーンには Meta のOUTCOME_ENGAGEMENT目的が設定されている必要があります。そうでない場合、リクエストはcode: 101とともに400を返します。- レスポンスとブーストされた広告の取得は、
destinationを含むcallToActionを返します。
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"
}