创建用户
POST
https://open.feishu.cn/open-apis/contact/v3/users
自建应用
应用商店应用无权限调用此接口。
创建用户后,会给用户发送邀请短信/邮件,用户在操作同意后才可访问团队。
返回数据中不返回手机号,如果需要请重新查询用户信息获取手机号。
字段权限要求 :
该接口返回体中存在下列敏感字段,仅当开启对应的权限后才会返回;如果无需获取这些字段,则不建议申请
以应用身份读取通讯录
获取用户基本信息
获取用户组织架构信息
获取用户受雇信息
获取用户邮箱信息
仅自建应用
获取用户手机号
仅自建应用
获取用户 user ID
仅自建应用
以应用身份访问通讯录
历史版本
读取通讯录
错误码
HTTP状态码 | 错误码 | 描述 | 排查建议 |
---|---|---|---|
400 | 41001 | mobile has already exist error | 手机号已存在 |
400 | 41002 | email has already exist error | 邮箱已存在 |
409 | 41003 | user account conflict error | 用户的联系方式属于两个不同的飞书账号,添加失败。建议用户换其它的手机号或邮箱,或是先注销手机号或邮箱对应的帐号,然后再创建或更新,具体注销的流程见帮助中心有关这个错误的详细介绍请参考通用错误码中的介绍 |
400 | 41004 | mobile is invalid error | 手机号不合法,请检查是否是正确的手机号格式 |
400 | 41005 | email is invalid error | 不是合法邮箱的邮箱地址,请检查邮箱地址的有效性 |
400 | 41006 | no user name error | 没有设置user的name |
400 | 41007 | exceed uncertain tenant seat limit error | 未认证租户的人员不能超过限制。 |
400 | 41008 | exceed bill seat limit error | 租户人员数目超过限制。 |
400 | 41009 | no email or mobile error | 电子邮箱和手机号不能都为空。 |
400 | 41010 | no mobile error | 手机号不能为空。 |
400 | 41011 | user id already exist error | user_id是企业内用户的唯一ID,不能重复 |
400 | 41012 | user id invalid error | 用户ID无效。 |
400 | 41013 | exceed user id update limit error | 用户ID更新次数超过限制。 |
400 | 41014 | user name sensitive error | name中包含敏感信息,如有疑问,请联系客服 |
400 | 41015 | idp type invalid error error | 登录类型无效。 |
400 | 41016 | department has too many users error | 一个部门中有过多的用户,用户数量超过了500 |
400 | 41017 | department is required error | 部门信息不能为空 |
400 | 41018 | position info is invalid error | 岗位信息无效 |
400 | 41019 | position department is invalid error | 岗位部门无效 |
400 | 41020 | position code has already exist error | 岗位code无效 |
400 | 41021 | position multiple main count error | 一个用户至多只能有设置一个主岗 |
400 | 41022 | user tenant not match error | 检查是否使用其他企业的凭证访问当前企业的资源 |
400 | 41025 | order department invalid error | 请求的用户排序信息中的部门ID必须是用户的部门ID之一 |
504 | 41027 | create account failed error | 创建用户失败 |
405 | 41028 | user multi department need upgrade visibility error | 请在企业管理后台更新“组织架构可见范围”的补充规则 |
400 | 41029 | create or update user multi department error | 当前企业不支持用户同时加入多个部门,如有疑问,请联系客服 |
400 | 41030 | set leader to oneself error | 请检查用户的直属上级参数值 |
504 | 41031 | position feature not enable error | 当前企业不支持设置用户岗位信息,如有疑问,请联系客服 |
504 | 41032 | user multi department feature not enable error | 当前企业不支持用户同时加入多个部门,如有疑问,请联系客服 |
400 | 41033 | user in too many departments error | 不支持用户同时属于50个以上的部门,请检查 |
400 | 41034 | email prefix already exist error | email的前缀已经存在 |
400 | 41035 | email prefix is invalid error | email的前缀不合法,请检查拼写 |
400 | 41036 | avatar key is invalid error | 头像key无效 |
400 | 41037 | avatar key is sensitive error | 头像key存在敏感信息 |
400 | 41038 | gender is invalid error | 性别不合法,请检查 |
400 | 41040 | user name is null error | 用户名不能为空 |
400 | 41041 | department id is not assigned error | 用户所属的部门不能为空 |
400 | 41042 | join time is invalid error | 用户加入时间不能为空 |
400 | 41043 | employee id is invalid error | 无效的user id。 大小位于1-64个字节之间 |
400 | 41044 | Custom attribute is not set error | 设置用户自定义字段,必须指明设定的字段ID,字段ID可以通过获取企业自定义字段接口查询 |
400 | 41045 | Custom attribute id is not exist error | 自定义字段ID不存在,请确认自定义字段ID来源,自定义字段ID可以通过获取企业自定义字段接口查询 |
400 | 41046 | Custom attribute value is not set error | 设置自定义字段,需要传入字段value字段 |
400 | 41047 | Custom attribute href text is null error | 设置HREF类型自定义字段,text字段为必填字段 |
400 | 41048 | Custom attribute href url is null error | 设置HREF类型自定义字段,url字段为必填字段 |
400 | 41051 | user id info not provide error | 用户ID没有填写 |
400 | 41052 | user resign acceptor is invalid error | 用户辞职审批人无效 |
409 | 41053 | user has already exist error | 用户已存在 |
400 | 40003 | internal error | 内部错误,请提供 X-Request-Id向客服反馈。联系客服。 |
403 | 40004 | no dept authority error | 操作的部门需在通讯录权限范围中,了解更多 |
400 | 40021 | no a same request error | 两次操作不是同一个请求,请检查request值是否有改动。 |
400 | 41054 | need send email but not set mail | 请检查是否设置邮箱 |
400 | 41055 | need send sms but not set mobile | 请检查是否设置手机号 |
400 | 41059 | invalid employee type error | 用户的雇员类型错误,请填写1-5之间的数字,1 正式员工 2 实习生 3 外包 4 劳务 5 顾问 |
400 | 41060 | inactive employee type error | 雇员类型企业未使用,请咨询管理员 |
400 | 41063 | job_title length exceed 100 character | 职务的设置长度超过100字符,请检查字段长度 |
400 | 41068 | Number of email aliases exceeds the upper limit | 企业邮箱账户已经达到上线,请咨询企业管理员 |
400 | 41069 | Business email is in the recycle bin | 企业邮正在回收中,不可使用 |
400 | 41070 | name length exceed 64 character | 姓名长度超过64个字符 |
400 | 41071 | en_name length exceed 64 character | 英文名长度超过64个字符 |
400 | 41072 | nickname length exceed 64 character | 别名长度超过64个字符 |
400 | 44001 | business email domain not available error | 企业无对应的企业邮域名,咨询企业管理员 |
400 | 44004 | this user has been joined too many tenants recently | 用户加入团队过于频繁,请24小时后重试 |
400 | 44006 | name length exceed 64 character | 姓名超过64个字符 |
400 | 44007 | en_name length exceed 64 character | 英文名超过64个字符 |
400 | 44008 | nickname length exceed 64 character | 别名超过64个字符 |
400 | 44009 | this tenant has been create too many users recently | 团队添加成员过于频繁 |
400 | 44012 | Adding user has been intercepted. Contact Feishu Customer Service | 添加成员失败,详情飞书咨询客服 |
400 | 44013 | User enterprise Email password is not valid | -- |
400 | 44016 | can not set enterprise email password | -- |
400 | 44018 | lark not support +86 mobile | -- |
400 | 44019 | feishu only support +86 mobile | 未认证企业仅支持添加中国大陆+86 手机号,添加非 +86 手机号请先完成飞书认证,完成认证后次日可添加。 |
400 | 44020 | mobile and email need together exist | 已认证企业,添加非 +86 手机号成员时必须同时添加邮箱 |
400 | 44021 | leader is resigned | 负责人已经离职 |
400 | 44022 | leaderID is Invalid | 负责人是无效的参数 |
400 | 44023 | exceed feature contact seat limit | 超过套餐的通讯录上限 |
400 | 44024 | User enterprise email has already been registered as a member's account | 企业邮箱已注册 |
400 | 44038 | this user can not been update by security issues | 请求中的geo不在geolist内 |
400 | 44039 | not set geo name auth | 没有设置geo的权限 |
400 | 44040 | tenant not open mg not set geo name | 租户没有开通MG不能设置geo字段 |
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://open.feishu.cn/open-apis/contact/v3/users' \
--header 'Authorization;' \
--header 'Content-Type: application/json' \
--data-raw '{
"user_id": "3e3cf96b",
"name": "张三",
"en_name": "San Zhang",
"nickname": "Alex Zhang",
"email": "zhangsan@gmail.com",
"mobile": "13011111111",
"mobile_visible": false,
"gender": 1,
"avatar_key": "2500c7a9-5fff-4d9a-a2de-3d59614ae28g",
"department_ids": [
"od-4e6ac4d14bcd5071a37a39de902c7141"
],
"leader_user_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
"city": "杭州",
"country": "CN",
"work_station": "北楼-H34",
"join_time": 2147483647,
"employee_no": "1",
"employee_type": 1,
"orders": [
{
"department_id": "od-4e6ac4d14bcd5071a37a39de902c7141",
"user_order": 100,
"department_order": 100
}
],
"custom_attrs": [
{
"type": "TEXT",
"id": "DemoId",
"value": {
"text": "DemoText",
"url": "http://www.feishu.cn",
"pc_url": "http://www.feishu.cn",
"option_id": "edcvfrtg",
"generic_user": {
"id": "9b2fabg5",
"type": 1
}
}
}
],
"enterprise_email": "demo@mail.com",
"job_title": "xxxxx"
}'
响应示例响应示例
{
"code": 0,
"msg": "success",
"data": {
"user": {
"union_id": "on_94a1ee5551019f18cd73d9f111898cf2",
"user_id": "3e3cf96b",
"open_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
"name": "张三",
"en_name": "San Zhang",
"nickname": "Alex Zhang",
"email": "zhangsan@gmail.com",
"mobile": "13011111111",
"mobile_visible": false,
"gender": 1,
"avatar_key": "2500c7a9-5fff-4d9a-a2de-3d59614ae28g",
"avatar": {
"avatar_72": "https://foo.icon.com/xxxx",
"avatar_240": "https://foo.icon.com/xxxx",
"avatar_640": "https://foo.icon.com/xxxx",
"avatar_origin": "https://foo.icon.com/xxxx"
},
"status": {
"is_frozen": false,
"is_resigned": false,
"is_activated": true,
"is_exited": false,
"is_unjoin": false
},
"department_ids": [
"od-4e6ac4d14bcd5071a37a39de902c7141"
],
"leader_user_id": "ou_7dab8a3d3cdcc9da365777c7ad535d62",
"city": "杭州",
"country": "CN",
"work_station": "北楼-H34",
"join_time": 2147483647,
"is_tenant_manager": false,
"employee_no": "1",
"employee_type": 1,
"orders": [
{
"department_id": "od-4e6ac4d14bcd5071a37a39de902c7141",
"user_order": 100,
"department_order": 100
}
],
"custom_attrs": [
{
"type": "TEXT",
"id": "DemoId",
"value": {
"text": "DemoText",
"url": "http://www.feishu.cn",
"pc_url": "http://www.feishu.cn",
"option_id": "edcvfrtg",
"option_value": "option",
"name": "name",
"picture_url": "https://xxxxxxxxxxxxxxxxxx",
"generic_user": {
"id": "9b2fabg5",
"type": 1
}
}
}
],
"enterprise_email": "demo@mail.com",
"job_title": "xxxxx",
"is_frozen": false
}
}
}
请求参数
Query 参数
user_id_type
可选
示例值:
open_id
department_id_type
可选
示例值:
open_department_id
client_token
string
可选
示例值:
xxxx-xxxxx-xxx
Header 参数
Authorization
string
必需
默认值:
Bearer {{access_token}}
Content-Type
string
必需
默认值:
application/json; charset=utf-8
Body 参数application/json
返回响应
修改于 2023-01-12 03:10:39