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

# 工具审批

> 暂停智能体运行以等待审批，并用公开 API 继续

启用工具审批后，`POST /v1/agent/invoke` 可以以 `status: "awaiting_approval"` 结束。

`run_id` 是公开的请求 id。`thread_id` 是你传入的值，未传入时为 `null`。`pending_tool_approvals` 仅在运行等待审批时出现。每一项包含 `approval_id`、`tool_name`、`summary`、`arguments`、`expires_at` 和 `review_url`。`review_url` 在控制台打开该审批，不是邮件令牌。`denied_tool_calls` 仅在工具被拒绝时出现，`reason` 为 `policy_deny`。响应文本也会包含 `[Waiting for approval: …]`。

流式调用把同样的字段放在最后的 `usage` 事件上。

## 继续运行

使用同一个 `thread_id` 并带上 `decided_tool_approvals`：

```json theme={null}
{
  "agent": "YOUR_AGENT_ID",
  "thread_id": "ticket-42",
  "message": "",
  "decided_tool_approvals": [{ "approval_id": "APPROVAL_ID" }]
}
```

如果省略 `decided_tool_approvals` 并复用该线程，Fetch Hive 会加载该线程上的审批。

## 用 API 密钥决定

```bash theme={null}
curl 'https://api.fetchhive.com/v1/public/workspaces/WORKSPACE_ID/tool_action_approvals/APPROVAL_ID/decide' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  --data-raw '{ "decision": "allow_once" }'
```

`decision` 为 `allow_once` 或 `deny`。`always_allow` 返回 `422`，错误码为 `always_allow_requires_dashboard`。再次决定返回 `409`。已过期的审批返回 `410`。不属于该 API 密钥工作区的审批返回 `404`。

列出待审批项：

```bash theme={null}
curl 'https://api.fetchhive.com/v1/public/workspaces/WORKSPACE_ID/tool_action_approvals' \
  -H 'Authorization: Bearer YOUR_API_KEY'
```

`status` 默认为 `pending`。可用 `agent_id`、`run_id` 和 `request_id` 筛选。分页使用 `cursor`，每页最多 50 条。

## Webhook

由 webhook 发起的运行在暂停时发送 `agent.awaiting_approval`。载荷包含 `pending_tool_approvals`。运行继续后，`agent.completed` 包含 `resumed_from_run_id`。


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