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

# 获取、更新或删除策略

> 获取、修改或彻底删除单个护栏策略。

获取、修改或彻底删除单个护栏策略。可见范围:作者本人或所属组织的任意成员。非成员会收到 `404`,以确保团队策略的存在与否不会被泄露。

## 认证

需要具备 `billing` API 密钥权限范围的 Bearer 令牌。

## GET

获取完整的策略快照。

```bash theme={null}
curl https://www.hitheo.ai/api/v1/guardrail-policies/{id} \
  -H "Authorization: Bearer $THEO_API_KEY"
```

```typescript theme={null}
const policy = await theo.guardrails.policies.get(id);
```

## PATCH

更新现有策略的字段。发送 `rules` 会替换整个规则集(规则表在保存时被视为单个文档)。

<ParamField body="name" type="string">策略名称。</ParamField>
<ParamField body="description" type="string">自由文本描述。</ParamField>
<ParamField body="rules" type="object[]">替换用的规则集。</ParamField>
<ParamField body="enabled" type="boolean">暂停/恢复策略,而无需删除。</ParamField>
<ParamField body="is_default" type="boolean">设为/取消默认策略。每个作用域仅能有一个默认策略。</ParamField>

```bash theme={null}
curl -X PATCH https://www.hitheo.ai/api/v1/guardrail-policies/{id} \
  -H "Authorization: Bearer $THEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "enabled": false }'
```

```typescript theme={null}
await theo.guardrails.policies.update(id, { enabled: false });
```

团队作用域的策略需要在当前活动组织上具备 `manageWebhooks` 权限。

## DELETE

彻底删除。会级联移除所有指向该策略的 `api_key_guardrail_policies` 绑定关系——此前已绑定的密钥将恢复为严格的默认选择加入状态(不执行任何护栏)。

```bash theme={null}
curl -X DELETE https://www.hitheo.ai/api/v1/guardrail-policies/{id} \
  -H "Authorization: Bearer $THEO_API_KEY"
```

```typescript theme={null}
await theo.guardrails.policies.delete(id);
```

## 错误

* `400 guardrail_policy_invalid` — PATCH 请求校验失败。
* `404 not_found` — 策略不存在,或调用方无权查看。
* `409 conflict` — 违反了默认策略唯一性约束。


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