API 參考
建立防護規則指派
將一個 Guardrail 附加至標準 API 金鑰、帳戶成員或共享標籤預算。
將一個 Guardrail 附加至標準 API 金鑰、帳戶成員或共享標籤預算。
端點
- 基礎 URL
https://runapi.ai- API 版本
v1- 身分驗證
Authorization: Bearer YOUR_MANAGEMENT_API_KEY
02
JSON 請求內文請求
僅在列出的請求位置中傳送值。
JSON 主體4 個欄位
account_user_idstring
選填
帳戶成員前綴 ID。此目標需要帳戶管理員權限。
api_token_idstring
選填
標準 API 金鑰前綴 ID。api_token_id、account_user_id 或 tag 必須且只能提供一個。
guardrail_idstring
必填
Guardrail 前綴 ID。
tagstring
選填
共享預算中區分大小寫的 key:value 標籤。需要帳戶管理員及總額為正的 block 模式 Guardrail。只能提供一個目標。
03
HTTP 201成功回應
POST /api/v1/guardrail_assignments
JSON
{
"account_user_id": null,
"api_token_id": null,
"created_at": "2026-07-27T10:00:00.000Z",
"guardrail_id": "guardrail_123",
"id": "guardrail_assignment_123",
"tag": "dept:ml"
}
04
HTTP 401錯誤回應 (401)
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Authentication required"
}
05
HTTP 403錯誤回應 (403)
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Management API key required"
}
06
HTTP 400錯誤回應 (400)
回應綱要
JSON
{
"oneOf": [
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
},
{
"properties": {
"error": {
"description": "人類可讀的驗證摘要。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "以公開請求欄位為索引鍵的驗證訊息,每個欄位包含一組人類可讀的字串陣列。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
]
}
回應範例
JSON
{
"error": "page must be an integer"
}
07
HTTP 403錯誤回應 (403)
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Forbidden"
}
08
HTTP 404錯誤回應 (404)
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的錯誤訊息。",
"type": "string"
}
},
"required": [
"error"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Resource not found"
}
09
HTTP 422錯誤回應 (422)
回應綱要
JSON
{
"properties": {
"error": {
"description": "人類可讀的驗證摘要。",
"type": "string"
},
"errors": {
"additionalProperties": {
"items": {
"type": "string"
},
"type": "array"
},
"description": "以公開請求欄位為索引鍵的驗證訊息,每個欄位包含一組人類可讀的字串陣列。",
"type": "object"
}
},
"required": [
"error",
"errors"
],
"type": "object",
"unevaluatedProperties": false
}
回應範例
JSON
{
"error": "Validation failed",
"errors": {
"base": [
"Validation failed"
]
}
}
10
cURL 範例
CURL
curl -X POST https://runapi.ai/api/v1/guardrail_assignments \
-H 'Authorization: Bearer YOUR_MANAGEMENT_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"guardrail_id":"guardrail_123","tag":"dept:ml"}'