curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/instagram/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/instagram/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/instagram/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"
}
Instagram Ads
创建受众
创建由网站访客、互动用户、类似受众或客户名单组成的 Instagram 自定义受众,用于推广时包含或排除。
POST
/
ads
/
instagram
/
audiences
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/instagram/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/instagram/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/instagram/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"
}
在 Instagram 广告账户上创建自定义受众。支持四种类型,通过
类似受众没有自己的国家:人员来自推广的
客户名单在创建时为空。使用受众成员添加人员。哈希标识符仍然是个人数据:上传名单前请阅读该页面。
type 选择:
website:Meta 像素在你的网站上看到的人。engagement:与 Facebook 主页、Instagram 账户或视频互动过的人。lookalike:与你已有受众相似的人。customerList:你自己的人员名单,通过受众成员用哈希标识符填充。
audience 下返回,status.ready: false。Meta 会在接下来的几个小时内填充它;列出受众以查看 status.ready 何时变为 true,然后在推广帖子时将其 id 用于 targeting.audiences 或 targeting.excludedAudiences。
在创建或使用任何受众之前,广告账户中拥有角色的人员必须在
https://business.facebook.com/ads/manage/customaudiences/tos/?act=<ad account id> 接受一次 Meta 的 Custom Audience 条款。Ayrshare 无法代你接受。在此之前,此端点返回带有 code: 101 的 400,details 会指明账户以及接受条款的页面。广告账户会在 tosAccepted.customAudienceTos 中显示是否已接受。Meta 不允许在住房、就业或金融广告中使用类似受众。属于这些特殊广告类别之一的推广可以包含或排除网站、互动和客户名单受众,但不能使用类似受众。
请求头参数
请求体参数
每种type 都接受以下参数:
要在其上创建受众的广告账户,来自广告账户,带或不带
act_ 前缀均可。website、engagement、lookalike 或 customerList。每种类型只接受下方列出的自身字段。来自其他类型的字段会返回带有 code: 101 的 400 并指明该字段。为每个新受众提供一个新的唯一值,例如 UUID。如果你用相同的键重复请求,Ayrshare 会返回第一次的响应,并标记
idempotentReplayed: true,不会创建第二个受众。你也可以改为在 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/instagram/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/instagram/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/instagram/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"
}