Skip to main content
Android
iOS
Web
Windows
Unity
Flutter
React Native

Manage chat group mute list

Muting means to prevent group users from sending messages in the group. Chat provides multiple mute management APIs, including those for getting the mute list, adding a user to the mute list, and removing a user from the mute list.

This page shows how to manage the mute list by calling Chat RESTful APIs. Before calling the following methods, ensure that you understand the call frequency limit 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

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.
pathStringThe request path, which is part of the request URI. You can safely ignore this parameter.
entities JSONThe response entity.
dataJSONThe details of the response.
timestampNumberThe Unix timestamp (ms) of the HTTP response.
durationNumberThe duration (ms) from when the HTTP request is sent to the time the response is received.

Authorization

Chat RESTful APIs require Bearer HTTP authentication. Every time an HTTP request is sent, the following Authorization field must be filled in the request header:


_1
Authorization: Bearer ${YourAppToken}

In order to improve the security of the project, Agora uses a token (dynamic key) to authenticate users before they log in to the chat system. Chat RESTful APIs only support authenticating users using app tokens. For details, see Authentication using App Token.

Muting a chat group member

Adds a chat group member to the group mute list. Once muted, members cannot send messages in the chat group or in any threads within the chat group.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/mute

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe group ID.Yes

For other parameters and detailed descriptions, see Common parameters.

Request header

ParameterTypeDescriptionRequired
Content-TypeStringThe parameter type. Set it as application/json.Yes
AcceptStringThe parameter type. Set it as application/json.Yes
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

ParameterTypeDescriptionRequired
mute_durationLongThe duration in which the specified member is muted, in milliseconds.Yes
usernamesArrayThe user IDs to be added to the chat group mute list. You can pass in a maximum of 60 user IDs.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds, and the data field in the response body contains the following parameters.

ParameterTypeDescription
resultBooleanWhether the chat group member is successfully added to the mute list.
  • true: Success
  • false: Failure
expireLongThe Unix timestamp when the mute state expires, in milliseconds.
userStringThe user ID of the muted chat group member.

For other fields and descriptions, see Common parameter.

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

Example

Request example


_1
curl -X POST -H 'Content-type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>' -d '{"usernames":["user1"], "mute_duration":86400000}' 'http://XXXX/XXXX/XXXX/chatgroups/10130212061185/mute'

Response example


_15
{
_15
"action": "post",
_15
"application": "527cd7e0-XXXX-XXXX-9f59-ef10ecd81ff0",
_15
"uri": "http://XXXX/XXXX/XXXX/chatgroups/10130212061185/mute",
_15
"entities": [],
_15
"data": [{
_15
"result": true,
_15
"expire": 1489158589481,
_15
"user": "user1"
_15
}],
_15
"timestamp": 1489072189508,
_15
"duration": 0,
_15
"organization": "XXXX",
_15
"applicationName": "XXXX"
_15
}

Unmuting a chat group member

Removes the specified user from the chat group mute list. Once removed from the mute list, a member can once again send messages in the chat group and in the threads within the chat group.

HTTP request


_1
DELETE https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/mute/{member_id}

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe group ID.Yes
member_idStringThe user ID of a group member to be removed from the chat group mute list. You can pass in a maximum of 60 user IDs that are separated by comma (,). For example, {member1}, {member2}.Yes

For other parameters and detailed descriptions, see Common parameters.

Request header

ParameterTypeDescriptionRequired
AcceptStringThe parameter type. Set it as application/json.Yes
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, and the data field in the response body contains the following parameters.

ParameterTypeDescription
resultBooleanWhether the user is successfully removed from the mute list.
  • true: Yes.
  • false: No.
userStringThe usernames removed from the mute list.

For other fields and descriptions, see Common parameter.

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

Example

Request example


_1
curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>' 'http://XXXX/XXXX/XXXX/chatgroups/10130212061185/mute/user1'

Response example


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

Retrieving the mute list

Retrieves the mute list of the chat group.

HTTP request


_1
GET https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/mute

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe group ID.Yes

For other parameters and detailed descriptions, see Common parameters.

Request header

ParameterTypeDescriptionRequired
AcceptStringThe parameter type. Set it as application/json.Yes
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, and the data field in the response body contains the following parameters.

ParameterTypeDescription
expireLongThe Unix timestamp when the mute state expires, in milliseconds.
userStringThe usernames of the muted members.

For other fields and descriptions, see Common parameter.

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

Example

Request example


_1
curl -X GET -H 'Accept: application/json' 'http://XXXX/XXXX/XXXX/chatgroups/10130212061185/mute' -H 'Authorization: Bearer <YourAppToken>'

Response example


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

Muting all chat group members

This method mutes all the chat group members. If this method call succeeds, none of the chat group members can send messages in the chat group or in any threads within the chat group, except those in the group allow list. As the mute does not expire in a certain period, you need to call the API of unmuting all chat group members to stop muting them.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/ban

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe chat group ID.Yes

For other parameters and detailed descriptions, see Common parameters.

Request header

ParameterTypeDescriptionRequired
Content-TypeStringThe parameter type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or admin, 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, and the data field in the response body contains the following parameters:

ParameterTypeDescription
data.muteBooleanWhether all the chat group members are muted.
  • true: Yes.
  • false: No.

For other fields and descriptions, see Common parameter.

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

Example

Request example


_1
curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {Your app token}' 'http://XXXX/XXXX/XXXX/chatgroups/{The group ID}/ban'

Response example


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

Unmuting all chat group members

This method unmutes all the chat group members. Once unmuted, the chat group members can once again send messages in the chat group and in the threads within the chat group.

HTTP request


_1
DELETE https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/ban

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe chat group ID.Yes

For other parameters and detailed descriptions, see Common parameters.

Request header

ParameterTypeDescriptionRequired
Content-TypeStringThe parameter type. Set it as application/json.Yes
AuthorizationStringThe authentication token of the user or admin, 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, and the data field in the response body contains the following parameters:

ParameterTypeDescription
resultBooleanWhether all the chat group members are unmuted.
  • true: Yes.
  • false: No.

For other fields and descriptions, see Common parameter.

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

Example

Request example


_1
curl -X DELETE -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {Your app token}' 'http://XXXX/XXXX/XXXX/chatgroups/1208XXXX5169153/ban'

Response example


_13
{
_13
"action": "put",
_13
"application": "527cd7e0-XXXX-XXXX-9f59-ef10ecd81ff0",
_13
"uri": "http://XXXX/XXXX/XXXX/chatgroups/120824965169153/ban",
_13
"entities": [],
_13
"data": {
_13
"mute": false
_13
},
_13
"timestamp": 1594628899502,
_13
"duration": 1,
_13
"organization": "XXXX",
_13
"applicationName": "XXXX"
_13
}

vundefined