> ## Documentation Index
> Fetch the complete documentation index at: https://www.ayrshare.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 受眾成員

> 傳送電子郵件、電話或行動廣告 ID 的 SHA-256 雜湊，向 Snapchat 顧客名單區隔新增或移除人員。

向透過[建立受眾](https://www.ayrshare.com/docs/apis/ads/snapchat/create-audience.md)（`type: customerList`）建立的顧客名單區隔新增人員，或將其移除。你將每個人作為一個正規化識別碼的 SHA-256 雜湊傳送；Snapchat 將雜湊與帳戶進行比對；原始值永遠不會離開你的系統。

`DELETE /ads/snapchat/audiences/{id}/users` 接受相同的請求體，改為移除這些人員。

<ul>
  <li>每個請求一種識別碼：電子郵件、電話和行動廣告 ID 請分別在不同請求中傳送。</li>
  <li>每個請求最多包含 10,000 列，請求體最大 10 MiB。更大的名單請分多個請求傳送。</li>
  <li>Snapchat 比對到足夠多的人後，區隔即可用於推廣。此時[受眾](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)會顯示 `status.ready`。</li>
  <li>該 ID 必須是 `accountId` 指定的廣告帳戶上的顧客名單區隔。任何其他 ID（包括已刪除或未知的 ID）都會回傳帶有 `code: 101` 的 `400`，且不會傳送任何內容。</li>
</ul>

## 雜湊識別碼屬於個人資料

根據 GDPR 及類似法律，經過雜湊處理的電子郵件或電話號碼仍屬於個人資料。上傳名單時：

<ul>
  <li>**你是資料控制者。** 你需要合法依據（通常是名單中人員的同意）才能將其資料用於廣告，這也是你的隱私權政策和 Snapchat 廣告條款的要求。</li>
  <li>**Ayrshare 是資料處理者。** 我們將雜湊傳遞給 Snapchat，除計數外不保留任何內容：請求體中的任何列都不會被記錄、快取或儲存，回應也絕不會回顯任何列。</li>
  <li>**你需要在傳送前進行雜湊。** Ayrshare 絕不會替你進行雜湊。不是雜湊的值會在向 Snapchat 傳送任何內容之前被拒絕。</li>
</ul>

### 如何進行雜湊

依照 Snapchat [顧客名單規則](https://developers.snap.com/marketing-api/Ads-API/audience-creation/customer-lists)的說明正規化每個值，然後使用 SHA-256 進行雜湊，並以 64 個小寫十六進位字元傳送結果。簡而言之：

<ul>
  <li>`EMAIL`：去除空格並轉為小寫，例如 `jane@example.com`。</li>
  <li>`PHONE`：僅數字，包含國碼，不帶開頭的 `00` 或國內開頭的 `0`，例如 `14155551234` 或 `448444124653`。</li>
  <li>`MADID`：行動廣告 ID（IDFA 或 Android 廣告 ID），使用小寫並保留連字號。</li>
</ul>

## 請求頭參數

**Authorization** `string` *required*

[API Key](https://www.ayrshare.com/docs/apis/overview.md#authorization) of the Primary Profile.

Format: `Authorization: Bearer API_KEY`
**Profile-Key** `string`

[Profile Key](https://www.ayrshare.com/docs/apis/overview.md#profile-key-format) of a User Profile.

Format: `Profile-Key: PROFILE_KEY`

## 路徑參數

**id** `string` *required*

顧客名單區隔 ID，來自[建立受眾](https://www.ayrshare.com/docs/apis/ads/snapchat/create-audience.md)或[受眾](https://www.ayrshare.com/docs/apis/ads/snapchat/get-audiences.md)。

## 請求體參數

**accountId** `string` *required*

區隔所屬的廣告帳戶。

**schema** `array` *required*

列中包含的唯一識別碼：`["EMAIL"]`、`["PHONE"]` 或 `["MADID"]`。這些名稱與 Facebook 和 Instagram 接受的名稱相同。

**data** `array` *required*

每人一列：一個包含此人 SHA-256 雜湊的陣列，格式為 64 個小寫十六進位字元。最多 10,000 列。

不是此類雜湊的儲存格、寬度錯誤的列、不受支援的鍵或多個鍵，會在向 Snapchat 傳送任何內容之前回傳帶有 `code: 101` 的 `400`。訊息會指出列和欄，但絕不會顯示值，例如 `data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters.`

## 回應

僅包含計數：

<ul>
  <li>`received`：Snapchat 接收的列數。</li>
  <li>`invalid`：Snapchat 未接收的列數。</li>
  <li>`batches`：這些列分幾次上傳傳送。</li>
</ul>

```bash cURL theme={"system"}
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"]]}'
```

```javascript JavaScript theme={"system"}
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);
```

```python Python theme={"system"}
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())
```

```json 200: Success theme={"system"}
{
  "status": "success",
  "id": "8c1e2f3a-0000-4000-8000-000000000101",
  "received": 2,
  "invalid": 0,
  "batches": 1
}
```

```json 400: Not a hash theme={"system"}
{
  "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."
}
```

```json 400: More than one identifier theme={"system"}
{
  "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."
}
```

```json 400: Not a customer list theme={"system"}
{
  "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."
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.