创建技能开放策略接口

将 <BASE_URL> 替换为所在企业环境的 API 域名。

  • Scope:admin.v1.skills.manage
  • 权限项:技能管理(skills)
  • 权限类型:管理
  • 接口:POST/api/openapi/v1/skill-policies

认证与请求头

使用应用 API Key 调用。当前接口只校验上方独立 Scope;读取、管理与执行权限互不隐含。

名称位置类型必填说明示例
Authorizationheaderstring是应用 API Key,使用 Bearer 方式传递。Bearer qwk_***
X-Request-Idheaderstring否可选的调用追踪标识;未传入时由服务端生成。req-20260831-001

请求参数

名称位置类型必填说明示例
Idempotency-Keyheaderstring必填-"<string>"
descriptionbodystring否-"<string>"
display_orderbodyinteger · int64否-0
modebodystring必填-"allowlist"
namebodystring必填-"<string>"
resource_idsbodyarray | null必填-["<string>"]
resource_scopebodystring必填-"all"
statusbodystring否-"enabled"
subject_scopebodystring必填-"all_users"
subjectsbodyarray | null必填-[{"include_descendants":false,"subject_id":"<string>","subject_type":"user"}]
surfacesbodyarray | null必填-["<string>"]
valid_frombodystring · date-time否-"2026-08-27T10:00:00Z"
valid_tobodystring · date-time否-"2026-08-27T10:00:00Z"

请求示例

cURL

curl --request POST \
  --url '<BASE_URL>/api/openapi/v1/skill-policies' \
  --header 'Authorization: Bearer <API_KEY>' \
  --header 'Idempotency-Key: <UNIQUE_REQUEST_ID>' \
  --header 'Content-Type: application/json' \
  --data '{
  "description": "<string>",
  "display_order": 0,
  "mode": "allowlist",
  "name": "<string>",
  "resource_ids": [
    "<string>"
  ],
  "resource_scope": "all",
  "status": "enabled",
  "subject_scope": "all_users",
  "subjects": [
    {
      "include_descendants": false,
      "subject_id": "<string>",
      "subject_type": "user"
    }
  ],
  "surfaces": [
    "<string>"
  ],
  "valid_from": "2026-08-27T10:00:00Z",
  "valid_to": "2026-08-27T10:00:00Z"
}'

响应

201 Created

名称类型必填说明示例
created_atstring · date-time是-"2026-08-27T10:00:00Z"
defaultboolean是-false
descriptionstring是-"<string>"
idstring是-"<string>"
modestring是-"<string>"
namestring是-"<string>"
policy_typestring是-"<string>"
resource_countinteger · int64是-0
resource_scopestring是-"<string>"
statusstring是-"<string>"
subject_countinteger · int64是-0
subject_countsobject是-{}
subject_scopestring是-"<string>"
surfacesarray | null是-["<string>"]
updated_atstring · date-time是-"2026-08-27T10:00:00Z"

响应示例

{
  "created_at": "2026-08-27T10:00:00Z",
  "default": false,
  "description": "<string>",
  "id": "<string>",
  "mode": "<string>",
  "name": "<string>",
  "policy_type": "<string>",
  "resource_count": 0,
  "resource_scope": "<string>",
  "status": "<string>",
  "subject_count": 0,
  "subject_counts": {},
  "subject_scope": "<string>",
  "surfaces": [
    "<string>"
  ],
  "updated_at": "2026-08-27T10:00:00Z"
}

default Flat business error

名称类型必填说明示例
codestring否Stable business error code"<string>"
detailstring是Human-readable error description"<string>"
detailsOpenapiErrorDetails否-{"field":"<string>","reason":"<string>","suggestion":"<string>"}
details.fieldstring否Request field that failed validation"<string>"
details.reasonstring否Stable validation failure reason"<string>"
details.suggestionstring否Suggested normalized value"<string>"
errorstring是Stable HTTP error type"<string>"

响应示例

{
  "code": "<string>",
  "detail": "<string>",
  "details": {
    "field": "<string>",
    "reason": "<string>",
    "suggestion": "<string>"
  },
  "error": "<string>"
}