> ## Documentation Index
> Fetch the complete documentation index at: https://developer.rocket.chat/llms.txt
> Use this file to discover all available pages before exploring further.
# Add Permission to a Role
> Grant a permission to a role.
Permission required: `access-permissions`.
To modify a setting-level permission, the `access-setting-permissions` permission is also required.
### Changelog
| Version | Description |
| ---------------- | ------------|
|9.0.0 | The `403` response returns `errorType: error-forbidden`. |
|8.7.0 | Added |
## OpenAPI
````json POST /api/v1/permissions.addRole
{
"openapi": "3.0.0",
"info": {
"version": "1.0.0",
"title": "User Management"
},
"servers": [
{
"url": "https://apiexplorer.support.rocket.chat"
}
],
"tags": [
{
"name": "LDAP"
},
{
"name": "Permissions"
},
{
"name": "Roles"
},
{
"name": "Users"
},
{
"name": "SAML"
}
],
"paths": {
"/api/v1/permissions.addRole": {
"post": {
"tags": [
"Permissions"
],
"summary": "Add Permission to a Role",
"description": "Grant a permission to a role. \n\nPermission required: `access-permissions`. \n\nTo modify a setting-level permission, the `access-setting-permissions` permission is also required.\n\n### Changelog\n| Version | Description |\n| ---------------- | ------------|\n|9.0.0 | The `403` response returns `errorType: error-forbidden`. |\n|8.7.0 | Added |",
"operationId": "post-api-v1-permissions.addRole",
"parameters": [
{
"$ref": "#/components/parameters/UserId"
},
{
"$ref": "#/components/parameters/Auth-Token"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"permissionId": {
"type": "string",
"description": "The permission ID.",
"example": "create-team-channel"
},
"role": {
"type": "string",
"description": "The role to grant the permission to. For default Rocket.Chat roles, enter the role name, such as `admin` or `user`. For custom roles, enter the role ID.",
"example": "user"
}
},
"required": [
"permissionId",
"role"
]
},
"examples": {
"Example": {
"value": {
"permissionId": "create-team-channel",
"role": "user"
}
}
}
}
}
},
"responses": {
"200": {
"$ref": "#/components/responses/trueSuccess"
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
},
"errorType": {
"type": "string"
},
"details": {
"type": "object",
"properties": {
"method": {
"type": "string"
},
"action": {
"type": "string"
}
}
}
}
},
"examples": {
"Invalid Parameters": {
"value": {
"success": false,
"error": "must have required property 'role'",
"errorType": "error-invalid-params"
}
},
"Permission does not exist": {
"value": {
"success": false,
"error": "Permission does not exist [error-invalid-permission]",
"errorType": "error-invalid-permission",
"details": {
"method": "authorization:addPermissionToRole",
"action": "Adding_permission"
}
}
},
"Invalid Role": {
"value": {
"success": false,
"error": "Role does not exist [error-invalid-role]",
"errorType": "error-invalid-role",
"details": {
"method": "authorization:addPermissionToRole",
"action": "Adding_permission"
}
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/authorizationError"
},
"403": {
"description": "Forbidden",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
},
"errorType": {
"type": "string"
}
}
},
"examples": {
"Permission Error": {
"value": {
"success": false,
"error": "User does not have the permissions required for this action",
"errorType": "error-forbidden"
}
}
}
}
}
}
}
}
}
},
"components": {
"parameters": {
"UserId": {
"name": "X-User-Id",
"in": "header",
"description": "The authenticated user ID.",
"required": true,
"schema": {
"type": "string"
},
"example": "rbAXPnMktTFbNpwtJ"
},
"Auth-Token": {
"name": "X-Auth-Token",
"in": "header",
"description": "The authenticated user token.",
"required": true,
"schema": {
"type": "string"
},
"example": "RScctEHSmLGZGywfIhWyRpyofhKOiMoUIpimhvheU3f"
}
},
"responses": {
"trueSuccess": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
}
}
},
"examples": {
"Success": {
"value": {
"success": true
}
}
}
}
}
},
"authorizationError": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
}
}
},
"examples": {
"Authorization Error": {
"value": {
"success": false,
"error": "You must be logged in to do this."
}
}
}
}
}
}
}
}
}
````