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

> Panggil API ini untuk menghapus peran tertentu berdasarkan role ID di DingTalk, lengkap dengan parameter permintaan, detail panggilan, dan field respons.

Panggil API ini untuk menghapus peran tertentu berdasarkan role ID.

## Deskripsi panggilan API

* Sebelum memanggil API ini, pastikan semua karyawan yang terkait dengan peran tersebut sudah dilepaskan dari peran itu.
* Peran di bawah grup peran default tidak dapat dihapus.

## Permintaan

| **Informasi dasar**          |                                                                                                  |
| ---------------------------- | ------------------------------------------------------------------------------------------------ |
| URL HTTP                     | [https://api.dingtalk.io/topapi/role/deleterole](https://api.dingtalk.io/topapi/role/deleterole) |
| Metode HTTP                  | POST                                                                                             |
| Jenis 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    | 6ed1xxxx | Kredensial aplikasi 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                                                                                                                                                                                                                                     |
| -------- | ------ | ----- | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| role\_id | Number | Ya    | 1581321999 | ID peran yang akan dihapus. Panggil API [Ambil daftar peran](/id/open/development/obtains-a-list-of-enterprise-roles) untuk memperolehnya.  Peran di grup "Default" tidak dapat diubah, termasuk: Owner, Manager, Super Admin, dan Sub Admin. |

### Contoh permintaan

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/role/deleterole" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=f5326exxxxbe8d071' \
-d 'role_id=11'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/deleterole");
OapiRoleDeleteroleRequest req = new OapiRoleDeleteroleRequest();
req.setRoleId(1581321999L);
OapiRoleDeleteroleResponse 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.OapiRoleDeleteroleRequest("https://api.dingtalk.io/topapi/role/deleterole")

req.role_id=11
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 OapiRoleDeleteroleRequest;
$req->setRoleId("11");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/deleterole");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/deleterole");
OapiRoleDeleteroleRequest req = new OapiRoleDeleteroleRequest();
req.RoleId = 11L;
OapiRoleDeleteroleResponse 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 | zw9fhpj3m32u | ID permintaan.               |

### Contoh isi respons

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

### Kode error

Jika terjadi error saat memanggil API ini, lihat dokumen [Kode error global](/id/open/development/server-api-error-codes-1) untuk menemukan solusi berdasarkan pesan error.

| Kode error (errcode) | Pesan error (errmsg)               | Solusi                         |
| -------------------- | ---------------------------------- | ------------------------------ |
| 33011                | Invalid role\_id                   | Pastikan role\_id sudah benar. |
| 23004                | Editing system tags is not allowed | Pastikan role\_id valid.       |
| 1002                 | System busy                        | Coba lagi nanti.               |
