Manage chat room block list
A chat room block list refers to a list of users that can neither see nor receive chat room messages. Chat provides a complete set of block list management methods, including adding users to the block list and removing them from it, as well as retrieving the members on the block list.
This page shows how to manage a chat room block list by calling the 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 |
chatroom_id | String | The 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
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. |
entities | JSON | The response entity. |
data | JSON | The details of the response. |
timestamp | Number | The Unix timestamp (ms) when the user is registered. |
duration | Number | The time duration (ms) from sending the HTTP request to receiving the response. |
chatroomid | String | The unique identifier of the chat room. |
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.
Retrieving the chat room block list
Retrieves the block list of the specified chat room.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For the parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Required | Description |
---|---|---|---|
Content-Type | String | Yes | application/json |
Authorization | String | Yes | 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. |
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 |
---|---|---|
data | Array | The user IDs in the chat group block list. |
count | Number | The number of users in the chat group block list. |
For other fields and descriptions, see Common parameters.
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
Adding a user to the chat room block list
Adds the specified user to the chat room block list. Once added to the chat room block list, users can no longer join the chat room. They can neither send nor receive messages in the chat room.
You cannot add the chat room owner to the chat room block list.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For other fields and descriptions, see Common parameters.
Request header
Parameter | Type | Required | Description |
---|---|---|---|
Content-Type | String | Yes | application/json |
Authorization | String | Yes | 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. |
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 added to the chat room block list. true : Yes. false : No. |
user | String | The username added to the chat room block list. |
For the parameters and detailed descriptions, see Common parameters.
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
Adding multiple users to the chat room block list
Adds multiple users to the chat room block list. Once added to the chat room block list, users can no longer join the chat room. They can neither send nor receive messages in the chat room.
You can add a maximum of 60 users to the chat room block list each time. You cannot add the chat room owner to the chat room block list.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For the parameters and detailed descriptions, see Common parameters. |
Request header
Parameter | Type | Required | Description |
---|---|---|---|
Content-Type | String | Yes | application/json |
Authorization | String | Yes | 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. |
Request body
Parameter | Type | Description |
---|---|---|
usernames | Array | The array of usernames to be added to the chat room block list. You can specify a maximum of 60 usernames, separated by commas (,). |
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 users are successfully added to the chat room block list.true : Yes. false : No. |
reason | String | The reason why the users fail to be added to the chat room block list. |
user | String | The usernames added to the chat room block list. |
For the parameters and detailed descriptions, see Common parameters.
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
Removing a user from the chat room block list
Removes the specified user from the chat room block list. To add a user that is in the block list back to the chat room, you need to remove that user from the block list first.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For the parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Required | Description |
---|---|---|---|
Content-Type | String | Yes | application/json |
Authorization | String | Yes | 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. |
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 chat room block list.true : Yes.false : No. |
user | String | The username removed from the chat room block list. |
For the parameters and detailed descriptions, see Common parameters.
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
Removing multiple users from the chat room block list
Removes the specified users from the chat room block list. To add users that are in the block list back to the chat room, you need to remove these users from the block list first. You can remove a maximum of 60 users from the chat room block list each time.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For the parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Required | Description |
---|---|---|---|
Content-Type | String | Yes | application/json |
Authorization | String | Yes | 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. |
Request 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 | Required | Description |
---|---|---|---|
username | String | Yes | The usernames to be removed from the chat room block list. You can specify a maximum of 60 usernames, separated by commas (,). |
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 users are successfully removed from the chat room block list.true : Yes.false : No. |
user | String | The usernames removed from the chat room block list. |
For the parameters and detailed descriptions, see Common parameters.
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
Status codes
For details, see HTTP Status Code.