curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/instagram/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/instagram/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/instagram/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"
}
Instagram Ads
オーディエンスメンバー
メールや電話番号などの SHA-256 ハッシュを送り、Instagram 顧客リストオーディエンスに人を追加・削除します。
POST
/
ads
/
instagram
/
audiences
/
{id}
/
users
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/instagram/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/instagram/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/instagram/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"
}
オーディエンスを作成で作成した顧客リストオーディエンス(
type: customerList)に人を追加、または削除します。各人を正規化した識別子の SHA-256 ハッシュとして送ります。Meta がハッシュをアカウントと照合し、元の値がお使いのシステムの外に出ることはありません。
DELETE /ads/instagram/audiences/{id}/users は同じボディを受け付け、代わりに人を削除します。
- Meta が 100 人以上をマッチングすると、リストをブーストで使えるようになります。これには最大 48 時間かかることがあります。その時点でオーディエンスに
status.readyが表示されます。 - 各リクエストは最大 10,000 行、ボディは最大 10 MiB です。それより大きなリストは複数のリクエストに分けて送ってください。
- GraphQL では、
addAdAudienceUsersとremoveAdAudienceUsersのバッチは小さくなります。schema列が 1 つの場合は約 900 行で、列が増えるほど少なくなります。それより大きな GraphQL リクエストにはRequest body too large.が返ります。10,000 行のフルバッチはこれらの REST エンドポイントに送ってください。 - 大きなアップロードの途中で 1 つのリクエストが失敗しても、それより前のリクエストはオーディエンスに残ります。失敗したリクエストを再送してください。Meta が重複行を除外します。
- ID は
accountIdで指定した広告アカウントのカスタムオーディエンスである必要があります。それ以外の ID ではcode: 101付きの400が返ります。
ハッシュ化した識別子は個人データです
ハッシュ化したメールアドレスや電話番号も、GDPR などの法律では個人データです。リストをアップロードするときは、次の点に注意してください。- データ管理者はお客様です。 リストに含まれる人のデータを広告に使うには、プライバシーポリシーと Meta の Custom Audience 規約が求めるとおり、法的根拠(通常はリストに含まれる人の同意)が必要です。
- Ayrshare は処理者です。 ハッシュを Meta に渡し、件数以外は何も保持しません。ボディの行がログ、キャッシュ、保存されることはなく、レスポンスが行を返すこともありません。
- 送信前にお客様がハッシュ化します。 Ayrshare が代わりにハッシュ化することはありません。ハッシュでない値は、Meta に何も送信される前に拒否されます。
ハッシュ化の方法
Meta の顧客リストのルールに従って各値を正規化し、SHA-256 でハッシュ化して、結果を小文字の 16 進数 64 文字で送ります。概要は次のとおりです。EMAIL: 空白を削除して小文字にします。例:jane@example.com。PHONE: 数字のみで、国番号を含め、先頭のゼロや+は付けません。例:14155551234。FN、LN、CT、ST、COUNTRY: 小文字で、句読点や空白は付けません。COUNTRYは 2 文字のコード、STは米国の州なら 2 文字のコード、それ以外は地域名です。ZIP: 小文字で、空白は付けません。米国のコードは最初の 5 桁です。GEN:mまたはf。DOBY: 4 桁の年。DOBMとDOBD: 2 桁。FI: 名の頭文字(小文字)。
ヘッダーパラメータ
パスパラメータ
顧客リストオーディエンスの ID。オーディエンスを作成またはオーディエンスから取得します。
ボディパラメータ
各列の識別子(順番どおり)。対応:
EMAIL、PHONE、GEN、DOBY、DOBM、DOBD、FN、LN、FI、CT、ST、ZIP、COUNTRY。Meta は MADID、EXTERN_ID、PAGEUID をハッシュ化せずに受け取るため、ここでは受け付けません。1 人につき 1 行:
schema の列ごとに 1 つの SHA-256 ハッシュを含む配列で、各ハッシュは小文字の 16 進数 64 文字です。最大 10,000 行。そのようなハッシュでないセル、幅が正しくない行、またはサポートされていないキーがあると、Meta に何も送信される前に code: 101 付きの 400 が返ります。メッセージには行と列が示され、値は示されません。例: data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters.レスポンス
件数のみを返します。received: Meta が受け付けた行。invalid: Meta が読み取れなかった行。batches: 行を送信したアップロードの回数。
curl \
-H "Authorization: Bearer API_KEY" \
-H "Content-Type: application/json" \
-X POST https://api.ayrshare.com/api/ads/instagram/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
const API_KEY = "API_KEY";
fetch("https://api.ayrshare.com/api/ads/instagram/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/instagram/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"
}