API 參考
建立護欄指派
將一個防護欄附加至標準 API 金鑰或帳戶成員。
將一個防護欄附加至標準 API 金鑰或帳戶成員。
端點
- 基礎 URL
https://runapi.ai- API 版本
v1- 身份驗證
Authorization: Bearer YOUR_MANAGEMENT_API_KEY
02
JSON 內容請求
僅在列出的請求位置傳送值。
JSON 內文3 個欄位
account_user_idstring
選填
帳戶成員前綴 ID。此目標需要帳戶管理員。
api_token_idstring
選填
標準 API 金鑰前綴 ID。請提供唯一的目標 ID。
guardrail_idstring
必填
Guardrail 前綴 ID。
03
HTTP 201成功回應
POST /api/v1/guardrail_assignments
JSON
{
"account_user_id": null,
"api_token_id": "token_123",
"created_at": "2026-07-27T10:00:00.000Z",
"guardrail_id": "guardrail_123",
"id": "guardrail_assignment_123"
}
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","api_token_id":"token_123"}'