Manage roles
Update time: 2022/12/13 08:55:20
Assign and change user roles in chat rooms.
Assign a role
You can assign or unassgin the administrator role, add to or remove from the blocklist, and mute or unmute participants. Each operation has corresponding permission requirements. For more information, see Request Parameters.
URL
httpPOST https://api.netease.im/nimserver/chatroom/setMemberRole.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For information about how to set the header in a POST request, see API Call methods.
-
The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
operator | String | Yes | The operator account |
target | String | Yes | The target account |
opt | int | Yes |
Operations: 1: Assign administrator. The operator must be the creator of a chat room 2: Assign regular participants. The operator must be the creator or administrator. -1: Add to the blocklist. The operator must be the creator or administrator. -2: Mute participants. The operator must be the creator or administrator. |
optvalue | Boolean | Yes |
true: assign the role, false: unassign the role. If a participant who is unassigned a role is not muted or added to the blocked, the participant becomes a guest. |
notifyExt | String | No | Extension field of notifications in JSON, up to 2,048 characters. |
Example
cURL request example
curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: fe416640c8e8a72734219e1847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=66&operator=zhangsan&target=lisi&opt=2&optvalue=true' 'https://api.netease.im/nimserver/chatroom/setMemberRole.action'
Example success response
json"Content-Type": "application/json; charset=utf-8"
{
"desc": {
"roomid": 16,
"level": 10,
"accid": "zhangsan",
"type": "COMMON"
},
"code": 200
}
Note:
Possible returned types:
LIMITED, //Limited users, muted or in the blocklist
COMMON, //Regular permanent member
CREATOR, //Creator of a chat room
MANAGER, //Administrator
TEMPORARY, //Guest member
Change the role of a member
You can change the role of a specified member in chat rooms.
URL
httpPOST https://api.netease.im/nimserver/chatroom/updateMyRoomRole.action HTTP/1.1
Content-Type:application/x-www-form-urlencoded;charset=utf-8
Request parameters
-
For information about how to set the header in a POST request, see API Call methods.
-
The settings of the body in a POST request:
Parameter | Type | Required | Description |
---|---|---|---|
roomid | long | Yes | Chat room ID |
accid | String | Yes | The user whose role is changed. |
save | boolean | No | Whether the changed information is persisted. The default value is false. The option is valid only for permanent members. |
needNotify | boolean | No | Whether a notification is sent when a role is changed. |
notifyExt | String | No | The content of a notification, up to 2,048 characters. |
nick | String | No | Nickname of a member in a chat room, up to 64 characters. |
avator | String | No | Avatar of a member in a chat room. |
ext | String | No | Extension field of a member profile in a chat room |
bid | String | No | Content moderation ID in JSON, {"textbid": "", "picbid": ""}. If unspecified, the original content moderation configuration is applied. |
Example
cURL request example
curlcurl -X POST -H "CheckSum: 51eb13ea5ee3a2c00e8388e48e61c65c7866c366" -H "AppKey: he516640c8e8a72734219eh847ad2547" -H "Nonce: 1" -H "CurTime: 1451207708" -H "Content-Type: application/x-www-form-urlencoded" -d 'roomid=36&accid=hzyangfeng201403&save=true&needNotify=true&nick=myNick' "https://api.netease.im/nimserver/chatroom/updateMyRoomRole.action"
Example success response
json
"Content-Type": "application/json; charset=utf-8"
{
"code": 200
}
Status codes
The status code is returned in the response body. For more information, see Status codes.
Was this page helpful?