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

# 安全发布

> 分阶段启用 Meta Business Agent，验证每次设置更改，并准备好经过测试的回滚请求。

发布有两个独立的控制项：`rollout.enabled` 决定是否启用代理，`ai_audience` 决定谁可以接收代理回复。

**API 参考：** [GET 获取设置](/api-reference/meta-business-agents/get-settings) · [PUT 替换设置](/api-reference/meta-business-agents/replace-settings)

## 为白名单收件人启用代理

在首次实时 WhatsApp 测试期间，限制受众范围。

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request PUT \
  "https://api.ycloud.com/v2/metaBusinessAgents/$PHONE_NUMBER_ID/settings" \
  --header "X-API-Key: $YCLOUD_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "rollout": {"enabled": true},
    "ai_audience": "ALLOWLISTED_ONLY"
  }'
```

从每个白名单测试号码发送代表性消息，并确认非白名单号码不会收到代理回复。

## 读回有效设置

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl "https://api.ycloud.com/v2/metaBusinessAgents/$PHONE_NUMBER_ID/settings" \
  --header "X-API-Key: $YCLOUD_API_KEY"
```

即使只有一个设置对象，响应也是一个数组。在每次发布更改后验证 `rollout.enabled` 和 `ai_audience`。

## 设置代理预算

预算限制滚动时间窗口内的令牌或 AI 轮次使用量。YCloud 使用 WhatsApp Business 电话号码 ID 来查找关联的 Business Manager。

**API 参考：** [GET 获取预算](/api-reference/meta-business-agents/get-budgets) · [PUT 替换预算](/api-reference/meta-business-agents/replace-budgets)

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request PUT \
  "https://api.ycloud.com/v2/metaBusinessAgents/$PHONE_NUMBER_ID/budgets" \
  --header "X-API-Key: $YCLOUD_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "budgets": [
      {
        "unit_type": "token",
        "time_window": "one_day",
        "max_budget": 10000
      },
      {
        "unit_type": "ai_turn",
        "time_window": "seven_days",
        "max_budget": 500
      }
    ]
  }'
```

`unit_type` 是 `token` 或 `ai_turn`。`time_window` 是 `one_day`、`seven_days`、`fourteen_days` 或 `thirty_days`。`max_budget` 必须是正整数。

`PUT` 替换完整的预算集合。为您想要保留的每个现有预算包含 `budget_id`，并为新预算省略它。每个 `(unit_type, time_window)` 对必须是唯一的。发送 `{"budgets":[]}` 以删除所有限制。在每次替换后读回集合。

## 扩展到全部受众

在白名单发布通过验收测试后，仅更改受众。

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request PUT \
  "https://api.ycloud.com/v2/metaBusinessAgents/$PHONE_NUMBER_ID/settings" \
  --header "X-API-Key: $YCLOUD_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"ai_audience":"EVERYONE"}'
```

省略的设置由 YCloud 保持不变。在将发布视为完成之前，再次读取设置并监控实时对话。

## 在需要时回滚

在扩展受众之前准备好此请求：

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl --request PUT \
  "https://api.ycloud.com/v2/metaBusinessAgents/$PHONE_NUMBER_ID/settings" \
  --header "X-API-Key: $YCLOUD_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{
    "rollout": {"enabled": false},
    "ai_audience": "ALLOWLISTED_ONLY"
  }'
```

回滚后读取有效设置。禁用发布不会删除代理、知识、技能或连接器。

<Warning>
  启用发布会更改实时消息处理。与人工支持团队协调所有权，不要使用全部受众作为完成受限验收测试的替代方案。
</Warning>

<Card title="下一步：操作和故障排除" icon="arrow-right" href="/zh/documentation/meta-business-agent/operate-and-troubleshoot">
  在启动后控制实时对话、处理事件、检查日志并处理故障。
</Card>


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