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
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 |
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 . |
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. |
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. |
properties | String | The 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:
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
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
thread_id | String | The ID of the thread. | Yes |
For the descriptions of the other path parameters, see Common Parameters.
Query parameter
Parameter | Type | Description | Required |
---|---|---|---|
limit | String | The maximum number of threads to retrieve per page. The range is [1, 50]. The default value is 50. | No |
cursor | String | The 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:
Parameter | Type | Description |
---|---|---|
affiliations | List | The user IDs of users to add to the thread. You can pass in up to 10 user IDs. |
properties.cursor | String | The 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
Response example
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
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
thread_id | String | The 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
Parameter | Type | Description | Required |
---|---|---|---|
usernames | List | The 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
Response example
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
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
thread_id | String | The 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
Parameter | Type | Description | Required |
---|---|---|---|
usernames | List | The 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:
Parameter | Type | Description |
---|---|---|
result | Boolean | Whether the specified thread member is removed from the thread:
|
user | String | The 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
Response example
Status codes
For details, see HTTP Status Codes.