Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Latest commit

 

History

History
50 lines (39 loc) · 2.47 KB

File metadata and controls

50 lines (39 loc) · 2.47 KB

Assign Role to User

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

HTTP MethodURLRequires Auth
POST/api/v1/roles.addUserToRoleyes

Body Parameters

KeyExample ValueDescription
roleName*guest

The role name. Alternatively, you can use the roleId parameter.


Note:

  • For default roles, the role name and ID are the same. For custom roles, the name and ID are different.
  • If you are setting a custom role for a user, make sure to enter the custom role ID and not the role name.

Refer to Roles for more information.

username*rocket.chatThe user name.
roomIddK7vNYXMdHGLdukpLThe 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 %}

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

Version Description
0.70.0 Added