> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 批量删除员工角色

> 调用本接口批量解除员工与指定角色的关联,含请求参数与响应字段说明。

调用本接口批量删除员工的角色。

## 请求

| **基本信息**    |                                                                                                                  |
| ----------- | ---------------------------------------------------------------------------------------------------------------- |
| HTTP URL    | [https://api.dingtalk.io/topapi/role/removerolesforemps](https://api.dingtalk.io/topapi/role/removerolesforemps) |
| HTTP Method | POST                                                                                                             |
| 支持的应用类型     | appType-企业内部应用                                                                                                   |
| 权限要求        | permission-qyapi\_manage\_addresslist-通讯录数据管理权限                                                                  |

### 查询参数

| 名称            | 类型     | 是否必填 | 示例值      | 描述                                                                                   |
| ------------- | ------ | ---- | -------- | ------------------------------------------------------------------------------------ |
| access\_token | String | 是    | 6ed1bxxx | 调用该接口的应用凭证，通过[获取企业内部应用的access\_token](/zh/open/development/obtain-orgapp-token)接口获取。 |

### 请求体

| 名称      | 类型     | 是否必填 | 示例值        | 描述                                                                                                                    |
| ------- | ------ | ---- | ---------- | --------------------------------------------------------------------------------------------------------------------- |
| roleIds | String | 是    | 1507113578 | 角色roleId列表，可调用[获取角色列表](/zh/open/development/obtains-a-list-of-enterprise-roles)接口获取。  最大列表长度为20，多个roleId用英文逗号（,）分隔。   |
| userIds | String | 是    | user100    | 员工的userid，可通过调用[根据手机号查询用户](/zh/open/development/query-users-by-phone-number)获取userId。  最大列表长度为100，多个userId用英文逗号（,）分隔。 |

### 请求示例

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/role/removerolesforemps" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=e56eb45d-4b5a-4284-bdcf-cbc5284e188a' \
-d 'roleIds=1507113578' \
-d 'userIds=user100'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/removerolesforemps");
OapiRoleRemoverolesforempsRequest req = new OapiRoleRemoverolesforempsRequest();
req.setRoleIds("1507113578");
req.setUserIds("user100,user101");
OapiRoleRemoverolesforempsResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
```

Python

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import dingtalk.api

req=dingtalk.api.OapiRoleRemoverolesforempsRequest("https://api.dingtalk.io/topapi/role/removerolesforemps")

req.roleIds="1507113578"
req.userIds="user100"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
```

PHP

```php theme={"theme":{"light":"github-light","dark":"github-dark"}}
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiRoleRemoverolesforempsRequest;
$req->setRoleIds("1,2");
$req->setUserIds("a,b");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/removerolesforemps");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/removerolesforemps");
OapiRoleRemoverolesforempsRequest req = new OapiRoleRemoverolesforempsRequest();
req.RoleIds = "1507113578";
req.UserIds = "user100";
OapiRoleRemoverolesforempsResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## 响应

### 响应体

| 名称          | 类型     | 示例值           | 描述     |
| ----------- | ------ | ------------- | ------ |
| errcode     | Number | 0             | 返回码。   |
| errmsg      | String | ok            | 返回码描述。 |
| request\_id | String | 10c1rigbngrp5 | 请求ID。  |

### 响应体示例

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "request_id":"10c1rigbngrp5"
}
```

### 错误码

若调用该接口报错，可根据错误信息在[全局错误码](/zh/open/development/server-api-error-codes-1)文档中查找解决方案。

| 错误码（errcode） | 错误码描述（errmsg） | 解决方案           |
| ------------ | ------------- | -------------- |
| 33011        | 无效的roleIds    | 请检查roleIds是否正确 |
| 33012        | 无效的userId     | 请检查userId是否正确  |
| -1           | 系统繁忙          | 请稍后再试          |
