Skip to main content
Call this API to create a role group.

Request

Basic information
HTTP URLhttps://oapi.dingtalk.io/role/add_role_group
HTTP MethodPOST
Supported app typesappType-Internal app
Permissions requiredpermission-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
nameStringYesManufacturingThe name of the role group.

Request example

curl -X POST "https://oapi.dingtalk.io/role/add_role_group" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=e9df3de5-2ccb-4aaf-a685-04ba09fe746d' \
-d 'name=%E5%90%8D%E7%A7%B0'
Java
  DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.io/role/add_role_group");
  OapiRoleAddrolegroupRequest req = new OapiRoleAddrolegroupRequest();
  req.setName("Manufacturing");
  OapiRoleAddrolegroupResponse rsp = client.execute(req, access_token);
  System.out.println(rsp.getBody());
Python
import dingtalk.api

req=dingtalk.api.OapiRoleAddrolegroupRequest("https://oapi.dingtalk.io/role/add_role_group")

req.name="Name"
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 OapiRoleAddrolegroupRequest;
$req->setName("Name");
$resp = $c->execute($req, $access_token, "https://oapi.dingtalk.io/role/add_role_group");
C#
import dingtalk.api

req=dingtalk.api.OapiRoleAddrolegroupRequest("https://oapi.dingtalk.io/role/add_role_group")

  req.name="Name"
  try:
resp= req.getResponse(access_token)
  print(resp)
  except Exception,e:
print(e)

Response

Response body

NameTypeExampleDescription
errcodeNumber0The return code.
errmsgStringokThe return code ID.
groupIdNumber1560985325The ID of the created role group.

Response body example

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

Error codes

If an error occurs when you call this API, refer to the Global error codes document to find a solution based on the error message.