> ## 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 role details

> Call this API to get the details of a specified role by role ID, including the role name and the role group it belongs to.

Call this API to get the details of a specified role by role ID.

## Request

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

### Query parameters

| 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](/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                                                                                                                            |
| ------ | ------ | -------- | ---------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| roleId | Number | Yes      | 1581321999 | The role ID. To get the value of the id parameter, call the [Get role list](/open/development/obtains-a-list-of-enterprise-roles) API. |

### Request example

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

Java

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
DingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrole");
OapiRoleGetroleRequest req = new OapiRoleGetroleRequest();
req.setRoleId(1507113578L);
OapiRoleGetroleResponse 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.OapiRoleGetroleRequest("https://api.dingtalk.io/topapi/role/getrole")

req.roleId=1001
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 OapiRoleGetroleRequest;
$req->setRoleId("1001");
$resp = $c->execute($req, $access_token, "https://api.dingtalk.io/topapi/role/getrole");
```

C#

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
IDingTalkClient client = new DefaultDingTalkClient("https://api.dingtalk.io/topapi/role/getrole");
OapiRoleGetroleRequest req = new OapiRoleGetroleRequest();
req.RoleId = 1001L;
OapiRoleGetroleResponse rsp = client.Execute(req, access_token);
Console.WriteLine(rsp.Body);
```

## Response

### Response body

| Name        | Type     | Example      | Description                                        |
| ----------- | -------- | ------------ | -------------------------------------------------- |
| role        | OpenRole |              | The role information.                              |
| name        | String   | Owner        | The role name.                                     |
| groupId     | Number   | 1507113577   | The ID of the role group that the role belongs to. |
| errcode     | Number   | 0            | The return code.                                   |
| errmsg      | String   | ok           | The description of the return code.                |
| request\_id | String   | 4cmr6app8ujf | The request ID.                                    |

### Response example

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "errcode":0,
  "role":{
    "groupId":1507113577,
    "name":"Owner"
  },
  "request_id":"4cmr6app8ujf"
}
```

### Error codes

If an error occurs when you call this API, find the 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                                                    |
| -------------------- | ----------------------------- | ----------------------------------------------------------- |
| 33011                | Invalid roleId                | Verify that the roleId is correct.                          |
| 43007                | Operation permission required | Verify that the access\_token has the required permissions. |
| 400001               | System error                  | Try again later.                                            |
