Skip to main content
Call this API to update a role name. This API does not allow you to modify roles in the “Default” group, including Person in charge, Supervisor, Super Admin, and Sub Admin.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/role/update_role
HTTP MethodPOST
Supported app typesappType-Internal app
Required permissionspermission-qyapi_manage_addresslist-Contacts data management permission

Query parameters

NameTypeRequiredExampleDescription
access_tokenStringYes6d1bxxxxThe app credential used to call this API. Obtain it through the API for getting the access_token of an internal app.

Request body

NameTypeRequiredExampleDescription
roleIdNumberYes1560985325The ID of the role to update. You can obtain it by calling the Get role list API. Roles in the “Default” group cannot be modified, including: Person in charge, Supervisor, Super Admin, and Sub Admin.
roleNameStringYesApparel manufacturingThe new role name.

Request example

curl -X POST "https://oapi.dingtalk.io/role/update_role" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=bb0d689c-e415-4fa5-b5d8-e16741e12b87' \
-d 'roleId=1' \
-d 'roleName=11'
Java
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/update_role");
OapiRoleUpdateRoleRequest req = new OapiRoleUpdateRoleRequest();
req.setRoleId(1560985325L);
req.setRoleName("Apparel manufacturing");
OapiRoleUpdateRoleResponse rsp = client.execute(req, access_token);
System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiRoleUpdateRoleRequest("https://oapi.dingtalk.io/role/update_role")

req.roleId=1
req.roleName="11"
try:
  resp= req.getResponse(access_token)
  print(resp)
except Exception,e:
  print(e)
PHP
include "TopSdk.php";
date_default_timezone_set('Asia/Shanghai');

$c = new DingTalkClient(DingTalkConstant::$CALL_TYPE_OAPI, DingTalkConstant::$METHOD_POST , DingTalkConstant::$FORMAT_JSON);
$req = new OapiRoleUpdateRoleRequest;
$req->setRoleId("1");
$req->setRoleName("11");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/role/update_role");
C#
IDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/update_role");
OapiRoleUpdateRoleRequest req = new OapiRoleUpdateRoleRequest();
req.RoleId = 1L;
req.RoleName = "11";
OapiRoleUpdateRoleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);

Response

Response body

NameTypeExampleDescription
errcodeNumber0The return code.
errmsgStringokThe description of the return code.

Response body example

{
  "errcode":0,
  "errmsg":"ok"
}

Error codes

If an error occurs when calling this API, refer to the Global error codes document to find a solution based on the error message.
Error code (errcode)Error message (errmsg)Solution
660000The parameter is emptyComplete the missing parameters.
33011Invalid roleIdCheck whether roleId is correct.
-1The system is busyTry again later.