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

Manage chat group allow list

A chat group allow list refers to a list of chat room members that can send group messages after the group owner or admins have muted all the group members using the mute-all method. Chat provides a complete set of allow list management methods, including adding users to the allow list and removing them from it, as well as retrieving the members on the allow list.

This page shows how to manage a chat group allow list using 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

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.

Retrieving the group allow list

This method retrieves the list of all the members on the chat group allow list.

HTTP request


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

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 user IDs on the group allow list. For other 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


_1
curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer {Your app token}' 'http://XXXX/XXXX/XXXX/chatgroups/{The group ID}/white/users'

Response example


_18
{
_18
"action": "get",
_18
"application": "5cf28979-XXXX-XXXX-b969-60141fb9c75d",
_18
"uri": "http://XXXX/XXXX/XXXX/chatgroups/1208XXXX5169153/white/users",
_18
"entities": [],
_18
"data": [
_18
"username1",
_18
"username2",
_18
"username3",
_18
"username4",
_18
"username5"
_18
],
_18
"timestamp": 1594724947117,
_18
"duration": 3,
_18
"organization": "XXXX",
_18
"applicationName": "XXXX",
_18
"count": 5
_18
}

Adding a member to the group allow list

This method adds the specified user to the chat group allow list. Members in the group allow list can still send group messages after the group owner or admin has muted all the group members using the mute-all method.

HTTP request


_1
POST https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/white/users/{username}

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe chat group ID.Yes
usernameStringThe user ID that you want to add to the group allow list.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 fields:

ParameterTypeDescription
resultBooleanWhether the chat group member is successfully added to the group allow list.
  • true: Yes.
  • false: No.
reasonStringThe reason for failing to add the member to the allow list.
groupidStringThe chat group ID.
actionStringThe operation of the method call.
userStringThe user ID added to the allow list.

For other 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


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

Response example


_16
{
_16
"action": "post",
_16
"application": "5cf28979-XXXX-XXXX-b969-60141fb9c75d",
_16
"uri": "http://XXXX/XXXX/XXXX/chatgroups/120824965169153/white/users/username1",
_16
"entities": [],
_16
"data": {
_16
"result": true,
_16
"action": "add_user_whitelist",
_16
"user": "username1",
_16
"groupid": "1208XXXX5169153"
_16
},
_16
"timestamp": 1594724293063,
_16
"duration": 4,
_16
"organization": "XXXX",
_16
"applicationName": "XXXX"
_16
}

Adding multiple members to the group allow list

This method adds multiple chat group members to the group allow list. You can add a maximum of 60 group members to the allow list per method call.

HTTP request


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

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

Request body

ParameterTypeDescription
usernamesArrayThe user IDs that you want to add to the group allow list.

HTTP response

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

ParameterTypeDescription
resultBooleanWhether the chat group member is successfully added to the group allow list.
  • true: Yes.
  • false: No.
reasonStringThe reason for failing to add the member to the allow list.
groupidStringThe chat group ID.
actionStringThe operation of the method call.
userStringThe user ID added to the allow list.

For other 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


_1
curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer {Your app token}' -d '{"usernames" : ["user1"]}' 'http://XXXX/XXXX/XXXX/chatgroups/{The group ID}/white/users'

Response example


_24
{
_24
"action": "post",
_24
"application": "5cf28979-XXXX-XXXX-b969-60141fb9c75d",
_24
"uri": "http://XXXX/XXXX/XXXX/chatgroups/1208XXXX5169153/white/users",
_24
"entities": [],
_24
"data": [
_24
{
_24
"result": true,
_24
"action": "add_user_whitelist",
_24
"user": "username1",
_24
"groupid": "1208XXXX5169153"
_24
},
_24
{
_24
"result": true,
_24
"action": "add_user_whitelist",
_24
"user": "username2",
_24
"groupid": "1208XXXX5169153"
_24
}
_24
],
_24
"timestamp": 1594724634191,
_24
"duration": 2,
_24
"organization": "XXXX",
_24
"applicationName": "XXXX"
_24
}

Removing members from the group allow list

This method removes the specified chat group member(s) from the group allow list. You can remove a maximum of 60 group members from the allow list per method call.

HTTP request


_1
DELETE https://{host}/{org_name}/{app_name}/chatgroups/{group_id}/white/users/{username}

Path parameter

ParameterTypeDescriptionRequired
group_idStringThe chat group ID.Yes
usernameStringThe user ID(s) that you want to remove from the allow list. For multiple user IDs, use the English comma "," to separate each user 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

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

ParameterTypeDescription
resultBooleanWhether the chat group member is successfully removed from the group allow list.
  • true: Yes.
  • false: No.
reasonStringThe reason for failing to remove the member from the allow list.
groupidStringThe chat group ID.
actionStringThe operation of the method call.
userStringThe user ID removed from the allow list.

For other 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


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

Response example


_24
{
_24
"action": "delete",
_24
"application": "5cf28979-XXXX-XXXX-b969-60141fb9c75d",
_24
"uri": "http://XXXX/XXXX/XXXX/chatgroups/1208XXXX5169153/white/users/username1,username2",
_24
"entities": [],
_24
"data": [
_24
{
_24
"result": true,
_24
"action": "remove_user_whitelist",
_24
"user": "username1",
_24
"groupid": "1208XXXX5169153"
_24
},
_24
{
_24
"result": true,
_24
"action": "remove_user_whitelist",
_24
"user": "username2",
_24
"groupid": "1208XXXX5169153"
_24
}
_24
],
_24
"timestamp": 1594725137704,
_24
"duration": 1,
_24
"organization": "XXXX",
_24
"applicationName": "XXXX"
_24
}

vundefined