批量更新成员的名称、角色或直属部门。
users:write
PATCH{域名}/openapi/v1/userscode=0 仅表示请求处理完成,不代表每个成员均更新成功,需根据 failed_items 判断逐项结果。| Header 参数 | 是否必填 | 描述 |
|---|---|---|
Authorization |
是 | 固定取值为 Bearer {access_token}。关于如何获取访问令牌,参考鉴权。 |
Content-Type |
是 | 固定取值为 application/json。 |
| 参数 | 类型 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|---|
|
|
array |
是 |
- |
待更新成员的列表。范围为 1 至 20 个。 每项需至少提供一个定位参数和一个待更新参数。 |
|
|
string |
条件必填 |
- |
待更新成员的 ID。 与 成员 ID 可以通过 “获取成员列表” 接口获取。 |
|
|
string |
条件必填 |
- |
待更新成员的邮箱地址。 与 成员邮箱可以通过 “获取成员列表” 接口获取。 |
|
|
string |
条件必填 |
- |
成员的新名称。 与 |
|
|
string |
条件必填 |
- |
成员的新角色,取值:
与 |
|
|
array |
条件必填 |
- |
成员的新直属部门的 ID,至多传入 1 个 ID。 与 部门 ID 可以通过 “获取单个父部门的子部门” 接口或 ”按关键词搜索部门“ 接口获取。 |
该接口独有的响应参数如下,参数位于 data 中。通用响应参数参考此文档。
| 参数 | 类型 | 描述 |
|---|---|---|
success_count |
int | 更新成功的成员数量。 |
failed_items |
array | 更新失败的成员列表。全部成功时返回 []。 |
failed_items[].index |
int | 更新失败的成员在请求体 users 数组中的索引,从 0 开始。 |
failed_items[].email |
string | 更新失败成员的邮箱。若仅为该成员传入了 user_id,该参数为空。 |
failed_items[].user_id |
string | 更新失败成员的 ID。未成功定位到成员的失败项,例如参数校验失败或邮箱未命中,可能省略该字段。 |
failed_items[].code |
int | 错误码。 |
failed_items[].message |
string | 失败原因。 |
warnings |
array | 非致命问题的提示信息;无提示时省略。 |
仅通过邮箱定位成员:
curl -X PATCH "${HOST}/openapi/v1/users" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"users": [
{
"email": "alice@example.com",
"user_name": "Alice Zhang",
"department_ids": ["20001"]
},
{
"email": "john@example.com",
"role": "admin"
}
]
}'
为单个成员同时传入 user_id 与 email,系统将进行一致性校验:
{
"users": [
{
"user_id": "10001",
"email": "alice@example.com",
"role": "admin"
},
{
"user_id": "10002",
"email": "john@example.com",
"user_name": "John Lee",
"department_ids": []
}
]
}
全部成员更新成功:
{
"code": 0,
"message": "success",
"request_id": "req_xxx",
"data": {
"success_count": 2,
"failed_items": []
}
}
部分成员更新失败:
{
"code": 0,
"message": "success",
"request_id": "req_xxx",
"data": {
"success_count": 1,
"failed_items": [
{
"index": 1,
"email": "john@example.com",
"code": 30007,
"message": "user not found in this tenant"
}
]
}
}
若该接口的请求返回错误码,参考错误码文档进行排查。