curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "schema": ["EMAIL"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"], ["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
accountId: "5a0d1b2c-0000-4000-8000-000000000003",
schema: ["EMAIL"],
data: [
["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"],
["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
'schema': ['EMAIL'],
'data': [
['5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7'],
['a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01']
]
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "8c1e2f3a-0000-4000-8000-000000000101",
"received": 2,
"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[1][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": "schema takes one key per request on snapchat: send EMAIL, PHONE and MADID in separate requests."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 8c1e2f3a-0000-4000-8000-000000000102 is a lookalike audience; members can be added to or removed from a customerList audience only."
}
Snapchat Ads
受眾成員
傳送電子郵件、電話或行動廣告 ID 的 SHA-256 雜湊,向 Snapchat 顧客名單區隔新增或移除人員。
POST
/
ads
/
snapchat
/
audiences
/
{id}
/
users
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "schema": ["EMAIL"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"], ["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
accountId: "5a0d1b2c-0000-4000-8000-000000000003",
schema: ["EMAIL"],
data: [
["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"],
["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
'schema': ['EMAIL'],
'data': [
['5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7'],
['a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01']
]
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "8c1e2f3a-0000-4000-8000-000000000101",
"received": 2,
"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[1][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": "schema takes one key per request on snapchat: send EMAIL, PHONE and MADID in separate requests."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 8c1e2f3a-0000-4000-8000-000000000102 is a lookalike audience; members can be added to or removed from a customerList audience only."
}
向透過建立受眾(
type: customerList)建立的顧客名單區隔新增人員,或將其移除。你將每個人作為一個正規化識別碼的 SHA-256 雜湊傳送;Snapchat 將雜湊與帳戶進行比對;原始值永遠不會離開你的系統。
DELETE /ads/snapchat/audiences/{id}/users 接受相同的請求體,改為移除這些人員。
- 每個請求一種識別碼:電子郵件、電話和行動廣告 ID 請分別在不同請求中傳送。
- 每個請求最多包含 10,000 列,請求體最大 10 MiB。更大的名單請分多個請求傳送。
- Snapchat 比對到足夠多的人後,區隔即可用於推廣。此時受眾會顯示
status.ready。 - 該 ID 必須是
accountId指定的廣告帳戶上的顧客名單區隔。任何其他 ID(包括已刪除或未知的 ID)都會回傳帶有code: 101的400,且不會傳送任何內容。
雜湊識別碼屬於個人資料
根據 GDPR 及類似法律,經過雜湊處理的電子郵件或電話號碼仍屬於個人資料。上傳名單時:- 你是資料控制者。 你需要合法依據(通常是名單中人員的同意)才能將其資料用於廣告,這也是你的隱私權政策和 Snapchat 廣告條款的要求。
- Ayrshare 是資料處理者。 我們將雜湊傳遞給 Snapchat,除計數外不保留任何內容:請求體中的任何列都不會被記錄、快取或儲存,回應也絕不會回顯任何列。
- 你需要在傳送前進行雜湊。 Ayrshare 絕不會替你進行雜湊。不是雜湊的值會在向 Snapchat 傳送任何內容之前被拒絕。
如何進行雜湊
依照 Snapchat 顧客名單規則的說明正規化每個值,然後使用 SHA-256 進行雜湊,並以 64 個小寫十六進位字元傳送結果。簡而言之:EMAIL:去除空格並轉為小寫,例如jane@example.com。PHONE:僅數字,包含國碼,不帶開頭的00或國內開頭的0,例如14155551234或448444124653。MADID:行動廣告 ID(IDFA 或 Android 廣告 ID),使用小寫並保留連字號。
請求頭參數
路徑參數
請求體參數
每人一列:一個包含此人 SHA-256 雜湊的陣列,格式為 64 個小寫十六進位字元。最多 10,000 列。不是此類雜湊的儲存格、寬度錯誤的列、不受支援的鍵或多個鍵,會在向 Snapchat 傳送任何內容之前回傳帶有
code: 101 的 400。訊息會指出列和欄,但絕不會顯示值,例如 data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters.回應
僅包含計數:received:Snapchat 接收的列數。invalid:Snapchat 未接收的列數。batches:這些列分幾次上傳傳送。
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users \
-d '{"accountId": "5a0d1b2c-0000-4000-8000-000000000003", "schema": ["EMAIL"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"], ["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users", {
method: "POST",
headers: {
"Authorization": `Bearer ${API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
accountId: "5a0d1b2c-0000-4000-8000-000000000003",
schema: ["EMAIL"],
data: [
["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7"],
["a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]
]
})
})
.then((res) => res.json())
.then((json) => console.log(json))
.catch(console.error);
import requests
payload = {
'accountId': '5a0d1b2c-0000-4000-8000-000000000003',
'schema': ['EMAIL'],
'data': [
['5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7'],
['a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01']
]
}
headers = {'Content-Type': 'application/json', 'Authorization': 'Bearer API_KEY'}
r = requests.post('https://api.ayrshare.com/api/ads/snapchat/audiences/8c1e2f3a-0000-4000-8000-000000000101/users', json=payload, headers=headers)
print(r.json())
{
"status": "success",
"id": "8c1e2f3a-0000-4000-8000-000000000101",
"received": 2,
"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[1][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": "schema takes one key per request on snapchat: send EMAIL, PHONE and MADID in separate requests."
}
{
"action": "request",
"status": "error",
"code": 101,
"message": "Missing or incorrect parameters. Please verify with the docs. https://www.ayrshare.com/docs/apis",
"details": "id 8c1e2f3a-0000-4000-8000-000000000102 is a lookalike audience; members can be added to or removed from a customerList audience only."
}