> ## 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.