Assign Role to User

Assign a role to a user. Optionally, you can set this role to a user for a specific room.

Body Parameters

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.

Example Call

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" 
}'

Example Response

{
    "role": {
        "_id": "auditor-log",
        "scope": "Users",
        "description": "",
        "mandatory2fa": false,
        "name": "auditor-log",
        "protected": true,
        "_updatedAt": "2023-07-10T23:20:56.702Z"
    },
    "success": true
}

Change Log

Last updated

Rocket.Chat versions receive support for six months after release.