API call description
- Before calling this API, make sure that all employees associated with the role have had the role removed.
- Roles under the default role group cannot be deleted.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Call this API to delete a specified role by role ID, with request parameters, invocation details, and response fields.
| Basic information | |
|---|---|
| HTTP URL | https://api.dingtalk.io/topapi/role/deleterole |
| HTTP Method | POST |
| Supported app type | appType-Internal app |
| Permission required | permission-qyapi_manage_addresslist-Contacts data management permission |
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| access_token | String | Yes | 6ed1xxxx | The app credential for calling this API. Obtain it through the API for getting the access_token of an internal app. |
| Name | Type | Required | Example | Description |
|---|---|---|---|---|
| role_id | Number | Yes | 1581321999 | The ID of the role to delete. Call the Get role list API to obtain it. Roles in the “Default” group cannot be modified, including: Owner, Manager, Super Admin, and Sub Admin. |
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'
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());
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)
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");
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);
| Name | Type | Example | Description |
|---|---|---|---|
| errcode | Number | 0 | The return code. |
| errmsg | String | ok | The description of the return code. |
| request_id | String | zw9fhpj3m32u | The request ID. |
{
"errcode":"0",
"request_id":"zw9fhpj3m32u"
}
| Error code (errcode) | Error message (errmsg) | Solution |
|---|---|---|
| 33011 | Invalid role_id | Verify that role_id is correct. |
| 23004 | Editing system tags is not allowed | Verify that role_id is valid. |
| 1002 | System busy | Try again later. |
Was this page helpful?