> ## 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 the role list

> Call this API to get the role list of an organization for reviewing configured role information.

Call this API to get the role list.

## Request

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

### Query parameters

| Name          | Type   | Required | Example  | Description                                                                                                                                                                                                                                                                                                      |
| ------------- | ------ | -------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| access\_token | String | Yes      | 6ed1bxxx | 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](/open/development/obtain-orgapp-token). - For a third-party enterprise app, obtain it through the API for getting the access\_token of a third-party enterprise. |

### Request body

| Name   | Type   | Required | Example | Description                                                                                                                                                        |
| ------ | ------ | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| size   | Number | No       | 20      | Supports paginated queries. Takes effect only when set together with the offset parameter. This parameter represents the page size. Default is 20. Maximum is 200. |
| offset | Number | No       | 0       | Supports paginated queries. Takes effect only when set together with the size parameter. This parameter represents the offset, which starts from 0.                |

### Request example

```curl theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST "https://api.dingtalk.io/topapi/role/list" \
-H 'Content-Type:application/x-www-form-urlencoded;charset=utf-8' \
-d 'access_token=a0a639xxxx2998' \
-d 'offset=0' \
-d 'size=20'
```

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/list");
OapiRoleListRequest req = new OapiRoleListRequest();
req.setSize(20L);
req.setOffset(0L);
OapiRoleListResponse 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.OapiRoleListRequest("https://api.dingtalk.io/topapi/role/list")

req.size=20
req.offset=0
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 OapiRoleListRequest;
$req->setSize("20");
$req->setOffset("0");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/list");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/list");
OapiRoleListRequest req = new OapiRoleListRequest();
req.Size = 20L;
req.Offset = 0L;
OapiRoleListResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response body

| Name        | Type             | Example      | Description                         |
| ----------- | ---------------- | ------------ | ----------------------------------- |
| request\_id | String           | ii8a42qgzu7e | The request ID.                     |
| errcode     | Number           | 0            | The return code.                    |
| errmsg      | String           | ok           | The description of the return code. |
| result      | PageVo           |              | The result list.                    |
| hasMore     | Boolean          | false        | Whether more data is available.     |
| list        | OpenRoleGroup\[] |              | The role group list.                |
| name        | String           | Default      | The role group name.                |
| groupId     | Number           | 1507113577   | The role group ID.                  |
| roles       | OpenRole\[]      |              | The role list.                      |
| name        | String           | Admin        | The role name.                      |
| id          | Number           | 1507113578   | The role ID.                        |

### Response body example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode": 0,
  "result": {
    "hasMore": true,
    "list": [
      {
        "groupId": 1507113577,
        "name": "Default",
        "roles": [
          {
            "id": 1507113580,
            "name": "Owner"
          },
          {
            "id": 1507113581,
            "name": "Manager"
          },
          {
            "id": 1507113578,
            "name": "Super Admin"
          },
          {
            "id": 1507113579,
            "name": "Sub Admin"
          }
        ]
      }
    ]
  },
  "request_id": "ii8a42qgzu7e"
}
```

### Error codes

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

| Error code (errcode) | Error message (errmsg) | Solution                                    |
| -------------------- | ---------------------- | ------------------------------------------- |
| 400043               | Invalid orgId          | Check whether the access\_token is correct. |
| 40069                | Invalid size           | Adjust the page size.                       |
| 40068                | Invalid offset         | Adjust the offset.                          |
| 400001               | System error           | Try again later.                            |
