Assign a role to a user. Optionally, you can set this role to a user for a specific room.
HTTP Method | URL | Requires Auth |
---|---|---|
POST | /api/v1/roles.addUserToRole | yes |
Key | Example Value | Description |
---|---|---|
roleName * | guest | The role name. Alternatively, you can use the
Refer to Roles for more information. |
username * | rocket.chat | The user name. |
roomId | dK7vNYXMdHGLdukpL | The room ID for which the user is assigned the role. |
{% hint style="info" %} By default, the three major room roles available in Rocket.Chat are Owner, Leader, and Moderator. Creating custom roles is an Enterprise workspace feature. Refer Room Roles for more information. {% endhint %}
curl --location 'http://localhost:3000/api/v1/roles.addUserToRole' \
--header 'x-auth-token: o9UKV2D7A5Ggl2vqgyEcItF-YPj4-R93NlMcA6XnE3B' \
--header 'x-user-id: rbAXPnMktTFbNpwtJ' \
--header 'Content-Type: application/json' \
--data '{
"roleName": "auditor-log",
"username": "test.funke",
"roomId": "64adb09baa5ad4273bfc0cbf"
}'
{
"role": {
"_id": "auditor-log",
"scope": "Users",
"description": "",
"mandatory2fa": false,
"name": "auditor-log",
"protected": true,
"_updatedAt": "2023-07-10T23:20:56.702Z"
},
"success": true
}
Version | Description |
---|---|
0.70.0 | Added |