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

# Get a list of role groups

> Call this API to get the list of role groups in an organization, used for querying and managing roles and permissions.

Call this API to obtain role group information.

## Request

| **Basic information** |                                                                                                      |
| --------------------- | ---------------------------------------------------------------------------------------------------- |
| HTTP URL              | [https://api.dingtalk.io/topapi/role/getrolegroup](https://api.dingtalk.io/topapi/role/getrolegroup) |
| HTTP Method           | POST                                                                                                 |
| Supported app types   | appType-Internal appappType-Third-party enterprise app                                               |
| Required permissions  | permission-qyapi\_get\_department\_list-Read permission for Contacts department information          |

### Query parameter

| Name          | Type   | Required | Example  | Description                                                                                                                                                                                                                                                               |
| ------------- | ------ | -------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | bE74xxxx | The App credential used to call this API.   - For an Internal app, obtain it through the API for getting the access\_token of an Internal app. - For a Third-party enterprise app, obtain it through the API for getting the access\_token of a third-party organization. |

### Request body

| Name      | Type   | Required | Example    | Description               |
| --------- | ------ | -------- | ---------- | ------------------------- |
| group\_id | Number | Yes      | 1507113580 | The ID of the role group. |

### Request example

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

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrolegroup");
OapiRoleGetrolegroupRequest req = new OapiRoleGetrolegroupRequest();
req.setGroupId(1507113580L);
OapiRoleGetrolegroupResponse 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.OapiRoleGetrolegroupRequest("https://api.dingtalk.io/topapi/role/getrolegroup")

req.group_id=1
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 OapiRoleGetrolegroupRequest;
$req->setGroupId("1");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/getrolegroup");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrolegroup");
OapiRoleGetrolegroupRequest req = new OapiRoleGetrolegroupRequest();
req.GroupId = 1L;
OapiRoleGetrolegroupResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response body

| Name        | Type          | Example      | Description                         |
| ----------- | ------------- | ------------ | ----------------------------------- |
| role\_group | OpenRoleGroup |              | The role group information.         |
| roles       | OpenRole\[]   |              | The list of roles.                  |
| role\_id    | Number        | 1507113580   | The role ID.                        |
| role\_name  | String        | Supervisor   | The role name.                      |
| group\_name | String        | Default      | The role group name.                |
| errcode     | Number        | 0            | The return code.                    |
| errmsg      | String        | ok           | The description of the return code. |
| request\_id | String        | 8lgzequlri0o | The request ID.                     |

### Response example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "errmsg": "ok",
  "role_group": {
    "group_name": "Default",
    "roles": [
      {
        "role_name": "Owner",
        "role_id": 1507113580
      },
      {
        "role_name": "Supervisor",
        "role_id": 1507113581
      },
      {
        "role_name": "Super Admin",
        "role_id": 1507113578
      },
      {
        "role_name": "Sub Admin",
        "role_id": 1507113579
      }
    ]
  },
  "request_id": "8lgzequlri0o"
}
```

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

| Error code (errcode) | Error message (errmsg) | Solution                         |
| -------------------- | ---------------------- | -------------------------------- |
| 400002               | Invalid parameter      | Verify whether groupId is valid. |
| -1                   | System is busy         | Try again later.                 |
