Skip to main content

Manage chat room mute list

This page shows how to perform chat room member mute management by calling the Chat RESTful APIs, including muting and unmuting members in a chat room, and retrieving the list of muted members.

Before calling the following methods, ensure that you understand the call frequency limit of the Chat RESTful APIs described in Limitations.

Common parameters

The following table lists common request and response parameters of the Chat RESTful APIs:

Request parameters

ParameterTypeDescriptionRequired
hostStringThe domain name assigned by the Chat service to access RESTful APIs. For how to get the domain name, see Get the information of your project.Yes
org_nameStringThe unique identifier assigned to each company (organization) by the Chat service. For how to get the org name, see Get the information of your project.Yes
app_nameStringThe unique identifier assigned to each app by the Chat service. For how to get the app name, see Get the information of your project.Yes
usernameStringThe unique login account of the user. The user ID must be 64 characters or less and cannot be empty. The following character sets are supported:
  • 26 lowercase English letters (a-z)
  • 26 uppercase English letters (A-Z)
  • 10 numbers (0-9)
  • "_", "-", "."
  • The username is case insensitive, so Aa and aa are the same username.
  • Ensure that each username under the same app is unique.
Yes
chatroom_idStringThe chat room ID. The unique chat room identifier assigned to each chat room by the Chat. You can get the chat room ID from the response body in Retrieve the basic information of all chat rooms.Yes

Response parameters

ParameterTypeDescription
actionStringThe request method.
organizationStringThe unique identifier assigned to each company (organization) by the Chat service. This is the same as org_name.
applicationStringA unique internal ID assigned to each app by the Chat service. You can safely ignore this parameter.
applicationNameStringThe unique identifier assigned to each app by the Chat service . This is the same as app_name.
uriStringThe request URI.
entities JSONThe response entity.
dataJSONThe details of the response.
timestampNumberThe Unix timestamp (ms) when the user is registered.
durationNumberThe time duration (ms) from sending the HTTP request to receiving the response.

Muting a chat room member

Mutes a chat room member. Once a chat room member is muted, this member cannot send messages in the chat room.

For each App Key, the call frequency limit of this method is 100 per second.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/chatrooms/{chatroom_id}/mute

Path parameter

For the parameters and detailed descriptions, see Common parameters .

Request header

ParameterTypeDescriptionRequired
Content-TypeStringapplication/jsonYes
AcceptStringapplication/jsonYes
AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${token}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

Request body

The request body is a JSON object, which contains the following fields:

FieldTypeDescriptionRequired
mute_durationNumberThe length of time to mute speech from the current time. The unit is milliseconds.
-1 indicates that the member is muted permanently.
Yes
usernamesStringThe ID of the user to be muted.

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the response body contains the following fields:

FieldTypeDescription
resultBoolThe mute result:
  • true: Success
  • false: Failure
  • expireNumberThe Unix timestamp (ms) when the mute state expires.
    userStringThe username of the muted chat room member.

    For other fields and detailed descriptions, see Common parameters.

    If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

    Example

    Request example


    _9
    # Replace <YourAppToken> with the app token generated in your server.
    _9
    curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>' -d
    _9
    '{
    _9
    "usernames": [
    _9
    "user1",
    _9
    "user2"
    _9
    ],
    _9
    "mute_duration": 86400000
    _9
    }''http://a1.easemob.com/easemob-demo/testapp/chatrooms/1265710621211/mute'

    Response example


    _22
    {
    _22
    "action": "post",
    _22
    "application": "22bcffa0-XXXX-XXXX-9df8-516f6df68c6d",
    _22
    "applicationName": "XXXX",
    _22
    "data": [
    _22
    {
    _22
    "result": true,
    _22
    "expire": 1642148173726,
    _22
    "user": "user1"
    _22
    },
    _22
    {
    _22
    "result": true,
    _22
    "expire": 1642148173726,
    _22
    "user": "user2"
    _22
    }
    _22
    ],
    _22
    "duration": 0,
    _22
    "entities": [],
    _22
    "organization": "XXXX",
    _22
    "timestamp": 1642060750410,
    _22
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/XXXX/mute"
    _22
    }

    Unmuting chat room members

    Unmutes one or more chat room members. The unmuted members can continue to send messages in the chat room.

    For each App Key, the call frequency limit of this method is 100 per second.

    HTTP request


    _1
    DELETE https://{host}/{org_name}/{app_name}/chatrooms/{chatroom_id}/mute/{member}

    Path parameter

    ParameterTypeDescriptionRequired
    memberStringThe username of the chat room member to be unmuted.
    If you want to unmute multiple members, separate the member usernames with commas (","). In the URL, use "%2C" to represent ",".
    Yes

    For other parameters and detailed descriptions, see Common parameters.

    Request header

    ParameterTypeDescriptionRequired
    AcceptStringapplication/jsonYes
    AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${token}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

    HTTP response

    Response body

    If the returned HTTP status code is 200, the request succeeds. The response body contains the following fields:

    FieldTypeDescription
    resultBoolThe unmute result:
  • true: Success
  • false: Failure
  • userStringThe username of the unmuted chat room member.

    For other fields and detailed descriptions, see Common parameters.

    If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

    Example

    Request example


    _2
    # Replace <YourAppToken> with the app token generated in your server.
    _2
    curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>' 'https://XXXX/XXXX/XXXX/chatrooms/XXXX/mute/XXXX'

    Response example


    _16
    {
    _16
    "action": "delete",
    _16
    "application": "527cd7e0-XXXX-XXXX-9f59-ef10ecd81ff0",
    _16
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/XXXX/mute/XXXX",
    _16
    "entities": [],
    _16
    "data": [
    _16
    {
    _16
    "result": true,
    _16
    "user": "XXXX"
    _16
    }
    _16
    ],
    _16
    "timestamp": 1489072695859,
    _16
    "duration": 0,
    _16
    "organization": "XXXX",
    _16
    "applicationName": "XXXX"
    _16
    }

    Retrieving muted chat room members

    Retrieves the list of all the muted members in the specified chat room.

    For each App Key, the call frequency limit of this method is 100 per second.


    _1
    GET https://{host}/{org_name}/{app_name}/chatrooms/{chatroom_id}/mute

    HTTP request

    Path parameter

    For the parameters and detailed descriptions, see Common parameters .

    Request header

    ParameterTypeDescriptionRequired
    AcceptStringapplication/jsonYes
    AuthorizationStringThe authentication token of the user or administrator, in the format of Bearer ${token}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.Yes

    HTTP response

    Response body

    If the returned HTTP status code is 200, the request succeeds. The response body contains the following fields:

    FieldTypeDescription
    expireNumberThe Unix timestamp (ms) when the mute expires.
    userStringThe username of the muted chat room member.

    For other fields and detailed descriptions, see Common parameters.

    If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

    Example

    Request example


    _2
    # Replace <YourAppToken> with the app token generated in your server.
    _2
    curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>' 'https://XXXX/XXXX/XXXX/chatrooms/XXXX/mute'

    Response example


    _20
    {
    _20
    "action": "post",
    _20
    "application": "527cd7e0-XXXX-XXXX-9f59-ef10ecd81ff0",
    _20
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/XXXX/mute",
    _20
    "entities": [],
    _20
    "data": [
    _20
    {
    _20
    "expire": 1489158589481,
    _20
    "user": "user1"
    _20
    },
    _20
    {
    _20
    "expire": 1489158589481,
    _20
    "user": "user2"
    _20
    }
    _20
    ],
    _20
    "timestamp": 1489072802179,
    _20
    "duration": 0,
    _20
    "organization": "XXXX",
    _20
    "applicationName": "XXXX"
    _20
    }

    Muting all chat room members

    Mutes all chat room members. Once this method call succeeds, only the members on the chat room allow list can send messages. For details, see Manage Chat Room Allow List.

    For each App Key, the call frequency limit of this method is 100 per second.

    HTTP request


    _1
    POST https://{host}/{org_name}/{app_name}/chatrooms/{chatroom_id}/ban

    Path parameter

    For the parameters and detailed descriptions, see Common parameters.

    Request header

    ParameterTypeRequiredDescription
    Content-TypeStringYesapplication/json
    AuthorizationStringYesThe authentication token of the user or administrator, in the format of Bearer ${token}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.

    HTTP response

    Response body

    If the returned HTTP status code is 200, the request succeeds. The response body contains the following fields:

    ParameterTypeDescription
    resultBoolWhether all members are successfully muted:
  • true: Yes.
  • false: No.
  • expireLongThe Unix timestamp when the global mute state expires. Unit: milliseconds.

    For other fields and detailed descriptions, see Common parameters.

    If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

    Example

    Request example


    _1
    curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer YWMt4LqJIul7EeizhBO5TSO_UgAAAAAAAAAAAAAAAAAAAAGL4CTw6XgR6LaXXVmNX4QCAgMAAAFnG7GyAQBPGgDv4ENRUku7fg05Kev0a_aVC8NyA6O6PgpxIRjajSVN3g' 'http://XXXX/XXXX/XXXX/chatrooms/1265710621211/ban'

    Response example


    _13
    {
    _13
    "action": "put",
    _13
    "application": "5cf28979-XXXX-XXXX-b969-60141fb9c75d",
    _13
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/XXXX/ban",
    _13
    "entities": [],
    _13
    "data": {
    _13
    "mute": true
    _13
    },
    _13
    "timestamp": 1594628861058,
    _13
    "duration": 1,
    _13
    "organization": "XXXX",
    _13
    "applicationName": "XXXX"
    _13
    }

    Unmuting all chat room members

    Unmutes all chat room members. Once unmuted, the chat room members resume the right to send messages in the chat room.

    For each App Key, the call frequency limit of this method is 100 per second.

    HTTP request


    _1
    DELETE https://{host}/{org_name}/{app_name}/chatrooms/{chatroom_id}/ban

    Path parameter

    For the parameters and detailed descriptions, see Common parameters.

    Request header

    ParameterTypeRequiredDescription
    Content-TypeStringYesapplication/json
    AuthorizationStringYesThe authentication token of the user or administrator, in the format of Bearer ${token}, where Bearer is a fixed character, followed by an English space, and then the obtained token value.

    HTTP response

    Response body

    If the returned HTTP status code is 200, the request succeeds. The response body contains the following fields:

    ParameterTypeDescription
    resultBooleanWhether all chat room members are successfully unmuted:
  • true: Yes.
  • false: No.
  • For other fields and detailed descriptions, see Common parameters.

    If the returned HTTP status code is not 200, the request fails. You can refer to Status codes for possible reasons.

    Example

    Request example


    _1
    curl -X DELETE -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer YWMt4LqJIul7EeizhBO5TSO_UgAAAAAAAAAAAAAAAAAAAAGL4CTw6XgR6LaXXVmNX4QCAgMAAAFnG7GyAQBPGgDv4ENRUku7fg05Kev0a_aVC8NyA6O6PgpxIRjajSVN3g' 'http://XXXX/XXXX/XXXX/chatrooms/XXXX/ban'

    Response example


    _13
    {
    _13
    "action": "put",
    _13
    "application": "5cf28979-XXXX-XXXX-b969-60141fb9c75d",
    _13
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/XXXX/ban",
    _13
    "entities": [],
    _13
    "data": {
    _13
    "mute": false
    _13
    },
    _13
    "timestamp": 1594628899502,
    _13
    "duration": 1,
    _13
    "organization": "XXXX",
    _13
    "applicationName": "XXXX"
    _13
    }

    Status codes

    For details, see HTTP Status Codes.