Manage chat room admins
In an app integrated with Chat, only the super admin of chat rooms has the permission to create chat rooms on the client.
This page shows how to manage super administrators of chat rooms by calling the Chat RESTful APIs, including adding and retrieving super administrators and revoking the chat room creation privilege of a super administrator. Before calling the following methods, ensure that you understand the call frequency limit of the Chat RESTful APIs 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. |
path | String | The request path, which is part of the request URL. You can safely ignore this parameter. |
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. |
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.
Adding a chat room super admin
Adds a regular chat room member as the super admin of the 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 | Description | Required |
---|---|---|---|
Content-Type | String | application/json | Yes |
Accept | String | 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
The request body is a JSON object, which contains the following fields:
Field | Type | Description | Required |
---|---|---|---|
superadmin | String | The username of the user to be added as the super administrator of chat rooms. | Yes |
HTTP response
Response body
If the returned HTTP status code is 200
, the request succeeds, and the response body contains the following fields:
Field | Type | Description |
---|---|---|
result | Bool | The addition result:true : Successfalse : Failure |
resource | String | It is a reserved parameter. You can safely ignore this parameter. |
For other fields and detailed descriptions, see Common parameters.
If the returned HTTP status code is not 200
, the request fails. You can refer to Status codes for possible reasons.
Example
Request example
Response example
Removing a chat room super admin
Removes the super admin privileges of the chat room super admin and that super admin becomes a regular chat room member.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
Parameter | Type | Description | Required |
---|---|---|---|
superAdmin | String | The username of the super admin whose privilege is to be revoked. | Yes |
For other parameters and detailed descriptions, see Common parameters.
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Accept | String | 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 the following fields:
Field | Type | Description |
---|---|---|
newSuperAdmin | String | The username of the super admin whose privilege is revoked. |
resource | String | It is a reserved parameter. You can safely ignore this parameter. |
For other fields and detailed descriptions, see Common parameters.
If the returned HTTP status code is not 200
, the request fails. You can refer to Status codes for possible reasons.
Example
Request example
Response example
Retrieving super admins of specified chat rooms with pagination
Retrieves the super admins of the specified chat rooms by pagination.
For each App Key, the call frequency limit of this method is 100 per second.
HTTP request
Path parameter
For parameters and detailed descriptions, see Common parameters.
Query parameter
Parameter | Type | Description | Required |
---|---|---|---|
pagenum | Number | The number of page on which chat room admins are retrieved. The default value is 1. | No |
pagesize | Number | The number of super admins displayed on each page. The default value is 10. | No |
Request header
Parameter | Type | Description | Required |
---|---|---|---|
Accept | String | 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 the following fields:
Parameter | Type | Descriptions |
---|---|---|
data | JSONArray | The array of usernames of super admins of the specified chat rooms. |
count | Number | The number of super admins that are returned. |
For other fields and detailed descriptions, see Common parameters.
If the returned HTTP status code is not 200
, the request fails. You can refer to Status codes for possible reasons.
Example
Request example
Response example
Status codes
For details, see HTTP Status Codes.