> ## 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.
# Create Role
>
Create a new role in the workspace. See Custom Roles for further information.
* You can't create new roles with the same name as existing roles. For example, it is not possible to create a new role with the name `admin`.
* The scope can either be `Users`(user level) or `Subscriptions`(room level).
* Permission required: `access-permissions`
### Changelog
| Version | Description |
| ---------------- | ------------|
|6.0.0 | Moved to Enterprise plan. |
|3.15.0 | The endpoint is no longer used to update roles. |
|0.70.0 | Added |
## OpenAPI
````json POST /api/v1/roles.create
{
"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/roles.create": {
"post": {
"tags": [
"Roles"
],
"summary": "Create Role",
"description": "\n\nCreate a new role in the workspace. See Custom Roles for further information.\n\n* You can't create new roles with the same name as existing roles. For example, it is not possible to create a new role with the name `admin`.\n* The scope can either be `Users`(user level) or `Subscriptions`(room level).\n* Permission required: `access-permissions`\n\n### Changelog\n| Version | Description |\n| ---------------- | ------------|\n|6.0.0 | Moved to Enterprise plan. |\n|3.15.0 | The endpoint is no longer used to update roles. |\n|0.70.0 | Added |",
"operationId": "post-api-v1-roles.create",
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Enter the new role's name.",
"example": "newRole"
},
"scope": {
"type": "string",
"description": "The new role's scope. The scope can either be Users (user level) or Subscriptions (room level). The default value is `Users`.",
"example": "Subscriptions"
},
"description": {
"type": "string",
"description": "Enter a description for the new role.",
"example": "Role description"
},
"mandatory2fa": {
"type": "boolean",
"description": "Whether the role should have a mandatory 2FA. The default value is `false`. If set to true, users assigned to this role are prompted to enter a 2FA code for certain activities.",
"default": false
}
},
"required": [
"name"
]
},
"examples": {
"Example": {
"value": {
"name": "Test Role",
"scope": "Users",
"description": "Testing Role for API",
"mandatory2fa": false
}
}
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"role": {
"type": "object",
"properties": {
"_id": {
"type": "string"
},
"name": {
"type": "string"
},
"scope": {
"type": "string"
},
"description": {
"type": "string"
},
"protected": {
"type": "boolean"
},
"mandatory2fa": {
"type": "boolean"
},
"_updatedAt": {
"type": "string"
}
}
},
"success": {
"type": "boolean"
}
}
},
"examples": {
"Success Example": {
"value": {
"role": {
"_id": "646c431fa8c3a3ba32d0e1c4",
"name": "support1",
"scope": "Subscriptions",
"description": "Role support tier 1",
"protected": false,
"mandatory2fa": false,
"_updatedAt": "2023-05-23T04:37:51.161Z"
},
"success": true
}
}
}
}
}
},
"400": {
"description": "Bad Request",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"error": {
"type": "string"
},
"errorType": {
"type": "string"
}
}
},
"examples": {
"Missing Parameter": {
"value": {
"success": false,
"errorType": "invalid-params",
"error": "must have required property 'name'"
}
},
"Role Already Exists": {
"value": {
"success": false,
"error": "Role name already exists [error-duplicate-role-names-not-allowed]",
"errorType": "error-duplicate-role-names-not-allowed"
}
},
"Access Permission not Allowed": {
"value": {
"success": false,
"error": "Accessing permissions is not allowed [error-action-not-allowed]",
"errorType": "error-action-not-allowed"
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/authorizationError"
}
},
"parameters": [
{
"$ref": "#/components/parameters/UserId"
},
{
"$ref": "#/components/parameters/Auth-Token"
}
]
}
}
},
"components": {
"responses": {
"authorizationError": {
"description": "Unauthorized",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"message": {
"type": "string"
}
}
},
"examples": {
"Authorization Error": {
"value": {
"status": "error",
"message": "You must be logged in to do this."
}
}
}
}
}
}
},
"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"
}
}
}
}
````