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
Parameter | Type | Description | Required |
---|---|---|---|
host | String | The 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_name | String | The 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_name | String | The 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 |
username | String | The 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:
| Yes |
Response parameters
Parameter | Type | Description |
---|---|---|
action | String | The request method. |
organization | String | The unique identifier assigned to each company (organization) by the Chat service. This is the same as org_name . |
application | String | A unique internal ID assigned to each app by the Chat service. You can safely ignore this parameter. |
applicationName | String | The unique identifier assigned to each app by the Chat service. This is the same as app_name . |
uri | String | The request URI. |
path | String | The request path, which is part of the request URI. You can safely ignore this parameter. |
entities | JSON | The response entity. |
data | JSON | The details of the response. |
timestamp | Number | The Unix timestamp (ms) of the HTTP response. |
duration | Number | The 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:
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
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
For other parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Content-Type | String | The parameter type. Set it as application/json . | Yes |
Accept | String | The parameter type. Set it as application/json . | Yes |
Authorization | String | The 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
Parameter | Type | Description | Required |
---|---|---|---|
mute_duration | Long | The duration in which the specified member is muted, in milliseconds. | Yes |
usernames | Array | The usernames to be added to the chat group mute list. | 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.
Parameter | Type | Description |
---|---|---|
result | Boolean | Whether the chat group member is successfully added to the mute list.
|
expire | Long | The Unix timestamp when the mute state expires, in milliseconds. |
user | String | The username of the muted chat group member. |
For other fields and descriptions, see Public 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
Response example
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
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
member_id | String | The group member ID. To remove more than one group member from the mute list, pass in multiple usernames separated by comma (,). For example, {member1}, {member2} . | Yes |
For other parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Accept | String | The parameter type. Set it as application/json . | Yes |
Authorization | String | The 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.
Parameter | Type | Description |
---|---|---|
result | Boolean | Whether the user is successfully removed from the mute list.
|
user | String | The usernames removed from the mute list. |
For other fields and descriptions, see Public 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
Response example
Retrieving the mute list
Retrieves the mute list of the chat group.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
For other parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Accept | String | The parameter type. Set it as application/json . | Yes |
Authorization | String | The 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.
Parameter | Type | Description |
---|---|---|
expire | Long | The Unix timestamp when the mute state expires, in milliseconds. |
user | String | The usernames of the muted members. |
For other fields and descriptions, see Public 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
Response example
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.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The chat group ID. | Yes |
For other parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Content-Type | String | The parameter type. Set it as application/json . | Yes |
Authorization | String | The 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 |
Request body
Parameter | Type | Description |
---|---|---|
mute-duration | Long | The amount of time the group members remain muted, in milliseconds. |
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:
Parameter | Type | Description |
---|---|---|
result | Boolean | Whether all the chat group members are muted.
|
expire | Long | The Unix timestamp when the mute state expires, in milliseconds. |
For other fields and descriptions, see Public 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
Response example
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
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The chat group ID. | Yes |
For other parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Content-Type | String | The parameter type. Set it as application/json . | Yes |
Authorization | String | The 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:
Parameter | Type | Description |
---|---|---|
result | Boolean | Whether all the chat group members are unmuted.
|
For other fields and descriptions, see Public parameter.
If the returned HTTP status code is not 200, the request fails. You can refer to Status code for possible causes.