curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/facebook/audiences \
-d '{"accountId": "1234567890", "name": "Site visitors 30d", "type": "website", "pixelId": "987654321098765", "retentionDays": 30, "urlContains": ["/pricing"]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"accountId": "1234567890",
"name": "Site visitors 30d",
"type": "website",
"pixelId": "987654321098765",
"retentionDays": 30,
"urlContains": [
"/pricing"
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY', 'Content-Type': 'application/json'}
payload = {
"accountId": "1234567890",
"name": "Site visitors 30d",
"type": "website",
"pixelId": "987654321098765",
"retentionDays": 30,
"urlContains": [
"/pricing"
]
}
r = requests.post('https://api.ayrshare.com/api/ads/facebook/audiences', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"audience": {
"id": "23851234567890123",
"name": "Site visitors 30d",
"type": "website",
"size": null,
"status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
"created": "2026-10-29T10:05:00.000Z"
}
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "ratio is not a recognised field."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "Creating a custom audience needs the Custom Audience terms accepted on ad account act_123456789. A person with a role on the account accepts them at https://business.facebook.com/ads/manage/customaudiences/tos/?act=123456789"
}
{
"action": "ads",
"status": "error",
"code": 369,
"message": "Unable to create the audience. Please try again.",
"details": "Meta's reason"
}
Facebook Ads
オーディエンスを作成
サイト訪問者、エンゲージした人、類似、顧客リストの Facebook カスタムオーディエンスを作成し、ブーストで含める・除外します。
POST
/
ads
/
facebook
/
audiences
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/facebook/audiences \
-d '{"accountId": "1234567890", "name": "Site visitors 30d", "type": "website", "pixelId": "987654321098765", "retentionDays": 30, "urlContains": ["/pricing"]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"accountId": "1234567890",
"name": "Site visitors 30d",
"type": "website",
"pixelId": "987654321098765",
"retentionDays": 30,
"urlContains": [
"/pricing"
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY', 'Content-Type': 'application/json'}
payload = {
"accountId": "1234567890",
"name": "Site visitors 30d",
"type": "website",
"pixelId": "987654321098765",
"retentionDays": 30,
"urlContains": [
"/pricing"
]
}
r = requests.post('https://api.ayrshare.com/api/ads/facebook/audiences', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"audience": {
"id": "23851234567890123",
"name": "Site visitors 30d",
"type": "website",
"size": null,
"status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
"created": "2026-10-29T10:05:00.000Z"
}
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "ratio is not a recognised field."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "Creating a custom audience needs the Custom Audience terms accepted on ad account act_123456789. A person with a role on the account accepts them at https://business.facebook.com/ads/manage/customaudiences/tos/?act=123456789"
}
{
"action": "ads",
"status": "error",
"code": 369,
"message": "Unable to create the audience. Please try again.",
"details": "Meta's reason"
}
Facebook 広告アカウントにカスタムオーディエンスを作成します。
類似オーディエンスには独自の国がありません。対象者はブーストの
顧客リストは空の状態で作成されます。オーディエンスメンバーで人を追加します。ハッシュ化した識別子も個人データです。リストをアップロードする前にそのページを読んでください。
type で選べる 4 種類に対応しています。
website: Meta ピクセルがサイト上で検出した人。engagement: Facebook ページ、Instagram アカウント、または動画にエンゲージした人。lookalike: 既存のオーディエンスに似た人。customerList: 独自の人物リスト。オーディエンスメンバーからハッシュ化した識別子で追加します。
audience に status.ready: false として返されます。Meta はその後数時間でオーディエンスを作成します。一覧表示して status.ready が true になったことを確認し、投稿をブーストするときにその id を targeting.audiences または targeting.excludedAudiences に指定します。
オーディエンスを作成または使用する前に、広告アカウントで役割を持つユーザーが Meta の Custom Audience 規約に一度同意する必要があります。同意は
https://business.facebook.com/ads/manage/customaudiences/tos/?act=<ad account id> で行います。Ayrshare が代わりに同意することはできません。同意するまで、このエンドポイントは code: 101 を含む 400 を返し、details にアカウントと規約に同意するページが示されます。同意済みかどうかは、広告アカウントの tosAccepted.customAudienceTos で確認できます。Meta は、住宅、雇用、金融の広告で類似オーディエンスを許可していません。これらの特別な広告カテゴリのブーストでは、ウェブサイト、エンゲージメント、顧客リストのオーディエンスを含めたり除外したりできますが、類似オーディエンスは使用できません。
ヘッダーパラメータ
ボディパラメータ
すべてのtype で次のパラメータを使用します。
オーディエンスを作成する広告アカウント。広告アカウントから取得し、
act_ プレフィックスの有無は問いません。website、engagement、lookalike、customerList のいずれか。各タイプは以下に示す専用のフィールドのみを受け付けます。別のタイプのフィールドを指定すると、そのフィールド名を示す code: 101 付きの 400 が返ります。新しいオーディエンスごとの新しい一意の値(UUID など)。同じキーでリクエストを繰り返すと、Ayrshare は
idempotentReplayed: true を付けた最初のレスポンスを返し、2 つ目のオーディエンスは作成しません。キーは代わりに Idempotency-Key ヘッダーで送ることもできます。両方を送る場合は一致させる必要があります。別のリクエストでキーを再利用した場合や、最初のリクエストがまだ処理中の場合は 409 が返ります。503 はキーを確保できず何も作成されなかったことを意味します。後で同じキーで再試行してください。ウェブサイトオーディエンス
エンゲージメントオーディエンス
数えるエンゲージメント。値は Meta 独自の名前で、
source によって異なります。page:page_engaged,page_visited,page_liked,page_messaged,page_cta_clicked,page_or_post_save,page_post_interactioninstagram:ig_business_profile_all,ig_business_profile_engaged,ig_business_profile_visit,ig_business_profile_ad_saved,ig_user_messaged_business,ig_ad_like,ig_ad_comment,ig_ad_share,ig_ad_save,ig_ad_cta_click,ig_ad_carousel_swipe,ig_organic_like,ig_organic_comment,ig_organic_share,ig_organic_save,ig_organic_swipe,ig_organic_carousel_swipevideo:video_watched,video_completed,video_view_10s,video_view_15s,video_view_25_percent,video_view_50_percent,video_view_75_percent
code: 101 付きの 400 が返ります。類似オーディエンス
似た人を探す元のオーディエンス。オーディエンスから取得します。Meta には 100 人以上が必要です。
targeting.locations で指定した国から選ばれます。country を送ると code: 101 付きの 400 が返ります。Meta が類似オーディエンスを作成するには数時間かかります。
顧客リストオーディエンス
リストのデータの入手元(Meta の用語):
USER_PROVIDED_ONLY(本人から提供)、PARTNER_PROVIDED_ONLY(パートナーから提供)、または BOTH_USER_AND_PARTNER_PROVIDED。curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/facebook/audiences \
-d '{"accountId": "1234567890", "name": "Site visitors 30d", "type": "website", "pixelId": "987654321098765", "retentionDays": 30, "urlContains": ["/pricing"]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"accountId": "1234567890",
"name": "Site visitors 30d",
"type": "website",
"pixelId": "987654321098765",
"retentionDays": 30,
"urlContains": [
"/pricing"
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
headers = {'Authorization': 'Bearer API_KEY', 'Content-Type': 'application/json'}
payload = {
"accountId": "1234567890",
"name": "Site visitors 30d",
"type": "website",
"pixelId": "987654321098765",
"retentionDays": 30,
"urlContains": [
"/pricing"
]
}
r = requests.post('https://api.ayrshare.com/api/ads/facebook/audiences', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"audience": {
"id": "23851234567890123",
"name": "Site visitors 30d",
"type": "website",
"size": null,
"status": { "ready": false, "code": 300, "description": "This audience is still being populated." },
"created": "2026-10-29T10:05:00.000Z"
}
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "ratio is not a recognised field."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "Creating a custom audience needs the Custom Audience terms accepted on ad account act_123456789. A person with a role on the account accepts them at https://business.facebook.com/ads/manage/customaudiences/tos/?act=123456789"
}
{
"action": "ads",
"status": "error",
"code": 369,
"message": "Unable to create the audience. Please try again.",
"details": "Meta's reason"
}