Skip to main content

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

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
chatroom_idStringThe 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

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 URL. You can safely ignore this parameter.
entities JSONThe response entity.
dataJSONThe details of the response.
timestampNumberThe Unix timestamp (ms) when the user is registered.
durationNumberThe 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:


_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.

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


_1
POST https://{host}/{org_name}/{app_name}/chatrooms/super_admin

Path parameter

For the parameters and detailed descriptions, see Common parameters .

Request header

ParameterTypeDescriptionRequired
Content-TypeStringapplication/jsonYes
AcceptStringapplication/jsonYes
AuthorizationStringThe 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:

FieldTypeDescriptionRequired
superadminStringThe 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:

FieldTypeDescription
resultBoolThe addition result:
  • true: Success
  • false: Failure
  • resourceStringIt 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


    _4
    curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>'-d
    _4
    '{
    _4
    "superadmin": user1
    _4
    }''http://XXXX/XXXX/XXXX/chatrooms/super_admin'

    Response example


    _14
    {
    _14
    "action": "post",
    _14
    "application": "9fa492a0-XXXX-XXXX-b1b9-a76b05da6904",
    _14
    "uri": "https://XXXX/XXXX/XXXX/chatrooms/super_admin",
    _14
    "entities": [],
    _14
    "data": {
    _14
    "result": "success",
    _14
    "resource": ""
    _14
    },
    _14
    "timestamp": 1596187658017,
    _14
    "duration": 1,
    _14
    "organization": "XXXX",
    _14
    "applicationName": "XXXX"
    _14
    }

    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.


    _1
    DELETE https://{host}/{org_name}/{app_name}/chatrooms/super_admin/{superAdmin}

    HTTP request

    Path parameter

    ParameterTypeDescriptionRequired
    superAdminStringThe username of the super admin whose privilege is to be revoked.Yes

    For other parameters and detailed descriptions, see Common parameters.

    Request header

    ParameterTypeDescriptionRequired
    AcceptStringapplication/jsonYes
    AuthorizationStringThe 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:

    FieldTypeDescription
    newSuperAdminStringThe username of the super admin whose privilege is revoked.
    resourceStringIt 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


    _1
    curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer <YourAppToken>' 'http://XXXX/XXXX/XXXX/chatrooms/super_admin/XXXX'

    Response example


    _14
    {
    _14
    "action": "delete",
    _14
    "application": "9fa492a0-XXXX-XXXX-b1b9-a76b05da6904",
    _14
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/super_admin/XXXX",
    _14
    "entities": [],
    _14
    "data": {
    _14
    "newSuperAdmin": "XXXX",
    _14
    "resource": ""
    _14
    },
    _14
    "timestamp": 1596187855832,
    _14
    "duration": 0,
    _14
    "organization": "XXXX",
    _14
    "applicationName": "XXXX"
    _14
    }

    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


    _1
    GET https://{host} /{org_name}/{app_name}/chatrooms/super_admin?pagenum={N}&pagesize={N}

    Path parameter

    ParameterTypeDescriptionRequired
    pagenumIntThe number of page on which chat room admins are retrieved. The default value is 1.No
    pagesizeIntThe number of super admins displayed on each page. The default value is 10.No

    For other parameters and detailed descriptions, see Common parameters.

    Request header

    ParameterTypeDescriptionRequired
    AcceptStringapplication/jsonYes
    AuthorizationStringThe 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:

    ParameterTypeDescriptions
    pagenumIntThe current page number.
    pagesizeIntThe maximum number of super administrators displayed on each page.
    dataJSONArrayThe array of usernames of super admins of the specified chat rooms.
    countNumberThe 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


    _1
    curl -X GET http://XXXX/XXXX/XXXX/chatrooms/super_admin?pagenum=2&pagesize=2 -H 'Authorization: Bearer <YourAppToken>'

    Response example


    _16
    {
    _16
    "action": "get",
    _16
    "application": "9fa492a0-XXXX-XXXX-b1b9-a76b05da6904",
    _16
    "params": {
    _16
    "pagesize": ["2"],
    _16
    "pagenum": ["2"]
    _16
    },
    _16
    "uri": "http://XXXX/XXXX/XXXX/chatrooms/super_admin",
    _16
    "entities": [],
    _16
    "data": ["hxtest1", "hxtest11", "hxtest10"],
    _16
    "timestamp": 1596187292391,
    _16
    "duration": 0,
    _16
    "organization": "XXXX",
    _16
    "applicationName": "XXXX",
    _16
    "count": 3
    _16
    }

    Status codes

    For details, see HTTP Status Codes.

    Page Content