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