> ## 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.

# Batch remove roles from employees

> Call this API to batch remove the association between employees and specified roles, with request parameters and response fields.

Call this API to remove roles from multiple employees in batch.

## Request

| **Basic information** |                                                                                                                  |
| --------------------- | ---------------------------------------------------------------------------------------------------------------- |
| HTTP URL              | [https://api.dingtalk.io/topapi/role/removerolesforemps](https://api.dingtalk.io/topapi/role/removerolesforemps) |
| HTTP Method           | POST                                                                                                             |
| Supported app types   | appType-Internal app                                                                                             |
| Required permissions  | permission-qyapi\_manage\_addresslist-Contacts data management permission                                        |

### Query parameters

| Name          | Type   | Required | Example  | Description                                                                                                                                                    |
| ------------- | ------ | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | 6ed1bxxx | The App credential used to call this API. Obtain it through the API for getting the [access\_token of an internal app](/open/development/obtain-orgapp-token). |

### Request body

| Name    | Type   | Required | Example    | Description                                                                                                                                                                                                      |
| ------- | ------ | -------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| roleIds | String | Yes      | 1507113578 | The List of role roleIds. Call the [Get role list](/open/development/obtains-a-list-of-enterprise-roles) API to obtain it.  The maximum list length is 20. Separate multiple roleIds with commas (,).            |
| userIds | String | Yes      | user100    | The user ID of the Employee. Call [Query users by phone number](/open/development/query-users-by-phone-number) to obtain the userId.  The maximum list length is 100. Separate multiple userIds with commas (,). |

### Request example

```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);
```

## Response

### Response body

| Name        | Type   | Example       | Description                         |
| ----------- | ------ | ------------- | ----------------------------------- |
| errcode     | Number | 0             | The return code.                    |
| errmsg      | String | ok            | The description of the return code. |
| request\_id | String | 10c1rigbngrp5 | The request ID.                     |

### Response body example

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

### Error codes

If an error is returned when you call this API, find the solution in the [Global error codes](/open/development/server-api-error-codes-1) document based on the error message.

| Error code (errcode) | Error message (errmsg) | Solution                               |
| -------------------- | ---------------------- | -------------------------------------- |
| 33011                | Invalid roleIds        | Check whether the roleIds are correct. |
| 33012                | Invalid userId         | Check whether the userId is correct.   |
| -1                   | System busy            | Try again later.                       |
