> ## 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 取得](/ja/open/development/obtain-orgapp-token)インターフェースを通じて取得します。 |

### リクエストボディ

| 名前      | タイプ    | 必須 | 例          | 説明                                                                                                                                                |
| ------- | ------ | -- | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| roleIds | String | 必須 | 1507113578 | ロール roleId のリスト。[ロールリスト取得](/ja/open/development/obtains-a-list-of-enterprise-roles)インターフェースを呼び出して取得できます。リストの最大長は 20 で、複数の roleId は半角カンマ（,）で区切ります。 |
| userIds | String | 必須 | user100    | 社員の userid。[電話番号でユーザーを検索](/ja/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"
}
```

### エラーコード

本インターフェースの呼び出しでエラーが発生した場合は、エラーメッセージをもとに[グローバルエラーコード](/ja/open/development/server-api-error-codes-1)ドキュメントで解決策をご確認ください。

| エラーコード（errcode） | エラーコードの説明（errmsg） | 解決策                  |
| --------------- | ----------------- | -------------------- |
| 33011           | 無効な roleIds       | roleIds が正しいかご確認ください |
| 33012           | 無効な userId        | userId が正しいかご確認ください  |
| -1              | システムビジー           | 後で再度お試しください          |
