Skip to content

用户V1员工管理 - FeishuUserV1Employees

接口名称

用户V1员工管理 - (IFeishuUserV1Employees)

功能描述

本接口提供飞书企业员工(Employee)的完整生命周期管理功能,适用于用户应用场景。支持员工的创建、信息更新、离职、恢复、状态变更以及批量查询和搜索等操作。使用用户令牌访问,适合代表用户执行员工相关操作的场景。

员工指飞书企业内身份为「Employee」的成员,等同于通讯录OpenAPI中的「User」。员工在飞书的身份标识包括 employee_idopen_idunion_id

参考文档

函数列表

函数名称功能描述认证方式HTTP 方法
CreateEmployeeAsync创建员工用户令牌POST
UpdateEmployeeAsync更新员工信息用户令牌PATCH
DeleteEmployeeByIdAsync离职员工用户令牌DELETE
ResurrectEmployeeAsync恢复已离职员工用户令牌POST
ResignedEmployeeAsync办理员工待离职用户令牌PATCH
RegularEmployeeAsync取消员工离职用户令牌PATCH
QueryEmployeesAsync批量查询员工用户令牌POST
QueryEmployeePageListAsync分页查询员工列表用户令牌POST
SearchEmployeePageListAsync搜索员工用户令牌POST

函数详细内容

创建员工

函数名称:创建员工

函数签名

csharp
Task<FeishuApiResult<EmployeeCreateResult>?> CreateEmployeeAsync(
    [Body] EmployeeCreateRequest userModel,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
userModelEmployeeCreateRequest创建的员工请求体
employee_id_typestring用户ID类型,默认 open_id
department_id_typestring部门ID类型,默认 open_department_id
cancellationTokenCancellationToken取消操作令牌

响应

json
{
  "code": 0,
  "msg": "success",
  "data": {
    "employee": {
      "employee_id": "ou_xxx",
      "name": "张三"
    }
  }
}

说明

  • 使用 user_access_token 时,默认为管理员用户
  • 仅「人事管理模式」的管理员可操作

代码示例

csharp
public class UserEmployeeService
{
    private readonly IFeishuUserV1Employees _employeeClient;

    public UserEmployeeService(IFeishuUserV1Employees employeeClient)
    {
        _employeeClient = employeeClient;
    }

    public async Task CreateEmployeeAsUserAsync()
    {
        var request = new EmployeeCreateRequest
        {
            Employee = new EmployeeCreateInfo
            {
                Name = "李四",
                Mobile = "+86-13900139000",
                DepartmentIds = ["od-xxx"]
            }
        };

        var result = await _employeeClient.CreateEmployeeAsync(request);
        if (result?.Code == 0)
        {
            Console.WriteLine($"员工创建成功: {result.Data?.Employee?.Name}");
        }
    }
}

更新员工信息

函数名称:更新员工信息

函数签名

csharp
Task<FeishuNullDataApiResult?> UpdateEmployeeAsync(
    [Path] string employee_id,
    [Body] EmployeeUpdateRequest userModel,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
employee_idstring员工ID
userModelEmployeeUpdateRequest更新的员工请求体
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌

离职员工

函数名称:离职员工

函数签名

csharp
Task<FeishuNullDataApiResult?> DeleteEmployeeByIdAsync(
    [Path] string employee_id,
    [Body] DeleteEmployeeRequest deleteEmployeeRequest,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
employee_idstring员工ID
deleteEmployeeRequestDeleteEmployeeRequest离职员工请求体
employee_id_typestring用户ID类型
cancellationTokenCancellationToken取消操作令牌

说明:使用 user_access_token 时默认为管理员用户,将校验管理员管理范围。当用户有多个管理员身份均可离职员工时,管理员管理范围取最大集。


恢复已离职员工

函数名称:恢复已离职员工

函数签名

csharp
Task<FeishuNullDataApiResult?> ResurrectEmployeeAsync(
    [Path] string employee_id,
    [Body] ResurrectEmployeeRequest resurrectEmployeeRequest,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
employee_idstring员工ID
resurrectEmployeeRequestResurrectEmployeeRequest恢复离职员工请求体
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌

办理员工待离职

函数名称:办理员工待离职

函数签名

csharp
Task<FeishuNullDataApiResult?> ResignedEmployeeAsync(
    [Path] string employee_id,
    [Body] ResignEmployeeRequest resignEmployeeRequest,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
employee_idstring员工ID
resignEmployeeRequestResignEmployeeRequest在职员工流转到待离职请求体
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌

说明:使用 user_access_token 时默认为管理员用户,仅「人事管理模式」的管理员可操作。


取消员工离职

函数名称:取消员工离职

函数签名

csharp
Task<FeishuNullDataApiResult?> RegularEmployeeAsync(
    [Path] string employee_id,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
employee_idstring员工ID
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌

说明:使用 user_access_token 时默认为管理员用户,仅「人事管理模式」的管理员可操作。


批量查询员工

函数名称:批量查询员工

函数签名

csharp
Task<FeishuApiResult<EmployeeListResult>?> QueryEmployeesAsync(
    [Body] EmployeeQueryRequest employeeQueryRequest,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
employeeQueryRequestEmployeeQueryRequest员工查询请求体
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌

分页查询员工列表

函数名称:分页查询员工列表

函数签名

csharp
Task<FeishuApiResult<EmployeePageListResult>?> QueryEmployeePageListAsync(
    [Body] FilterSearchRequest filterSearchRequest,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
filterSearchRequestFilterSearchRequest字段过滤查询条件请求体
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌

搜索员工

函数名称:搜索员工

函数签名

csharp
Task<FeishuApiResult<EmployeePageListResult>?> SearchEmployeePageListAsync(
    [Body] PageSearchRequest pageSearchRequest,
    [Query("employee_id_type")] string? employee_id_type = Consts.User_Id_Type,
    [Query("department_id_type")] string? department_id_type = Consts.Department_Id_Type,
    CancellationToken cancellationToken = default);

认证:用户令牌

参数

参数名类型必填说明
pageSearchRequestPageSearchRequest分页查询参数请求体
employee_id_typestring用户ID类型
department_id_typestring部门ID类型
cancellationTokenCancellationToken取消操作令牌