Manage chat group announcement and files
This page shows how to manage the group announcement and group files 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.
Retrieving the chat group announcement
Retrieves the announcement of the specified chat group.
For each App Key, the call frequency limit of this method is 100 per second.
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 |
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 |
---|---|---|
announcement | String | The content of the group announcement. |
For other fields and descriptions, see Common 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
Modifying the chat group announcement
Modifies the announcement of the specified chat group. The group announcement cannot exceed 512 characters.
For each App Key, the call frequency limit of this method is 100 per second.
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 |
---|---|---|---|
announcement | String | The content of the group announcement. | 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 |
---|---|---|
id | String | The group ID. |
result | Boolean | Whether the group announcement is successfully modified.
|
For other fields and descriptions, see Common 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 chat group shared files
Retrieves the shared files of the specified chat group with pagination. Each page can have a maximum of 1000 shared files.
After successfully calling this method, you can get the file_id
from the response, which is the unique file ID that identifies the shared file. This field can be used to specify a shared file when you download or remove it.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
For the descriptions of other path parameters, 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 |
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 |
---|---|---|
file_id | String | The ID of the chat group shared file. This field is required if you want to download or remove a group's shared files. |
file_name | String | The name of the chat group shared file. |
file_owner | String | The ID of the user uploading the shared file. |
file_size | Number | The size of the chat group shared file, in bytes. |
created | Long | The Unix timestamp for uploading the group shared file. |
For other fields and descriptions, see Common 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
Uploading a chat group shared file
Uploads a chat group shared file. This shared file cannot exceed 10 MB.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
For the descriptions of other path parameters, 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 |
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 |
---|---|---|
file_url | String | The URL to shared files of groups on the Chat server. |
group_id | String | The group ID. |
file_name | String | The name of the group's shared file. |
created | Long | The upload time of the group's shared file. |
file_id | String | The ID of the group's shared file. This field is required if you want to download or remove a group's shared files. |
file_size | Number | The size of the group's shared file, in the unit of bytes. |
For other fields and descriptions, see Common 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
Downloading the chat group shared file
Downloads a shared file of the chat group. You can get the file ID (file_id
) from the response body of Retrieving the chat group shared files.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
file_id | String | The file 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 response body contains only the content of the uploaded file. For example, the content of the uploaded file is Hello world
, the response body only contains Hello world
.
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
The response contains only the content of the uploaded file. For example, the content of the uploaded file is Hello world
, the response only contains Hello world
.
Deleting a chat group shared file
Deletes a chat group shared file. You can get the file ID (file_id
) from the response body of Retrieving the chat group shared files.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
group_id | String | The group ID. | Yes |
file_id | String | The file 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 |
---|---|---|
group_id | String | The group ID. |
file_id | String | The ID of the chat group shared file. This field is required if you want to download or remove a shared files. |
result | Boolean | The result of deleting the file: |
For other fields and descriptions, see Common 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
Status codes
For details, see HTTP Status Codes.