创建管理员角色接口

创建管理员角色,同时指定管理权限、角色成员和可管理的人员范围。permissions 填写权限目录中的编码,member_ids 填写加入此角色的用户标识。

所需权限

所需权限资源Scope资源服务
管理员角色管理(管理)admin-rolesadmin.v1.admin-roles.manageqwenwork-biz-service

POST /api/openapi/v1/admin-roles

认证与请求头

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

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

请求参数

名称位置类型必填说明示例
Idempotency-Keyheaderstring必填本次写操作的幂等键。同一操作重试时复用相同键和请求内容,避免重复处理。"<string>"
descriptionbodystring管理员角色的用途说明。"<string>"
member_idsbodyarray | null必填加入该管理员角色的用户标识列表。["<string>"]
namebodystring必填管理员角色的名称。"<string>"
permissionsbodyarray | null必填角色授予的管理后台权限编码列表。["<string>"]
scopesbodyarray | null必填此管理员角色能够管理的用户、部门和用户组范围。[{"include_descendants":false,"subject_id":"<string>","subject_type":"<string>"}]
scopes[].include_descendantsbodyboolean选择部门时,是否同时包含该部门的下级部门。false
scopes[].subject_idbodystring必填所选用户、部门或用户组的标识,与 subject_type 配合使用。"<string>"
scopes[].subject_typebodystring必填范围对象类型:user 为用户,org_unit 为部门,user_group 为用户组。"<string>"

请求示例

将 <BASE_URL> 替换为企业部署的千问办公 API 服务地址,并填写实际参数。示例中的占位值不能直接用于请求。

curl --request POST --url '<BASE_URL>/api/openapi/v1/admin-roles' --header 'Authorization: Bearer <API_KEY>' --header 'Idempotency-Key: <UNIQUE_REQUEST_ID>' --header 'Content-Type: application/json' --data '{  "description": "<string>",  "member_ids": ["<string>"  ],  "name": "<string>",  "permissions": ["<string>"  ],  "scopes": [{"include_descendants": false,"subject_id": "<string>","subject_type": "<string>"}  ]}'

响应

201 创建成功,返回新建的记录。

名称类型必填说明示例
created_atstring · date-time此记录的创建时间。"2026-08-27T10:00:00Z"
descriptionstring管理员角色的用途说明。"<string>"
idstring此记录的唯一标识,查询、更新或删除对应记录时使用。"<string>"
member_idsarray | null加入该管理员角色的用户标识列表。["<string>"]
namestring管理员角色的名称。"<string>"
permissionsarray | null角色授予的管理后台权限编码列表。["<string>"]
scopesarray | null此管理员角色能够管理的用户、部门和用户组范围。[{"include_descendants":false,"subject_id":"<string>","subject_type":"<string>"}]
scopes[].include_descendantsboolean选择部门时,是否同时包含该部门的下级部门。false
scopes[].subject_idstring所选用户、部门或用户组的标识,与 subject_type 配合使用。"<string>"
scopes[].subject_typestring范围对象类型:user 为用户,org_unit 为部门,user_group 为用户组。"<string>"
systemboolean是否为系统内置角色。false
updated_atstring · date-time此记录最后一次更新的时间。"2026-08-27T10:00:00Z"
{
  "created_at": "2026-08-27T10:00:00Z",
  "description": "<string>",
  "id": "<string>",
  "member_ids": [
    "<string>"
  ],
  "name": "<string>",
  "permissions": [
    "<string>"
  ],
  "scopes": [
    {
      "include_descendants": false,
      "subject_id": "<string>",
      "subject_type": "<string>"
    }
  ],
  "system": false,
  "updated_at": "2026-08-27T10:00:00Z"
}

default 请求失败,返回错误码和错误详情。

名称类型必填说明示例
codestring用于程序判断错误原因的稳定业务错误码。"<string>"
detailstring便于阅读的错误说明。"<string>"
detailsOpenapiErrorDetails字段校验失败时的详细信息。{"field":"<string>","reason":"<string>","suggestion":"<string>"}
details.fieldstring未通过校验的请求字段。"<string>"
details.reasonstring稳定的校验失败原因,用于判断字段为何不合法。"<string>"
details.suggestionstring建议采用的规范化字段值。"<string>"
errorstring稳定的 HTTP 错误类型。"<string>"
{
  "code": "<string>",
  "detail": "<string>",
  "details": {
    "field": "<string>",
    "reason": "<string>",
    "suggestion": "<string>"
  },
  "error": "<string>"
}