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

Manage thread members

This page shows how to manage thread members 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

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

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.
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.
uriStringThe request URI.
pathStringThe request path, which is part of the request URI. You can safely ignore this parameter.
entities JSONThe response entity.
propertiesStringThe request property.

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 thread members

Retrieves all the members in the specified thread.

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

HTTP request


_1
GET https://{host}/{org_name}/{app_name}/thread/{thread_id}/users?limit={N}&cursor={cursor}

Path parameter

ParameterTypeDescriptionRequired
thread_idStringThe ID of the thread.Yes

For the descriptions of the other path parameters, see Common Parameters.

Query parameter

ParameterTypeDescriptionRequired
limitStringThe maximum number of threads to retrieve per page. The range is [1, 50]. The default value is 50.No
cursorStringThe page from which to start retrieving threads. Pass in null or an empty string at the first query.No

Request header

For the descriptions of the request headers, see Authorization.

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
affiliationsListThe user IDs of users to add to the thread. You can pass in up to 10 user IDs.
properties.cursorStringThe cursor that indicates the starting position of the next query.

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 codes for possible causes.

Example

Request example


_1
curl -X GET http://XXXX.com/XXXX/testapp/thread/177916702949377/users -H 'Authorization: Bearer <YourAppToken>'

Response example


_14
{
_14
"action": "get",
_14
"data": {
_14
"affiliations": [
_14
"test4"
_14
]
_14
},
_14
"duration": 4,
_14
"properties": {
_14
"cursor": "ZGNiMjRmNGY1YjczYjlhYTNkYjk1MDY2YmEyNzFmODQ6aW06dGhyZWFkOmVhc2Vtb2ItZGVtbyN0ZXN0eToyMA"
_14
},
_14
"timestamp": 1650872048366,
_14
"uri": "http://XXXX.com/XXXX/testy/thread/179786360094768/users"
_14
}

Adding multiple users to a thread

Adds multiple users to the specified thread. You can add a maximum of 10 users to a thread at each call.

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}/thread/{thread_id}/users

Path parameter

ParameterTypeDescriptionRequired
thread_idStringThe ID of the thread.Yes

For the descriptions of the other path parameters, see Common Parameters.

Request header

For the descriptions of the request headers, see Authorization.

Request body

ParameterTypeDescriptionRequired
usernamesListThe usernames of the members in the thread.Yes

HTTP response

Response body

If the returned HTTP status code is 200, the request succeeds; otherwise, the request fails, and you can refer to Status codes for possible causes.

For other fields and descriptions, see Common parameters.

Example

Request example


_6
curl -X POST http://XXXX.com/XXXX/testapp/thread/177916702949377/users -H 'Authorization: Bearer <YourAppToken>'-d '{
_6
"usernames": [
_6
"test2",
_6
"test3"
_6
]
_6
}'

Response example


_11
{
_11
"action": "post",
_11
"applicationName": "testapp",
_11
"data": {
_11
"status": "ok"
_11
},
_11
"duration": 1069,
_11
"organization": "XXXX",
_11
"timestamp": 1650872649160,
_11
"uri": "http://XXXX.com/XXXX/testy/thread/179786360094768/joined_thread"
_11
}

Removing multiple thread members

Removes multiple users from the specified thread. You can remove a maximum of 10 users from a thread at each call.

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}/thread/{thread_id}/users

Path parameter

ParameterTypeDescriptionRequired
thread_idStringThe ID of the thread.Yes

For the descriptions of the other path parameters, see Common Parameters.

Request header

For the descriptions of the request headers, see Authorization.

Request body

ParameterTypeDescriptionRequired
usernamesListThe user IDs of members to remove from the thread. You can pass in up to 10 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 specified thread member is removed from the thread:
  • true: Yes.
  • false: No.
userStringThe username of the removed member in the thread.

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 codes for possible causes.

Example

Request example


_1
curl -X DELETE http://XXXX.com/XXXX/testapp/thread/177916702949377/users -H 'Authorization: Bearer <YourAppToken>'

Response example


_18
{
_18
"action": "delete",
_18
"applicationName": "testy",
_18
"duration": 12412,
_18
"entities": [
_18
{
_18
"result": false,
_18
"user": "test2"
_18
},
_18
{
_18
"result": false,
_18
"user": "test6"
_18
}
_18
],
_18
"organization": "XXXX",
_18
"timestamp": 1650874050419,
_18
"uri": "http://XXXX.com/XXXX/testy/thread/179786360094768/users"
_18
}

Status codes

For details, see HTTP Status Codes.

vundefined