// Admin.NET 项目的版权、商标、专利和其他相关权利均受相应法律法规的保护。使用本项目应遵守相关法律法规和许可证的要求。 // // 本项目主要遵循 MIT 许可证和 Apache 许可证(版本 2.0)进行分发和使用。许可证位于源代码树根目录中的 LICENSE-MIT 和 LICENSE-APACHE 文件。 // // 不得利用本项目从事危害国家安全、扰乱社会秩序、侵犯他人合法权益等法律法规禁止的活动!任何基于本项目二次开发而产生的一切法律纠纷和责任,我们不承担任何责任! namespace Admin.NET.Plugin.WorkWeixin; /// /// 创建成员输入参数 /// /// ///
最后更新:2025/07/25 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/create?access_token=ACCESS_TOKEN ///
权限说明:仅通讯录同步助手或第三方通讯录应用可调用 ///
限制说明:每个部门下的部门、成员总数不能超过3万个 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90195 ///
[HttpRemoteApi(Action = "user/create", Desc = "创建成员", HttpMethod = HttpMethodEnum.Post)] public class CreateUserWorkWxInput : AuthWorkWxInput { /// /// 成员UserID。对应管理端的账号,企业内必须唯一。长度为1~64个字节。只能由数字、字母和"_-@."四种字符组成,且第一个字符必须是数字或字母。 /// /// 是否必填:是 [CustomJsonProperty("userid")] [Required(ErrorMessage = "用户ID不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "用户ID长度必须在1-64个字节之间")] [RegularExpression("^[a-zA-Z0-9][a-zA-Z0-9_\\-@.]*$", ErrorMessage = "用户ID只能由数字、字母和_-@.组成,且必须以数字或字母开头")] public string UserId { get; set; } /// /// 成员名称。长度为1~64个utf8字符 /// /// 是否必填:是 [CustomJsonProperty("name")] [Required(ErrorMessage = "成员名称不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "成员名称长度必须在1-64个字符之间")] public string Name { get; set; } /// /// 成员别名。长度1~64个utf8字符 /// /// 是否必填:否 [CustomJsonProperty("alias")] [StringLength(64, MinimumLength = 1, ErrorMessage = "别名长度必须在1-64个字符之间")] public string Alias { get; set; } /// /// 手机号码。企业内必须唯一,mobile/email二者不能同时为空 /// /// 是否必填:否 [CustomJsonProperty("mobile")] public string Mobile { get; set; } /// /// 邮箱。企业内必须唯一,mobile/email二者不能同时为空 /// /// 是否必填:否 [CustomJsonProperty("email")] [EmailAddress(ErrorMessage = "邮箱格式不正确")] [StringLength(64, MinimumLength = 6, ErrorMessage = "邮箱长度必须在6-64个字节之间")] public string Email { get; set; } /// /// 成员所属部门id列表,不超过100个 /// /// 是否必填:否 [CustomJsonProperty("department")] [MaxLength(100, ErrorMessage = "部门数量不能超过100个")] public List Department { get; set; } /// /// 部门内的排序值,个数必须和参数department的个数一致 /// /// 是否必填:否 [CustomJsonProperty("order")] public List Order { get; set; } /// /// 职务信息。长度为0~128个字符 /// /// 是否必填:否 [CustomJsonProperty("position")] [StringLength(128, ErrorMessage = "职务信息长度不能超过128个字符")] public string Position { get; set; } /// /// 性别。1表示男性,2表示女性 /// /// 是否必填:否 [CustomJsonProperty("gender")] [Range(1, 2, ErrorMessage = "性别只能是1(男)或2(女)")] public int? Gender { get; set; } /// /// 企业邮箱账号 /// /// 是否必填:否 [CustomJsonProperty("biz_mail")] [EmailAddress(ErrorMessage = "企业邮箱格式不正确")] [StringLength(64, MinimumLength = 6, ErrorMessage = "企业邮箱长度必须在6-64个字节之间")] public string BizMail { get; set; } /// /// 座机。32字节以内,由纯数字、"-"、"+"或","组成 /// /// 是否必填:否 [CustomJsonProperty("telephone")] [StringLength(32, ErrorMessage = "座机号码长度不能超过32个字节")] [RegularExpression("^[0-9\\-\\+,]*$", ErrorMessage = "座机号码只能包含数字、-、+或,")] public string Telephone { get; set; } /// /// 在所在的部门内是否为部门负责人。1表示为部门负责人,0表示非部门负责人 /// /// 是否必填:否 [CustomJsonProperty("is_leader_in_dept")] public List IsLeaderInDept { get; set; } /// /// 直属上级UserID,设置范围为企业内成员,可以设置最多1个上级 /// /// 是否必填:否 [CustomJsonProperty("direct_leader")] [MaxLength(1, ErrorMessage = "直属上级最多只能设置1个")] public List DirectLeader { get; set; } /// /// 成员头像的mediaid,通过素材管理接口上传图片获得的mediaid /// /// 是否必填:否 [CustomJsonProperty("avatar_mediaid")] public string AvatarMediaId { get; set; } /// /// 启用/禁用成员。1表示启用成员,0表示禁用成员 /// /// 是否必填:否 [CustomJsonProperty("enable")] [Range(0, 1, ErrorMessage = "启用状态只能是0(禁用)或1(启用)")] public int? Enable { get; set; } /// /// 扩展属性 /// /// 是否必填:否 [CustomJsonProperty("extattr")] public ExtAttrDto ExtAttr { get; set; } /// /// 是否邀请该成员使用企业微信,默认值为true /// /// 是否必填:否 [CustomJsonProperty("to_invite")] public bool? ToInvite { get; set; } /// /// 对外职务,长度12个汉字内 /// /// 是否必填:否 [CustomJsonProperty("external_position")] [StringLength(36, ErrorMessage = "对外职务长度不能超过12个汉字")] public string ExternalPosition { get; set; } /// /// 成员对外属性 /// /// 是否必填:否 [CustomJsonProperty("external_profile")] public ExternalProfileDto ExternalProfile { get; set; } /// /// 地址。长度最大128个字符 /// /// 是否必填:否 [CustomJsonProperty("address")] [StringLength(128, ErrorMessage = "地址长度不能超过128个字符")] public string Address { get; set; } /// /// 主部门 /// /// 是否必填:否 [CustomJsonProperty("main_department")] public long? MainDepartment { get; set; } /// /// 扩展属性 /// public class ExtAttrDto { /// /// 扩展属性列表 /// [CustomJsonProperty("attrs")] public List Attrs { get; set; } } /// /// 扩展属性项 /// public class ExtAttrItemDto { /// /// 属性类型:0-文本,1-网页 /// [CustomJsonProperty("type")] [Range(0, 1, ErrorMessage = "扩展属性类型只能是0(文本)或1(网页)")] public int Type { get; set; } /// /// 属性名称 /// [CustomJsonProperty("name")] [Required(ErrorMessage = "扩展属性名称不能为空")] public string Name { get; set; } /// /// 文本属性值(当type=0时使用) /// [CustomJsonProperty("text")] public ExtAttrTextDto Text { get; set; } /// /// 网页属性值(当type=1时使用) /// [CustomJsonProperty("web")] public ExtAttrWebDto Web { get; set; } } /// /// 扩展属性文本值 /// public class ExtAttrTextDto { /// /// 文本值 /// [CustomJsonProperty("value")] [Required(ErrorMessage = "文本值不能为空")] public string Value { get; set; } } /// /// 扩展属性网页值 /// public class ExtAttrWebDto { /// /// 网页链接 /// [CustomJsonProperty("url")] [Required(ErrorMessage = "网页链接不能为空")] [Url(ErrorMessage = "网页链接格式不正确")] public string Url { get; set; } /// /// 网页标题 /// [CustomJsonProperty("title")] [Required(ErrorMessage = "网页标题不能为空")] public string Title { get; set; } } /// /// 成员对外属性 /// public class ExternalProfileDto { /// /// 企业简称 /// [CustomJsonProperty("external_corp_name")] public string ExternalCorpName { get; set; } /// /// 视频号信息 /// [CustomJsonProperty("wechat_channels")] public WechatChannelsDto WechatChannels { get; set; } /// /// 对外属性列表 /// [CustomJsonProperty("external_attr")] public List ExternalAttr { get; set; } } /// /// 视频号信息 /// public class WechatChannelsDto { /// /// 视频号名称 /// [CustomJsonProperty("nickname")] public string Nickname { get; set; } } /// /// 对外属性项 /// public class ExternalAttrItemDto { /// /// 属性类型:0-文本,1-网页,2-小程序 /// [CustomJsonProperty("type")] [Range(0, 2, ErrorMessage = "对外属性类型只能是0(文本)、1(网页)或2(小程序)")] public int Type { get; set; } /// /// 属性名称 /// [CustomJsonProperty("name")] [Required(ErrorMessage = "对外属性名称不能为空")] public string Name { get; set; } /// /// 文本属性值(当type=0时使用) /// [CustomJsonProperty("text")] public ExtAttrTextDto Text { get; set; } /// /// 网页属性值(当type=1时使用) /// [CustomJsonProperty("web")] public ExtAttrWebDto Web { get; set; } /// /// 小程序属性值(当type=2时使用) /// [CustomJsonProperty("miniprogram")] public ExternalAttrMiniprogramDto Miniprogram { get; set; } } /// /// 对外属性小程序值 /// public class ExternalAttrMiniprogramDto { /// /// 小程序appid /// [CustomJsonProperty("appid")] [Required(ErrorMessage = "小程序appid不能为空")] public string AppId { get; set; } /// /// 小程序页面路径 /// [CustomJsonProperty("pagepath")] [Required(ErrorMessage = "小程序页面路径不能为空")] public string PagePath { get; set; } /// /// 小程序标题 /// [CustomJsonProperty("title")] [Required(ErrorMessage = "小程序标题不能为空")] public string Title { get; set; } } } /// /// 读取成员输入参数 /// /// ///
最后更新:2025/03/06 ///
请求方式:GET(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&userid=USERID ///
权限说明:应用须拥有指定成员的查看权限 ///
限制说明:应用只能获取可见范围内的成员信息,且每种应用获取的字段有所不同 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90196 ///
[HttpRemoteApi(Action = "user/get", Desc = "读取成员", HttpMethod = HttpMethodEnum.Get)] public class UserWorkWxInput : AuthWorkWxInput { /// /// 成员UserID。对应管理端的账号,企业内必须唯一。不区分大小写,长度为1~64个字节 /// /// 是否必填:是 [CustomJsonProperty("userid")] [Required(ErrorMessage = "用户ID不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "用户ID长度必须在1-64个字节之间")] public string UserId { get; set; } } /// /// 更新成员输入参数 /// /// ///
最后更新:2025/07/25 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/update?access_token=ACCESS_TOKEN ///
权限说明:仅通讯录同步助手或第三方通讯录应用可调用 ///
限制说明:每个部门下的部门、成员总数不能超过3万个 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90197 ///
[HttpRemoteApi(Action = "user/update", Desc = "更新成员", HttpMethod = HttpMethodEnum.Post)] public class UpdateUserWorkWxInput : AuthWorkWxInput { /// /// 成员UserID。对应管理端的账号,企业内必须唯一。不区分大小写,长度为1~64个字节 /// /// 是否必填:是 [CustomJsonProperty("userid")] [Required(ErrorMessage = "用户ID不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "用户ID长度必须在1-64个字节之间")] [RegularExpression("^[a-zA-Z0-9][a-zA-Z0-9_\\-@.]*$", ErrorMessage = "用户ID只能由数字、字母和_-@.组成,且必须以数字或字母开头")] public string UserId { get; set; } /// /// 成员名称。长度为1~64个utf8字符 /// /// 是否必填:否 [CustomJsonProperty("name")] [StringLength(64, MinimumLength = 1, ErrorMessage = "成员名称长度必须在1-64个字符之间")] public string Name { get; set; } /// /// 别名。长度为1-64个utf8字符 /// /// 是否必填:否 [CustomJsonProperty("alias")] [StringLength(64, MinimumLength = 1, ErrorMessage = "别名长度必须在1-64个字符之间")] public string Alias { get; set; } /// /// 手机号码。企业内必须唯一 /// /// 是否必填:否 [CustomJsonProperty("mobile")] public string Mobile { get; set; } /// /// 邮箱。企业内必须唯一 /// /// 是否必填:否 [CustomJsonProperty("email")] [EmailAddress(ErrorMessage = "邮箱格式不正确")] [StringLength(64, MinimumLength = 6, ErrorMessage = "邮箱长度必须在6-64个字节之间")] public string Email { get; set; } /// /// 企业邮箱账号。长度6~63个字节,且为有效的企业邮箱格式 /// /// 是否必填:否 [CustomJsonProperty("biz_mail")] [EmailAddress(ErrorMessage = "企业邮箱格式不正确")] [StringLength(63, MinimumLength = 6, ErrorMessage = "企业邮箱长度必须在6-63个字节之间")] public string BizMail { get; set; } /// /// 企业邮箱别名。最多可设置5个别名,更新时为覆盖式更新 /// /// 是否必填:否 [CustomJsonProperty("biz_mail_alias")] public BizMailAliasDto BizMailAlias { get; set; } /// /// 成员所属部门id列表,不超过100个 /// /// 是否必填:否 [CustomJsonProperty("department")] [MaxLength(100, ErrorMessage = "部门数量不能超过100个")] public List Department { get; set; } /// /// 部门内的排序值,数量必须和department一致 /// /// 是否必填:否 [CustomJsonProperty("order")] public List Order { get; set; } /// /// 职务信息。长度为0~128个utf8字符 /// /// 是否必填:否 [CustomJsonProperty("position")] [StringLength(128, ErrorMessage = "职务信息长度不能超过128个字符")] public string Position { get; set; } /// /// 性别。1表示男性,2表示女性 /// /// 是否必填:否 [CustomJsonProperty("gender")] [Range(1, 2, ErrorMessage = "性别只能是1(男)或2(女)")] public int? Gender { get; set; } /// /// 座机。由1-32位的纯数字、"-"、"+"或","组成 /// /// 是否必填:否 [CustomJsonProperty("telephone")] [StringLength(32, MinimumLength = 1, ErrorMessage = "座机号码长度必须在1-32个字节之间")] [RegularExpression("^[0-9\\-\\+,]*$", ErrorMessage = "座机号码只能包含数字、-、+或,")] public string Telephone { get; set; } /// /// 部门负责人字段,个数必须和department一致,表示在所在的部门内是否为负责人。0-否,1-是 /// /// 是否必填:否 [CustomJsonProperty("is_leader_in_dept")] public List IsLeaderInDept { get; set; } /// /// 直属上级,可以设置企业范围内成员为直属上级,最多设置1个 /// /// 是否必填:否 [CustomJsonProperty("direct_leader")] [MaxLength(1, ErrorMessage = "直属上级最多只能设置1个")] public List DirectLeader { get; set; } /// /// 成员头像的mediaid,通过素材管理接口上传图片获得的mediaid /// /// 是否必填:否 [CustomJsonProperty("avatar_mediaid")] public string AvatarMediaId { get; set; } /// /// 启用/禁用成员。1表示启用成员,0表示禁用成员 /// /// 是否必填:否 [CustomJsonProperty("enable")] [Range(0, 1, ErrorMessage = "启用状态只能是0(禁用)或1(启用)")] public int? Enable { get; set; } /// /// 扩展属性 /// /// 是否必填:否 [CustomJsonProperty("extattr")] public CreateUserWorkWxInput.ExtAttrDto ExtAttr { get; set; } /// /// 对外职务,不超过12个汉字 /// /// 是否必填:否 [CustomJsonProperty("external_position")] [StringLength(36, ErrorMessage = "对外职务长度不能超过12个汉字")] public string ExternalPosition { get; set; } /// /// 成员对外属性 /// /// 是否必填:否 [CustomJsonProperty("external_profile")] public CreateUserWorkWxInput.ExternalProfileDto ExternalProfile { get; set; } /// /// 地址。长度最大128个字符 /// /// 是否必填:否 [CustomJsonProperty("address")] [StringLength(128, ErrorMessage = "地址长度不能超过128个字符")] public string Address { get; set; } /// /// 主部门 /// /// 是否必填:否 [CustomJsonProperty("main_department")] public long? MainDepartment { get; set; } /// /// 新的用户ID(如果userid由系统自动生成,则仅允许修改一次) /// /// 是否必填:否 [CustomJsonProperty("new_userid")] [StringLength(64, MinimumLength = 1, ErrorMessage = "新用户ID长度必须在1-64个字节之间")] [RegularExpression("^[a-zA-Z0-9][a-zA-Z0-9_\\-@.]*$", ErrorMessage = "新用户ID只能由数字、字母和_-@.组成,且必须以数字或字母开头")] public string NewUserId { get; set; } /// /// 验证部门相关字段的一致性 /// public bool ValidateDepartmentFields() { if (Department != null && Order != null && Department.Count != Order.Count) { return false; } if (Department != null && IsLeaderInDept != null && Department.Count != IsLeaderInDept.Count) { return false; } return true; } /// /// 获取验证错误信息 /// public string GetValidationErrors() { if (Department != null && Order != null && Department.Count != Order.Count) { return "部门数量和排序值数量不一致"; } if (Department != null && IsLeaderInDept != null && Department.Count != IsLeaderInDept.Count) { return "部门数量和负责人标识数量不一致"; } return null; } /// /// 企业邮箱别名 /// public class BizMailAliasDto { /// /// 企业邮箱别名列表,最多可设置5个别名 /// [CustomJsonProperty("item")] [MaxLength(5, ErrorMessage = "企业邮箱别名最多只能设置5个")] public List Items { get; set; } = new List(); /// /// 清空所有别名 /// public void Clear() { Items?.Clear(); } /// /// 添加别名 /// public bool AddAlias(string alias) { if (Items == null) Items = new List(); if (Items.Count >= 5) return false; Items.Add(alias); return true; } /// /// 移除别名 /// public bool RemoveAlias(string alias) { return Items?.Remove(alias) ?? false; } } } /// /// 删除成员 /// /// ///
最后更新:2021/08/09 ///
请求方式:GET(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/delete?access_token=ACCESS_TOKEN&userid=USERID ///
权限说明:仅通讯录同步助手或第三方通讯录应用可调用 ///
特殊说明:若是绑定了腾讯企业邮,则会同时删除邮箱账号 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90198 ///
[HttpRemoteApi(Action = "user/delete", Desc = "删除成员", HttpMethod = HttpMethodEnum.Get)] public class DeleteUserWorkWxInput : AuthWorkWxInput { /// /// 成员UserID。对应管理端的账号 /// /// 是否必填:是 [CustomJsonProperty("userid")] [Required(ErrorMessage = "用户ID不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "用户ID长度必须在1-64个字节之间")] public string UserId { get; set; } } /// /// 批量删除成员 /// /// ///
最后更新:2019/06/13 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete?access_token=ACCESS_TOKEN ///
权限说明:仅通讯录同步助手或第三方通讯录应用可调用 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90199 ///
[HttpRemoteApi(Action = "user/batchdelete", Desc = "批量删除成员", HttpMethod = HttpMethodEnum.Post)] public class BatchDeleteUserWorkWxInput : AuthWorkWxInput { /// /// 成员UserID列表。对应管理端的账号。最多支持200个。若存在无效UserID,直接返回错误 /// /// 是否必填:是 [CustomJsonProperty("useridlist")] [Required(ErrorMessage = "用户ID列表不能为空")] [MinLength(1, ErrorMessage = "至少需要指定一个用户ID")] [MaxLength(200, ErrorMessage = "单次最多只能删除200个用户")] public List UserIdList { get; set; } } /// /// 获取部门成员 /// /// ///
最后更新:2022/08/22 ///
请求方式:GET(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/simplelist?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID ///
权限说明:应用须拥有指定部门的查看权限 ///
限制说明:如需获取该部门及其子部门的所有成员,需逐层递归获取 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90200 ///
[HttpRemoteApi(Action = "user/simplelist", Desc = "获取部门成员", HttpMethod = HttpMethodEnum.Get)] public class DeptUserSimpleListWorkWxInput : AuthWorkWxInput { /// /// 获取的部门id /// /// 是否必填:是 [CustomJsonProperty("department_id")] [Required(ErrorMessage = "部门ID不能为空")] public long DepartmentId { get; set; } /// /// 是否递归获取子部门成员 /// /// 是否必填:否 [CustomJsonProperty("fetch_child")] public bool? FetchChild { get; set; } } /// /// 获取部门成员详情 /// /// ///
最后更新:2024/07/24 ///
请求方式:GET(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list?access_token=ACCESS_TOKEN&department_id=DEPARTMENT_ID ///
权限说明:应用须拥有指定部门的查看权限 ///
限制说明:应用只能获取可见范围内的成员信息,且每种应用获取的字段有所不同 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90201 ///
[HttpRemoteApi(Action = "user/list", Desc = "获取部门成员详情", HttpMethod = HttpMethodEnum.Get)] public class DeptUserDetailListWorkWxInput : AuthWorkWxInput { /// /// 获取的部门id /// /// 是否必填:是 [CustomJsonProperty("department_id")] [Required(ErrorMessage = "部门ID不能为空")] public long DepartmentId { get; set; } /// /// 是否递归获取子部门成员 /// /// 是否必填:否 [CustomJsonProperty("fetch_child")] public bool? FetchChild { get; set; } } /// /// userid转openid /// /// ///
最后更新:2022/01/20 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_openid?access_token=ACCESS_TOKEN ///
权限说明:成员必须处于应用的可见范围内 ///
使用场景:企业支付,在使用企业红包和向员工付款时使用 ///
限制说明:需要成员使用微信登录企业微信或者关注微信插件才能转成openid ///
文档地址:https://developer.work.weixin.qq.com/document/path/90202 ///
[HttpRemoteApi(Action = "user/convert_to_openid", Desc = "userid转openid", HttpMethod = HttpMethodEnum.Post)] public class ConvToOpenIdWorkWxInput : AuthWorkWxInput { /// /// 企业内的成员id /// /// 是否必填:是 [CustomJsonProperty("userid")] [Required(ErrorMessage = "用户ID不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "用户ID长度必须在1-64个字节之间")] public string UserId { get; set; } } /// /// openid转userid /// /// ///
最后更新:2022/01/20 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/convert_to_userid?access_token=ACCESS_TOKEN ///
权限说明:管理组需对openid对应的企业微信成员有查看权限 ///
使用场景:企业支付之后的结果查询 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90202 ///
[HttpRemoteApi(Action = "user/convert_to_userid", Desc = "openid转userid", HttpMethod = HttpMethodEnum.Post)] public class ConvToUserIdWorkWxInput : AuthWorkWxInput { /// /// 在使用企业支付之后,返回结果的openid /// /// 是否必填:是 [CustomJsonProperty("openid")] [Required(ErrorMessage = "OpenID不能为空")] public string OpenId { get; set; } } /// /// 登录二次验证 /// /// ///
最后更新:2023/11/15 ///
请求方式:GET(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/authsucc?access_token=ACCESS_TOKEN&userid=USERID ///
使用场景:安全性要求高的企业进行成员验证,开启二次验证后使用 ///
流程说明:成员登录→跳转企业验证页面→获取code→根据code获取userid→调用本接口完成验证 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90203 ///
[HttpRemoteApi(Action = "user/authsucc", Desc = "登录二次验证", HttpMethod = HttpMethodEnum.Get)] public class UserAuthSuccessWorkWxInput : AuthWorkWxInput { /// /// 成员UserID。对应管理端的账号 /// /// 是否必填:是 [CustomJsonProperty("userid")] [Required(ErrorMessage = "用户ID不能为空")] [StringLength(64, MinimumLength = 1, ErrorMessage = "用户ID长度必须在1-64个字节之间")] public string UserId { get; set; } } /// /// 邀请成员 /// /// ///
最后更新:2024/11/04 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/batch/invite?access_token=ACCESS_TOKEN ///
权限说明:须拥有指定成员、部门或标签的查看权限,第三方仅通讯录应用可调用 ///
限制说明:user, party, tag三者不能同时为空;邀请频率有限制 ///
文档地址:https://developer.work.weixin.qq.com/document/path/90213 ///
[HttpRemoteApi(Action = "batch/invite", Desc = "邀请成员", HttpMethod = HttpMethodEnum.Post)] public class InviteUserWorkWxInput : AuthWorkWxInput { /// /// 成员ID列表, 最多支持1000个 /// /// 是否必填:否 [CustomJsonProperty("user")] [MaxLength(1000, ErrorMessage = "成员ID列表最多支持1000个")] public List User { get; set; } /// /// 部门ID列表,最多支持100个 /// /// 是否必填:否 [CustomJsonProperty("party")] [MaxLength(100, ErrorMessage = "部门ID列表最多支持100个")] public List Party { get; set; } /// /// 标签ID列表,最多支持100个 /// /// 是否必填:否 [CustomJsonProperty("tag")] [MaxLength(100, ErrorMessage = "标签ID列表最多支持100个")] public List Tag { get; set; } /// /// 验证邀请参数 /// public (bool IsValid, string ErrorMessage) Validate() { if ((User == null || User.Count == 0) && (Party == null || Party.Count == 0) && (Tag == null || Tag.Count == 0)) { return (false, "user, party, tag三者不能同时为空"); } return (true, null); } } /// /// 获取加入企业二维码 /// /// ///
最后更新:2019/11/30 ///
请求方式:GET(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/corp/get_join_qrcode?access_token=ACCESS_TOKEN&size_type=SIZE_TYPE ///
权限说明:须拥有通讯录的管理权限,使用通讯录同步的Secret ///
文档地址:https://developer.work.weixin.qq.com/document/path/90214 ///
[HttpRemoteApi(Action = "corp/get_join_qrcode", Desc = "获取加入企业二维码", HttpMethod = HttpMethodEnum.Get)] public class JoinQrcodeWorkWxInput : AuthWorkWxInput { /// /// qrcode尺寸类型,1: 171 x 171; 2: 399 x 399; 3: 741 x 741; 4: 2052 x 2052 /// /// 是否必填:否 [CustomJsonProperty("size_type")] [Range(1, 4, ErrorMessage = "尺寸类型必须在1-4之间")] public int? SizeType { get; set; } = 3; } /// /// 手机号获取userid /// /// ///
最后更新:2022/08/16 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/getuserid?access_token=ACCESS_TOKEN ///
权限说明:应用须拥有指定成员的查看权限 ///
限制说明:请确保手机号的正确性,若出错的次数超出企业规模人数的20%,会导致1天不可调用 ///
文档地址:https://developer.work.weixin.qq.com/document/path/95402 ///
[HttpRemoteApi(Action = "user/getuserid", Desc = "手机号获取userid", HttpMethod = HttpMethodEnum.Post)] public class UserIdByMobileWorkWxInput : AuthWorkWxInput { /// /// 用户在企业微信通讯录中的手机号码。长度为5~32个字节 /// /// 是否必填:是 [CustomJsonProperty("mobile")] [Required(ErrorMessage = "手机号不能为空")] [StringLength(32, MinimumLength = 5, ErrorMessage = "手机号长度必须在5-32个字节之间")] public string Mobile { get; set; } } /// /// 邮箱获取userid /// /// ///
最后更新:2022/07/19 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/get_userid_by_email?access_token=ACCESS_TOKEN ///
权限说明:应用须拥有指定成员的查看权限 ///
限制说明:请确保邮箱的正确性,若出错的次数较多,会导致1天不可调用 ///
文档地址:https://developer.work.weixin.qq.com/document/path/95892 ///
[HttpRemoteApi(Action = "user/get_userid_by_email", Desc = "邮箱获取userid", HttpMethod = HttpMethodEnum.Post)] public class UserIdByEmailWorkWxInput : AuthWorkWxInput { /// /// 邮箱 /// /// 是否必填:是 [CustomJsonProperty("email")] [Required(ErrorMessage = "邮箱不能为空")] [EmailAddress(ErrorMessage = "邮箱格式不正确")] public string Email { get; set; } /// /// 邮箱类型:1-企业邮箱(默认);2-个人邮箱 /// /// 是否必填:否 [CustomJsonProperty("email_type")] [Range(1, 2, ErrorMessage = "邮箱类型只能是1(企业邮箱)或2(个人邮箱)")] public int? EmailType { get; set; } = 1; /// /// 邮箱类型描述 /// public string EmailTypeDesc => EmailType switch { 1 => "企业邮箱", 2 => "个人邮箱", _ => "未知类型" }; } /// /// 获取成员ID列表 /// /// ///
最后更新:2024/07/23 ///
请求方式:POST(HTTPS) ///
请求地址:https://qyapi.weixin.qq.com/cgi-bin/user/list_id?access_token=ACCESS_TOKEN ///
权限说明:仅支持通过"通讯录同步secret"调用 ///
文档地址:https://developer.work.weixin.qq.com/document/path/96067 ///
[HttpRemoteApi(Action = "user/list_id", Desc = "获取成员ID列表", HttpMethod = HttpMethodEnum.Post)] public class UserIdListWorkWxInput : AuthWorkWxInput { /// /// 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用不填 /// /// 是否必填:否 [CustomJsonProperty("cursor")] public string Cursor { get; set; } /// /// 分页,预期请求的数据量,取值范围 1 ~ 10000 /// /// 是否必填:否 [CustomJsonProperty("limit")] [Range(1, 10000, ErrorMessage = "分页大小必须在1-10000之间")] public int? Limit { get; set; } = 1000; }