# Manage chat rooms (/en/api-reference/api-ref/im/chatroom-management/manage-chatrooms)

> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).

This page shows how to manage chat rooms by calling Chat RESTful APIs, including adding, deleting, modifying, and retrieving chat rooms.

Before calling the following methods, ensure that you understand the frequency limit of calling Chat RESTful API calls described in [Limitations](../limitations#call-limit-of-server-sides).

## Common parameters [#common-parameters]

The following table lists common request and response parameters of the Chat RESTful APIs:

### Request parameters [#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](/en/realtime-media/im/get-started/enable#get-the-information-of-the-agora-chat-project).                                                                                                                                                                                                              | Yes      |
| `app_id`   | String | The unique identifier automatically assigned to each project by Agora                                                                                                                                                                                                                                                                                                                                                                                | 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:* 26 lowercase English letters (a-z)
* 10 numbers (0-9)
* "\_", "-", "."<CalloutContainer type="info">
  <CalloutDescription>
    Do not use any of the 26 uppercase English letters (A-Z). Ensure that each `username` under the same App ID is unique.
  </CalloutDescription>
</CalloutContainer> | Yes      |

### Response parameters [#response-parameters]

| Parameter         | Type   | Description                                                                                          |
| :---------------- | :----- | :--------------------------------------------------------------------------------------------------- |
| `action`          | String | The request method.                                                                                  |
| `organization`    | String | The unique identifier assigned to each company (organization) by the Chat service.                   |
| `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 .                                     |
| `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.                                                                                 |
| `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 [#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:

```html
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](/en/realtime-media/im/build/secure-access-and-authentication/authentication).

<a id="creating-a-chat-room"></a>

## Creating a chat room [#creating-a-chat-room]

Creates a chat room.

### HTTP request [#http-request]

```html
POST https://{host}/app-id/{app_id}/chatrooms
```

#### Path parameter [#path-parameter]

For the parameters and detailed descriptions, see [Common parameters](#param).

#### Request header [#request-header]

| Parameter       | Type   | Description                                                                                                                                                                                      | Required |
| :-------------- | :----- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
| `Accept`        | String | `application/json`                                                                                                                                                                               | Yes      |
| `Content-Type`  | 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 [#request-body]

The request body is a JSON object, which contains the following fields:

| Field         | Type      | Description                                                                                                                                                                                                                                               | Required |
| :------------ | :-------- | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------- |
| `name`        | String    | The chat room name which can contain a maximum of 128 characters.                                                                                                                                                                                         | Yes      |
| `description` | String    | The chat room description which can contain a maximum of 512 characters.                                                                                                                                                                                  | Yes      |
| `maxusers`    | Int       | The maximum number of members (including the chat room owner) that can join a chat room. The value range is \[1,10,000], with `1000` as the default. To increase the upper limit, contact [support@agora.io](mailto\:support@agora.io).                   | No       |
| `owner`       | String    | The username of the chat room creator.                                                                                                                                                                                                                    | Yes      |
| `members`     | JSONArray | The array of user IDs of regular chat room members and administrators, excluding the chat room owner. If you specify this parameter, remember to pass in at least one user ID. The number of user IDs in the array cannot exceed the value of `maxusers`. | No       |

### HTTP response [#http-response]

#### Response body [#response-body]

If the returned HTTP status code is `200`, the request succeeds, and the response body contains the following fields:

| Field | Type   | Description                                                                                     |
| :---- | :----- | :---------------------------------------------------------------------------------------------- |
| `id`  | String | The chat room ID. This is the unique identifier assigned to each chat room by the Chat service. |

For other fields and detailed descriptions, see [Common parameters](#param).

If the returned HTTP status code is not `200`, the request fails. You can refer to [Status codes](#code) for possible reasons.

### Example [#example]

#### Request example [#request-example]

```json
# Replace  with the app token you generated on the server
curl -X POST -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer ' -d '{
   "name": "testchatroom1",
   "description": "test",
   "maxusers": 300,
   "owner": "user1",
   "members": [
     "user2"
   ]
 }' 'http://XXXX/app-id/XXXX/chatrooms'
```

#### Response example [#response-example]

```json
{
    "data": {
        "id": "66213271109633"
    }
}
```

## Retrieving basic information of all chat rooms [#retrieving-basic-information-of-all-chat-rooms]

Retrieves the basic information of all chat rooms under the app by page.

### HTTP request [#http-request-1]

```html
GET https://{host}/app-id/{app_id}/chatrooms?limit={N}&cursor={cursor}
```

#### Path parameter [#path-parameter-1]

For the parameters and detailed descriptions, see [Common parameters ](#param).

#### Query parameters [#query-parameters]

| parameter | type   | describe                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | Is it required? |
| :-------- | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :-------------- |
| `limit`   | Number | The number of chat rooms expected to be fetched each time. The value range is \[1,100], the default is `10`, This parameter is only required when fetching pages.                                                                                                                                                                                                                                                                                                               | No              |
| `cursor`  | String | The starting position for data query. This parameter is required only for paginated queries.  For the first query, you do not need to set `cursor` and the server returns chat rooms of the number specified with `limit` in the descending order of their creation time. You can get the cursor from the response body and pass it in the URL of the next query request. If there is no longer a `cursor` field in the response body, all chat rooms in the app are retrieved. | No              |

<CalloutContainer type="info">
  <CalloutDescription>
    If neither `limit` nor `cursor` is set, the server returns the first page of the chat room list with 10 chat rooms.
  </CalloutDescription>
</CalloutContainer>

#### Request header [#request-header-1]

| 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 [#http-response-1]

#### Response body [#response-body-1]

If the returned HTTP status code is `200`, the request succeeds. The response body contains the following fields:

| Field                | Type   | Description                                                                            |
| :------------------- | :----- | :------------------------------------------------------------------------------------- |
| `id`                 | String | The chat room ID. This is the unique identifier assigned to the chat room by the Chat. |
| `name`               | String | The chat room name.                                                                    |
| `owner`              | String | The username of the chat room creator.                                                 |
| `affiliations_count` | Number | The number of members (including the chat room creator) in the chat room.              |

For other fields and detailed descriptions, see [Common parameters](#param).

If the returned HTTP status code is not `200`, the request fails. You can refer to [Status codes](#code) for possible reasons.

### Example [#example-1]

#### Request example [#request-example-1]

```bash
# Replace  with the app token you generated on the server
curl --location --request GET 'http://XXXX/app-id/XXXX/chatrooms?limit=10' \
--header 'Authorization: Bearer '
```

## Retrieving chat rooms that a user joins [#retrieving-chat-rooms-that-a-user-joins]

Retrieves all the chat rooms that a user joins.

### HTTP request [#http-request-2]

```bash
GET https://{host}/app-id/{app_id}/users/{username}/joined_chatrooms?pagenum={N}&pagesize={N}
```

#### Path parameter [#path-parameter-2]

For the parameters and detailed descriptions, see [Common parameters ](#param).

#### Query parameter [#query-parameter]

| Parameter  | Type   | Description                                                                                                   | Required |
| :--------- | :----- | :------------------------------------------------------------------------------------------------------------ | :------- |
| `pagenum`  | Number | The page number on which chat rooms are to be retrieved.                                                      | No       |
| `pagesize` | Number | The number of chat rooms to be retrieved each time. The value range is \[1,1000], with `1000` as the default. | No       |

<CalloutContainer type="info">
  <CalloutDescription>
    If neither query parameter is specified, the server returns the 500 chat rooms that the user joined most recently.
  </CalloutDescription>
</CalloutContainer>

#### Request header [#request-header-2]

| 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 [#http-response-2]

#### Response body [#response-body-2]

If the returned HTTP status code is `200`, the request succeeds. The response body contains the following fields:

| Field  | Type   | Descriptions                                                                                                       |
| :----- | :----- | :----------------------------------------------------------------------------------------------------------------- |
| `id`   | String | The ID of the chat room that the user joins. This is the unique identifier assigned to each chat room by the Chat. |
| `name` | String | The name of the chat room that the user joins.                                                                     |

For other fields and detailed descriptions, see [Common parameters](#param).

If the returned HTTP status code is not `200`, the request fails. You can refer to [Status codes](#code) for possible reasons.

### Example [#example-2]

#### Request example [#request-example-2]

```json
# Replace  with the app token generated in your server.
curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer ' 'http://XXXX/app-id/XXXX/users/XXXX/joined_chatrooms'
```

#### Response example [#response-example-1]

```json
{
    "data": {
        "id": "66211860774913",
        "name": "test"
    }
}
```

## Retrieving detailed information of the specified chat rooms [#retrieving-detailed-information-of-the-specified-chat-rooms]

Retrieves the detailed information of one or more specified chat rooms.

### HTTP request [#http-request-3]

```json
GET https://{host}/app-id/{app_id}/chatrooms/{chatroom_id}
```

#### Path parameter [#path-parameter-3]

| Parameter     | Type   | Description                                                                                                                                                                                                                                                                                                                                                                                                               | Required |
| :------------ | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------- |
| `chatroom_id` | String | The chat room ID. The unique identifier assigned to each chat room by the Chat service. You can get the chat room ID from the response body of [Retrieve basic information of all chat rooms](#getall).When retrieving multiple chat rooms, type multiple chatroom IDs (`chatroom_id`) separated with the comma (,). A maximum of 100 chat rooms can be retrieved at one go.In the URL, "," needs to be escaped as "%2C". | Yes      |

For other parameters and detailed descriptions, see [Common parameters](#param).

#### Request header [#request-header-3]

| 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 [#http-response-3]

### Response body [#response-body-3]

If the returned HTTP status code is `200`, the request succeeds. The response body contains the following fields:

| Field                | Type      | Description                                                                                                                                                                                                                        |
| :------------------- | :-------- | :--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `id`                 | String    | The chat room ID.                                                                                                                                                                                                                  |
| `name`               | String    | The chat room name.                                                                                                                                                                                                                |
| `description`        | String    | The chat room description.                                                                                                                                                                                                         |
| `membersonly`        | Bool      | Whether a user requesting to join the chat room requires approval from the chat room administrator. `true`: Yes. `false`: No                                                                                                       |
| `allowinvites`       | Bool      | Whether to allow a chat room member to invite others to join the chat room. `true`: A chat room member can invite others to join the chat room. `false`: Only the chat room administrator can invite others to join the chat room. |
| `maxusers`           | Int       | The maximum number of members that can join the chat room.                                                                                                                                                                         |
| `owner`              | String    | The username of the chat room creator.                                                                                                                                                                                             |
| `created`            | Number    | The Unix timestamp (ms) when the chat room is created.                                                                                                                                                                             |
| `custom`             | String    | Custom information added during creation of the chat room.                                                                                                                                                                         |
| `affiliations_count` | Number    | The number of members (including the chat room creator) in the chat room.                                                                                                                                                          |
| `affiliations`       | JSONArray | The chat room member array, which contains the following fields: `owner`: The username of the chat room creator. `member`: The username of each chat room member.                                                                  |
| `public`             | Bool      | It is a reserved parameter. You can safely ignore this parameter.                                                                                                                                                                  |

For other fields and detailed descriptions, see [Common parameters](#param).

If the returned HTTP status code is not `200`, the request fails. You can refer to [Status codes](#code) for possible reasons.

### Example [#example-3]

#### Request example [#request-example-3]

```json
# Replace  with the app token generated in your server.
curl -X GET -H 'Accept: application/json' -H 'Authorization: Bearer ' 'http://XXXX/app-id/XXXX/chatrooms/XXXX%2CXXXX'
```

#### Response example [#response-example-2]

```json
{
    "action": "get",
    "application": "22bcffa0-XXXX-XXXX-9df8-516f6df68c6d",
    "applicationName": "XXXX",
    "count": 2
    "data": [
        {
            "id": "XXXX",
            "name": "testchatroom1",
            "description": "test",
            "membersonly": false,
            "allowinvites": false,
            "maxusers": 1000,
            "created": 1641365888209,
            "custom": "",
            "affiliations_count": 2,
            "affiliations": [
                {
                    "member": "user1"
                },
                {
                    "owner": "user2"
                }
            ],
            "public": true
        },
        {
            "id": "XXXX",
            "name": "testchatroom2",
            "description": "test",
            "membersonly": false,
            "allowinvites": false,
            "invite_need_confirm": true,
            "maxusers": 10000,
            "created": 1641289021898,
            "custom": "",
            "mute": false,
            "affiliations_count": 1,
            "affiliations": [
                {
                    "owner": "user3"
                }
            ],
            "public": true
        }
    ],
    "duration": 0,
    "entities": [],
    "organization": "XXXX",
    "timestamp": 1642064417048,
    "uri": "http://XXXX/app-id/XXXX/chatrooms/XXXX%2CXXXX"
}
```

## Modifying chat room information [#modifying-chat-room-information]

Modifies the information of the specified chat room. You can only modify the `name`, `description`, and `maxusers` of a chat room.

### HTTP request [#http-request-4]

```html
PUT https://{host}/app-id/{app_id}/chatrooms/{chatroom_id}
```

#### Path parameter [#path-parameter-4]

| Parameter     | Type   | Description                                                                                                                                                                                             | Required |
| :------------ | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------- |
| `chatroom_id` | String | The chat room ID. The unique identifier assigned to each chat room by the Chat service. You can get the chat room ID from the response body of [Retrieve basic information of all chat rooms](#getall). | Yes      |

For other parameters and detailed descriptions, see [Common parameters](#param).

#### Request header [#request-header-4]

| 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 [#request-body-1]

The request body is a JSON object which only contains the following fields:

| Field         | Type   | Description                                                                | Required |
| :------------ | :----- | :------------------------------------------------------------------------- | :------- |
| `name`        | String | The chat room name.                                                        | No       |
| `description` | String | The chat room description.                                                 | No       |
| `maxusers`    | Number | The maximum number of chat room members (including the chat room creator). | No       |

### HTTP response [#http-response-4]

#### Response body [#response-body-4]

If the returned HTTP status code is `200`, the request succeeds and the response body contains the following fields:

| Field         | Type | Description                                                                                                                   |
| :------------ | :--- | :---------------------------------------------------------------------------------------------------------------------------- |
| `groupname`   | Bool | Whether the chat room name is successfully changed. `true`: Success. `false`: Failure.                                        |
| `description` | Bool | Whether the chat room description is successfully modified. `true`: Success. `false`: Failure.                                |
| `maxusers`    | Bool | Whether the maximum number of members that can join the chat room is successfully changed. `true`: Success. `false`: Failure. |

If the returned HTTP status code is not `200`, the request failed. You can refer to [Status codes](#code) for possible reasons.

> If other fields than `name`, `description`, and `maxusers` are passed in the request body, the request fails and the error code `400` is returned.

### Example [#example-4]

#### Request example [#request-example-4]

```json
curl -X PUT -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer ' -d '{
   "name": "testchatroom",
   "description": "test",
   "maxusers": 300,
 }' 'http://XXXX/app-id/XXXX/chatrooms/XXXX'
```

#### Response example [#response-example-3]

```json
{
    "data": {
        "description": true,
        "maxusers": true,
        "groupname": true
    }
}
```

## Deleting the specified chat room [#deleting-the-specified-chat-room]

Deletes the specified chat room. If the specified chat room does not exist, an error returns.

### HTTP request [#http-request-5]

```html
DELETE https://{host}/app-id/{app_id}/chatrooms/{chatroom_id}
```

#### Path parameter [#path-parameter-5]

| Parameter     | Type   | Description                                                                                                                                                                                             | Required |
| :------------ | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------- |
| `chatroom_id` | String | The chat room ID. The unique identifier assigned to each chat room by the Chat service. You can get the chat room ID from the response body of [Retrieve basic information of all chat rooms](#getall). | Yes      |

For other parameters and detailed descriptions, see [Common parameters](#param).

#### Request header [#request-header-5]

| 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 [#http-response-5]

#### Response body [#response-body-5]

If the returned HTTP status code is `200`, the request succeeds and the response body contains the following fields:

| Field     | Type   | Description                                                                       |
| :-------- | :----- | :-------------------------------------------------------------------------------- |
| `success` | Bool   | Whether the chat room is successfully deleted. `true`: Success. `false`: Failure. |
| `id`      | String | The ID of the chat room that is deleted.                                          |

For other fields and detailed descriptions, see [Common parameters](#param).

If the returned HTTP status code is not `200`, the request fails. You can refer to [Status codes](#code) for possible reasons.

### Example [#example-5]

#### Request example [#request-example-5]

```json
# Replace  with the app token generated in your server.
curl -X DELETE -H 'Accept: application/json' -H 'Authorization: Bearer ' 'http://XXXX/app-id/XXXX/chatrooms/XXXX'
```

#### Response example [#response-example-4]

```json
{
    "action": "delete",
    "application": "8be024f0-XXXX-XXXX-b697-5d598d5f8402",
    "uri": "http://XXXX/app-id/XXXX/chatrooms/XXXX",
    "entities": [],
    "data": {
        "success": true,
        "id": "66211860774913"
    },
    "timestamp": 1542545100474,
    "duration": 0,
    "organization": "XXXX",
    "applicationName": "XXXX"
}
```

## Retrieving a chat room announcement [#retrieving-a-chat-room-announcement]

Retrieves the announcement text for the specified chat room.

### HTTP request [#http-request-6]

```bash
GET https://{host}/app-id/{app_id}/chatrooms/{chatroom_id}/announcement
```

#### Path parameter [#path-parameter-6]

| Parameter     | Type   | Required | Description                                                                                                                                                                                             |
| :------------ | :----- | :------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `chatroom_id` | String | Yes      | The chat room ID. The unique identifier assigned to each chat room by the Chat service. You can get the chat room ID from the response body of [Retrieve basic information of all chat rooms](#getall). |

For other parameters and detailed descriptions, see [Common parameters](#param).

#### Request header [#request-header-6]

| Parameter       | Type   | Required | Description                                                                                                                                                                                      |
| :-------------- | :----- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Content-Type`  | String | Yes      | Set to `application/json`.                                                                                                                                                                       |
| `Accept`        | String | Yes      | `application/json`                                                                                                                                                                               |
| `Authorization` | String | Yes      | 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. |

### HTTP response [#http-response-6]

The response body contains the following fields:

| Parameter         | Type   | Description                                       |
| :---------------- | :----- | :------------------------------------------------ |
| data.announcement | String | The announcement text of the specified chat room. |

### Example [#example-6]

#### Request example [#request-example-6]

```bash
curl -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer  ' 'http://XXXX/app-id/XXXX/chatrooms/XXXX/announcement'
```

#### Response example [#response-example-5]

```json
{
  "action": "get",
  "application": "52XXXXf0",
  "uri": "http://XXXX/app-id/XXXX/chatrooms/12XXXX11/announcement",
  "entities": [],
  "data": {
    "announcement" : " announcement text"
  },
  "timestamp": 1542363546590,
  "duration": 0,
  "organization": "XXXX",
  "applicationName": "testapp"
}
```

## Modifying the announcement of a chat room [#modifying-the-announcement-of-a-chat-room]

Modifies the announcement text of the specified chat room. The length cannot exceed 512 characters.

### HTTP request [#http-request-7]

```bash
POST https://{host}/app-id/{app_id}/chatrooms/{chatroom_id}/announcement
```

#### Path parameter [#path-parameter-7]

| Parameter     | Type   | Description                                                                                                                                                                                             | Required |
| :------------ | :----- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | :------- |
| `chatroom_id` | String | The chat room ID. The unique identifier assigned to each chat room by the Chat service. You can get the chat room ID from the response body of [Retrieve basic information of all chat rooms](#getall). | Yes      |

For other parameters and detailed descriptions, see [Common parameters](#param).

#### Request header [#request-header-7]

| Parameter       | Type   | Required | Description                                                                                                                                                                                      |
| :-------------- | :----- | :------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Content-Type`  | String | Yes      | Set to `application/json`.                                                                                                                                                                       |
| `Authorization` | String | Yes      | 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. |

#### Request body [#request-body-2]

| Parameter      | Type   | Required | Description                     |
| :------------- | :----- | :------- | :------------------------------ |
| `announcement` | String | Yes      | The modified announcement text. |

### HTTP response [#http-response-7]

#### Response body [#response-body-6]

If the returned HTTP status code is `200`, the request succeeds and the response body contains the following fields:

| Parameter   | Type    | Description                                                                                         |
| :---------- | :------ | :-------------------------------------------------------------------------------------------------- |
| data.id     | String  | The chat room ID.                                                                                   |
| data.result | Boolean | Whether the chat room announcement is successfully modified:  - `true`: Success - `false`: Failure. |

For other fields and detailed descriptions, see [Common parameters](#param).

If the returned HTTP status code is not `200`, the request fails. You can refer to [Status codes](#code) for possible reasons.

### Example [#example-7]

#### Request example [#request-example-7]

```bash
curl -X GET -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'Authorization: Bearer  ' 'http://XXXX/app-id/XXXX/chatrooms/12XXXX11/announcement' -d '{"announcement" : "chat room announcement"}'
```

#### Response example [#response-example-6]

```json
{
  "action": "post",
  "application": "52XXXXf0",
  "uri": "http://XXXX/app-id/XXXX/chatrooms/12XXXX11/announcement",
  "entities": [],
  "data": {
    "id": "12XXXX11",
    "result": true
  },
  "timestamp": 1594808604236,
  "duration": 0,
  "organization": "XXXX",
  "applicationName": "testapp"
}
```

## Status codes [#status-codes]

For details, see [HTTP Status Codes](../http-status-codes).
