批量创建企业成员。创建成功后,成员将直接加入企业并处于激活状态,无需通过邀请邮件完成加入或手动激活。
users:write
|
参数 |
类型 |
是否必填 |
描述 |
|---|---|---|---|
users |
array | 是 | 成员数组。单次请求最多传入 100 个成员。 |
users[].email |
string | 是 | 成员的邮箱地址。 |
users[].user_name |
string | 是 | 成员的名称。 |
|
|
string |
是 |
成员的角色,取值:
提示:不支持创建 “超级管理员” 角色。 |
|
|
string |
是 |
成员的账号的初始密码。 长度至少 8 位;不能包含空白字符;大写字母、小写字母、数字、特殊字符四类中至少包含三类。 |
|
参数 |
类型 |
描述 |
|---|---|---|
success_count |
int | 本次请求成功创建或重新激活的成员数量。 |
failed_items |
array | 创建失败的成员列表。全部成员创建成功时返回 []。 |
failed_items[].index |
int | 创建失败的成员在请求中传入的 users 数组中的下标,从 0 开始。 |
failed_items[].email |
string | 创建失败成员的邮箱地址。 |
failed_items[].code |
int | 错误码。详情参考错误码。 |
failed_items[].message |
string | 错误消息,用于说明创建失败的原因。 |
提示
当 code 为 0 且 failed_items 不为空时,表示接口调用成功,但部分成员创建失败。请根据 failed_items 中的 index、email 和错误码定位失败成员,并修正后重试。
curl -X POST "${HOST}/openapi/v1/users/create" \
-H "Authorization: Bearer ${ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"users": [
{
"email": "john@example.com",
"user_name": "John",
"role": "member",
"password": "Aa123456!"
},
{
"email": "bob@example.com",
"user_name": "Bob",
"role": "admin",
"password": "Bb123456!"
}
]
}'
{
"code": 0,
"message": "success",
"request_id": "021xxxxxxxxx",
"data": {
"success_count": 1,
"failed_items": [
{
"index": 1,
"email": "bob@example.com",
"code": 30001,
"message": "user already exists in this tenant"
}
]
}
}