# Create role

Call this interface to create a role.

## Usage restrictions

Under the same tenant, the maximum number of roles is 500.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/contact/v3/functional_roles
HTTP Method | POST
Rate Limit | [100 per minute](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.** | View, create, update, delete role and role members(contact:functional_role)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)
Content-Type | string | Yes | **Fixed value**: "application/json; charset=utf-8"

### Request body

Parameter | Type | Required | Description
---|---|---|---
role_name | string | Yes | Role name. The role name is unique in the same tenant and cannot be created repeatedly.<br>**Example value**: "Attendance Administrator"<br>**Data validation rules**:<br>- Length range: `1` ～ `50` characters

### Request body example
```json
{
    "role_name": "Attendance Administrator"
}
```

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-
role_id | string | The role ID is the unique identifier of the role under the current tenant.<br>**Note**: It is recommended that you save this ID locally so that you can delete or modify the role later.

### Response body example
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "role_id": "7vrj3vk70xk7v5r"
    }
}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
400 | 41201 | role name already exists | Role names cannot be repeated in a tenant. Please modify the role name and try again.
400 | 41208 | number of tenant roles cannot exceed 500 | The number of roles in the tenant exceeds 500 and cannot be created. You need to delete roles that are no longer used and try again.

For more error code information, see [General error codes](https://open.feishu.cn/document/ukTMukTMukTM/ugjM14COyUjL4ITN).

