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

# Menghapus peran karyawan secara massal

> Panggil API DingTalk ini untuk menghapus asosiasi antara karyawan dan peran tertentu secara massal, lengkap dengan parameter permintaan dan bidang respons.

Panggil API ini untuk menghapus peran dari beberapa karyawan sekaligus secara massal.

## Permintaan

| **Informasi dasar**         |                                                                                                                  |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| URL HTTP                    | [https://api.dingtalk.io/topapi/role/removerolesforemps](https://api.dingtalk.io/topapi/role/removerolesforemps) |
| Metode HTTP                 | POST                                                                                                             |
| Tipe aplikasi yang didukung | appType-Aplikasi internal                                                                                        |
| Izin yang diperlukan        | permission-qyapi\_manage\_addresslist-Izin pengelolaan data Kontak                                               |

### Parameter query

| Nama          | Tipe   | Wajib | Contoh   | Deskripsi                                                                                                                                                                           |
| ------------- | ------ | ----- | -------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Ya    | 6ed1bxxx | Kredensial aplikasi yang digunakan untuk memanggil API ini. Dapatkan melalui API untuk memperoleh [access\_token dari aplikasi internal](/id/open/development/obtain-orgapp-token). |

### Isi permintaan

| Nama    | Tipe   | Wajib | Contoh     | Deskripsi                                                                                                                                                                                                                              |
| ------- | ------ | ----- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| roleIds | String | Ya    | 1507113578 | Daftar roleIds peran. Panggil API [Dapatkan daftar peran](/id/open/development/obtains-a-list-of-enterprise-roles) untuk memperolehnya. Panjang maksimum daftar adalah 20. Pisahkan beberapa roleIds dengan koma (,).                  |
| userIds | String | Ya    | user100    | ID pengguna dari Karyawan. Panggil [Cari pengguna berdasarkan nomor telepon](/id/open/development/query-users-by-phone-number) untuk memperoleh userId. Panjang maksimum daftar adalah 100. Pisahkan beberapa userIds dengan koma (,). |

### Contoh permintaan

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

## Respons

### Isi respons

| Nama        | Tipe   | Contoh        | Deskripsi                    |
| ----------- | ------ | ------------- | ---------------------------- |
| errcode     | Number | 0             | Kode pengembalian.           |
| errmsg      | String | ok            | Deskripsi kode pengembalian. |
| request\_id | String | 10c1rigbngrp5 | ID permintaan.               |

### Contoh isi respons

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

### Kode error

Jika terjadi error saat Anda memanggil API ini, temukan solusinya di dokumen [Kode error global](/id/open/development/server-api-error-codes-1) berdasarkan pesan error.

| Kode error (errcode) | Pesan error (errmsg) | Solusi                              |
| -------------------- | -------------------- | ----------------------------------- |
| 33011                | Invalid roleIds      | Periksa apakah roleIds sudah benar. |
| 33012                | Invalid userId       | Periksa apakah userId sudah benar.  |
| -1                   | System busy          | Coba lagi nanti.                    |
