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

# Create a role group

> Call this API to create a new role group in Contacts, which can then be used to create roles and assign members within the group.

Call this API to create a role group.

## Request

| **Basic information** |                                                                                                |
| --------------------- | ---------------------------------------------------------------------------------------------- |
| HTTP URL              | [https://oapi.dingtalk.io/role/add\_role\_group](https://oapi.dingtalk.io/role/add_role_group) |
| HTTP Method           | POST                                                                                           |
| Supported app types   | appType-Internal app                                                                           |
| Permissions required  | permission-qyapi\_manage\_addresslist-Contacts data management permission                      |

### Query parameters

| Name          | Type   | Required | Example  | Description                                                                                                                                                    |
| ------------- | ------ | -------- | -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | 6d1bxxxx | The app credential used to call this API. Obtain it through the API for getting the [access\_token of an internal app](/open/development/obtain-orgapp-token). |

### Request body

| Name | Type   | Required | Example       | Description                 |
| ---- | ------ | -------- | ------------- | --------------------------- |
| name | String | Yes      | Manufacturing | The name of the role group. |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
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

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
  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

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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

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

C#

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
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

| Name    | Type   | Example    | Description                       |
| ------- | ------ | ---------- | --------------------------------- |
| errcode | Number | 0          | The return code.                  |
| errmsg  | String | ok         | The return code ID.               |
| groupId | Number | 1560985325 | The ID of the created role group. |

### Response body example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "groupId":1560985325,
  "errmsg":"ok"
}
```

### Error codes

If an error occurs when you call this API, refer to the [Global error codes](/open/development/server-api-error-codes-1) document to find a solution based on the error message.
