curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"accountId": "1234567890",
"schema": [
"EMAIL",
"PHONE"
],
"data": [
[
"5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7",
"a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"
]
]
})
})
.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",
"schema": [
"EMAIL",
"PHONE"
],
"data": [
[
"5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7",
"a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"
]
]
}
r = requests.post('https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "23851234567890123",
"received": 1,
"invalid": 0,
"batches": 1
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data[0][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data has 12000 rows; the limit is 10000 per request."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 23851234567890123 is not a custom audience of ad account 123456789."
}
{
"action": "request",
"status": "error",
"code": 525,
"message": "The request body is too large. Please reduce the size of the request."
}
{
"action": "ads",
"status": "error",
"code": 369,
"message": "Unable to add people to the audience. Please try again.",
"details": "Meta's reason"
}
Facebook Ads
Thành viên đối tượng
Thêm hoặc xóa người khỏi đối tượng danh sách khách hàng Facebook bằng cách gửi hàm băm SHA-256 của email, số điện thoại hoặc định danh khác của họ.
POST
/
ads
/
facebook
/
audiences
/
{id}
/
users
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"accountId": "1234567890",
"schema": [
"EMAIL",
"PHONE"
],
"data": [
[
"5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7",
"a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"
]
]
})
})
.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",
"schema": [
"EMAIL",
"PHONE"
],
"data": [
[
"5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7",
"a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"
]
]
}
r = requests.post('https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "23851234567890123",
"received": 1,
"invalid": 0,
"batches": 1
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data[0][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data has 12000 rows; the limit is 10000 per request."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 23851234567890123 is not a custom audience of ad account 123456789."
}
{
"action": "request",
"status": "error",
"code": 525,
"message": "The request body is too large. Please reduce the size of the request."
}
{
"action": "ads",
"status": "error",
"code": 369,
"message": "Unable to add people to the audience. Please try again.",
"details": "Meta's reason"
}
Thêm người vào một đối tượng danh sách khách hàng được tạo bằng Tạo đối tượng (
type: customerList), hoặc xóa họ. Bạn gửi mỗi người dưới dạng các hàm băm SHA-256 của định danh đã chuẩn hóa; Meta đối chiếu các hàm băm với tài khoản; giá trị gốc không bao giờ rời khỏi hệ thống của bạn.
DELETE /ads/facebook/audiences/{id}/users nhận cùng body và xóa những người đó thay vì thêm.
- Một danh sách có thể dùng trong lượt boost khi Meta đã khớp được ít nhất 100 người, việc này có thể mất tới 48 giờ. Đối tượng hiển thị
status.readykhi đã sẵn sàng. - Mỗi yêu cầu chứa tối đa 10.000 hàng và body tối đa 10 MiB. Gửi danh sách lớn hơn thành nhiều yêu cầu.
- Qua GraphQL,
addAdAudienceUsersvàremoveAdAudienceUserschứa lô nhỏ hơn: khoảng 900 hàng với một cộtschema, ít hơn khi có nhiều cột. Yêu cầu GraphQL lớn hơn sẽ nhậnRequest body too large.Hãy gửi các lô đầy đủ 10.000 hàng tới các endpoint REST này. - Nếu một yêu cầu trong lần tải lên lớn bị lỗi, các yêu cầu trước đó vẫn nằm trong đối tượng. Gửi lại yêu cầu bị lỗi: Meta loại bỏ các hàng trùng lặp.
- Id phải là một đối tượng tùy chỉnh trên tài khoản quảng cáo được chỉ định bởi
accountId. Bất kỳ id nào khác sẽ trả về400vớicode: 101.
Định danh đã băm là dữ liệu cá nhân
Email hoặc số điện thoại đã băm vẫn là dữ liệu cá nhân theo GDPR và các luật tương tự. Khi bạn tải lên một danh sách:- Bạn là bên kiểm soát dữ liệu. Bạn cần một cơ sở pháp lý, thường là sự đồng ý của những người trong danh sách, để dùng dữ liệu của họ cho quảng cáo, như chính sách quyền riêng tư của bạn và điều khoản Custom Audience của Meta yêu cầu.
- Ayrshare là bên xử lý. Chúng tôi chuyển các hàm băm tới Meta và không giữ lại gì ngoài số lượng: không hàng nào trong body được ghi log, lưu đệm hay lưu trữ, và phản hồi không bao giờ lặp lại một hàng.
- Bạn băm trước khi gửi. Ayrshare không bao giờ băm thay bạn. Giá trị không phải hàm băm sẽ bị từ chối trước khi bất cứ thứ gì được gửi tới Meta.
Cách băm
Chuẩn hóa từng giá trị theo quy tắc danh sách khách hàng của Meta, sau đó băm bằng SHA-256 và gửi kết quả dưới dạng 64 ký tự hex viết thường. Tóm tắt:EMAIL: bỏ khoảng trắng và chuyển sang chữ thường, ví dụjane@example.com.PHONE: chỉ chữ số, có mã quốc gia và không có số 0 đứng đầu hay+, ví dụ14155551234.FN,LN,CT,ST,COUNTRY: chữ thường, không dấu câu hay khoảng trắng;COUNTRYlà mã hai chữ cái;STlà mã hai chữ cái với tiểu bang Hoa Kỳ, nếu không thì là tên vùng.ZIP: chữ thường, không khoảng trắng; năm chữ số đầu với mã Hoa Kỳ.GEN:mhoặcf.DOBY: năm bốn chữ số.DOBMvàDOBD: hai chữ số.FI: chữ cái đầu của tên, viết thường.
Tham số Header
Tham số đường dẫn
Id đối tượng danh sách khách hàng, lấy từ Tạo đối tượng hoặc Đối tượng.
Tham số Body
Định danh trong mỗi cột, theo thứ tự. Hỗ trợ:
EMAIL, PHONE, GEN, DOBY, DOBM, DOBD, FN, LN, FI, CT, ST, ZIP, COUNTRY. Meta nhận MADID, EXTERN_ID và PAGEUID ở dạng chưa băm, nên chúng không được chấp nhận ở đây.Mỗi người một hàng: một mảng có một hàm băm SHA-256 cho mỗi cột
schema, dưới dạng 64 ký tự hex viết thường. Tối đa 10.000 hàng.Một ô không phải hàm băm như vậy, một hàng sai độ rộng hoặc một khóa không được hỗ trợ sẽ trả về 400 với code: 101 trước khi bất cứ thứ gì được gửi tới Meta. Thông báo nêu hàng và cột, không bao giờ nêu giá trị, ví dụ data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters.Phản hồi
Chỉ có số lượng:received: số hàng Meta đã nhận.invalid: số hàng Meta không đọc được.batches: số lần tải lên dùng để gửi các hàng.
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"accountId": "1234567890",
"schema": [
"EMAIL",
"PHONE"
],
"data": [
[
"5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7",
"a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"
]
]
})
})
.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",
"schema": [
"EMAIL",
"PHONE"
],
"data": [
[
"5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7",
"a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"
]
]
}
r = requests.post('https://api.ayrshare.com/api/ads/facebook/audiences/23851234567890123/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "23851234567890123",
"received": 1,
"invalid": 0,
"batches": 1
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data[0][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "data has 12000 rows; the limit is 10000 per request."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 23851234567890123 is not a custom audience of ad account 123456789."
}
{
"action": "request",
"status": "error",
"code": 525,
"message": "The request body is too large. Please reduce the size of the request."
}
{
"action": "ads",
"status": "error",
"code": 369,
"message": "Unable to add people to the audience. Please try again.",
"details": "Meta's reason"
}