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

# 受众成员

> 发送电子邮件、电话或其他标识符的 SHA-256 哈希，向 Instagram 客户名单受众添加或移除人员。

向通过[创建受众](https://www.ayrshare.com/docs/apis/ads/instagram/create-audience.md)创建的客户名单受众（`type: customerList`）添加人员，或将其移除。你以规范化标识符的 SHA-256 哈希形式发送每个人；Meta 将哈希与账户匹配；原始值永远不会离开你的系统。

`DELETE /ads/instagram/audiences/{id}/users` 接受相同的请求体，改为移除这些人员。

<ul>
  <li>当 Meta 匹配到至少 100 人后，名单即可用于推广，这最多可能需要 48 小时。届时[受众](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md)会显示 `status.ready`。</li>
  <li>每个请求最多包含 10,000 行，请求体最大 10 MiB。较大的名单请分多个请求发送。</li>
  <li>通过 GraphQL，`addAdAudienceUsers` 和 `removeAdAudienceUsers` 承载的批次较小：一个 `schema` 列时约 900 行，列越多行越少。更大的 GraphQL 请求会收到 `Request body too large.` 请将完整的 10,000 行批次发送到这些 REST 端点。</li>
  <li>如果较大上传中的某个请求失败，之前的请求仍保留在受众中。重新发送失败的请求即可：Meta 会对行去重。</li>
  <li>ID 必须是 `accountId` 指定的广告账户上的自定义受众。任何其他 ID 都会返回带有 `code: 101` 的 `400`。</li>
</ul>

## 哈希标识符属于个人数据

根据 GDPR 及类似法律，经过哈希处理的电子邮件或电话号码仍属于个人数据。上传名单时：

<ul>
  <li>**你是数据控制者。** 你需要合法依据（通常是名单中人员的同意）才能将他们的数据用于广告，这是你的隐私政策和 Meta 的 [Custom Audience 条款](https://www.facebook.com/legal/terms/customaudience)所要求的。</li>
  <li>**Ayrshare 是数据处理者。** 我们将哈希传递给 Meta，除计数外不保留任何内容：请求体中的任何行都不会被记录、缓存或存储，响应也绝不会回显任何行。</li>
  <li>**你在发送前进行哈希。** Ayrshare 绝不会替你进行哈希。不是哈希的值会在向 Meta 发送任何内容之前被拒绝。</li>
</ul>

### 如何进行哈希

按照 Meta 的[客户名单规则](https://developers.facebook.com/docs/marketing-api/audiences/guides/custom-audiences#hash)规范化每个值，然后用 SHA-256 进行哈希，并以 64 个小写十六进制字符发送结果。简而言之：

<ul>
  <li>`EMAIL`：去除空格并转为小写，例如 `jane@example.com`。</li>
  <li>`PHONE`：仅数字，包含国家代码，不带前导零或 `+`，例如 `14155551234`。</li>
  <li>`FN`、`LN`、`CT`、`ST`、`COUNTRY`：小写，不含标点或空格；`COUNTRY` 使用两个字母的代码；美国州的 `ST` 使用两个字母的代码，其他情况使用地区名称。</li>
  <li>`ZIP`：小写，不含空格；美国邮编取前五位数字。</li>
  <li>`GEN`：`m` 或 `f`。`DOBY`：四位数年份。`DOBM` 和 `DOBD`：两位数字。</li>
  <li>`FI`：名字的首字母，小写。</li>
</ul>

Meta 的页面提供了完整规则，包括其他国家格式的规则。

## 请求头参数

**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/instagram/create-audience.md)或[受众](https://www.ayrshare.com/docs/apis/ads/instagram/get-audiences.md)。

## 请求体参数

**accountId** `string` *required*

受众所属的广告账户，带或不带 `act_` 前缀均可。

**schema** `array` *required*

每列中的标识符，按顺序排列。支持：`EMAIL`、`PHONE`、`GEN`、`DOBY`、`DOBM`、`DOBD`、`FN`、`LN`、`FI`、`CT`、`ST`、`ZIP`、`COUNTRY`。Meta 接受未经哈希的 `MADID`、`EXTERN_ID` 和 `PAGEUID`，因此这里不接受它们。

**data** `array` *required*

每人一行：一个数组，每个 `schema` 列对应一个 SHA-256 哈希，以 64 个小写十六进制字符表示。最多 10,000 行。

不是此类哈希的单元格、宽度错误的行或不受支持的键，会在向 Meta 发送任何内容之前返回带有 `code: 101` 的 `400`。消息会指明行和列，但绝不包含值，例如 `data[1][0] (EMAIL) is not a hash: expected 64 lowercase hex characters.`

## 响应

仅包含计数：

<ul>
  <li>`received`：Meta 接收的行数。</li>
  <li>`invalid`：Meta 无法读取的行数。</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/instagram/audiences/23851234567890123/users \
-d '{"accountId": "1234567890", "schema": ["EMAIL", "PHONE"], "data": [["5f4dcc3b5aa765d61d8327deb882cf99b8f0e2e1f6b0d3c0a9b3b2f1e0d9c8b7", "a3f1c2d4e5f60718293a4b5c6d7e8f9012345678abcdef0123456789abcdef01"]]}'
```

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

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

```json 200: Success theme={"system"}
{
  "status": "success",
  "id": "23851234567890123",
  "received": 1,
  "invalid": 0,
  "batches": 1
}
```

```json 400: A raw value 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[0][0] (EMAIL) is not a hash: expected 64 lowercase hex characters."
}
```

```json 400: Too many rows 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 has 12000 rows; the limit is 10000 per request."
}
```

```json 400: Not an audience of this account 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 23851234567890123 is not a custom audience of ad account 123456789."
}
```

```json 413: Body over 10 MiB theme={"system"}
{
  "action": "request",
  "status": "error",
  "code": 525,
  "message": "The request body is too large. Please reduce the size of the request."
}
```

```json 400: Meta refused the upload theme={"system"}
{
  "action": "ads",
  "status": "error",
  "code": 369,
  "message": "Unable to add people to the audience. Please try again.",
  "details": "Meta's reason"
}
```


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