> ## Documentation Index
> Fetch the complete documentation index at: https://help.dingtalk.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Create, update, query, and delete meeting room groups

> Use an internal app and smart meeting room APIs to create, update, and query meeting room groups, covering expected results, prerequisites, credentials, and permissions.

This document describes how to create an internal app and use the APIs provided by the Smart meeting room to create, update, query, and delete meeting room groups.

## Expected result

The meeting room group result is shown below:

## Process overview

Prerequisite: Complete the [App creation and configuration](/open/dingstart/create-application) process.

Step 1: Obtain the App credential, including the client ID and Client Secret.

Step 2: Request API permissions for the Smart meeting room APIs.

Step 3: Obtain the App access credential by following [Obtain the access token of an internal app](/open/development/obtain-the-access-token-of-an-internal-app). When calling APIs, the access token is used to authenticate the caller.

Step 4: Call the meeting room APIs:

1. Call the Server API [Create meeting room groups](/open/development/create-meeting-room-groups) and obtain the `result` field from the response, which is the meeting room group ID.
2. Use the meeting room group ID to call the Server API [Update meeting room groups](/open/development/update-meeting-room-groups) to update the meeting room group information.
3. Call the Server API [Query meeting room groups list](/open/development/query-meeting-rooms-groups) to retrieve the list of meeting room groups.
4. Use the meeting room group ID to call the Server API [Query meeting room group](/open/development/query-meeting-room-groups) to retrieve detailed information about a single meeting room group.
5. Use the meeting room group ID to call the Server API [Delete a meeting room group](/open/development/delete-a-conference-room-group) to delete the meeting room group.

## Prerequisite

Complete the [App creation and configuration](/open/dingstart/create-application) process.

## Step 1: Obtain the App credential

1. Select the target App and go to the App details page. Click **Basic Information** > **Credentials and Basic Information**.
2. Obtain the client ID and Client Secret.

## Step 2: Add API permissions

Click **Development Configuration** > **Manage permissions**. In the permission search box, enter `VideoConference.Conference.Write` and `VideoConference.Conference.Read` respectively, and request the permissions.

## Step 3: Obtain the App access token

<Warning>
  For differences between Server API versions, see the legacy API vs. new API comparison. The following APIs all use Server APIs. For SDK downloads, see the server-side SDK download page.
</Warning>

Use the client ID and Client Secret obtained in Step 1 to obtain the App access token by following [Obtain the access token of an internal app](/open/development/obtain-the-access-token-of-an-internal-app).

```java theme={"theme":{"light":"github-light","dark":"github-dark"}}
 public void getAccessToken() throws Exception {
        Config config = new Config();
        config.protocol = "https";
        config.regionId = "central";
        com.aliyun.dingtalkoauth2_1_0.Client client = new com.aliyun.dingtalkoauth2_1_0.Client(config);
        GetAccessTokenRequest accessTokenRequest = new GetAccessTokenRequest()
                .setAppKey("din*********hgn")
                .setAppSecret("9G_O************mBkhgGIO");
        GetAccessTokenResponse accessToken = client.getAccessToken(accessTokenRequest);
        System.out.println(JSON.toJSONString(accessToken.getBody()));
    }
```

## Step 4: Call the meeting room group APIs

1. Call the Server API [Create meeting room groups](/open/development/create-meeting-room-groups) and obtain the `result` field from the response, which is the meeting room group ID.

   ```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
   public void createRoomsGroups() throws Exception {
           com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
           config.protocol = "https";
           config.regionId = "central";
           com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
           com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomGroupHeaders createMeetingRoomGroupHeaders = new com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomGroupHeaders();
           createMeetingRoomGroupHeaders.xAcsDingtalkAccessToken = "accessToken";
           com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomGroupRequest createMeetingRoomGroupRequest = new com.aliyun.dingtalkrooms_1_0.models.CreateMeetingRoomGroupRequest()
                   .setUnionId("E9CS6X*******eN7QiEiE")
                   .setGroupName("First Group")
                   .setParentGroupId(0L);
           try {
               CreateMeetingRoomGroupResponse meetingRoomGroupWithOptions = client.createMeetingRoomGroupWithOptions(createMeetingRoomGroupRequest, createMeetingRoomGroupHeaders, new RuntimeOptions());
               System.out.println(JSON.toJSONString(meetingRoomGroupWithOptions.getBody()));
           } catch (TeaException err) {
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           } catch (Exception _err) {
               TeaException err = new TeaException(_err.getMessage(), _err);
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           }
       }
   ```
2. Use the meeting room group ID to call the Server API [Update meeting room groups](/open/development/update-meeting-room-groups) to update the meeting room group information.

   ```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
    public void updateRoomsGroups() throws Exception {
           com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
           config.protocol = "https";
           config.regionId = "central";
           com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
           com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomGroupHeaders updateMeetingRoomGroupHeaders = new com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomGroupHeaders();
           updateMeetingRoomGroupHeaders.xAcsDingtalkAccessToken = "accessToken";
           com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomGroupRequest updateMeetingRoomGroupRequest = new com.aliyun.dingtalkrooms_1_0.models.UpdateMeetingRoomGroupRequest()
                   .setUnionId("E9CS6X*******eN7QiEiE")
                   .setGroupName("My First Group")
                   .setGroupId(39L);
           try {
               UpdateMeetingRoomGroupResponse updateMeetingRoomGroupResponse = client.updateMeetingRoomGroupWithOptions(updateMeetingRoomGroupRequest, updateMeetingRoomGroupHeaders, new RuntimeOptions());
               System.out.println(JSON.toJSONString(updateMeetingRoomGroupResponse.getBody()));
           } catch (TeaException err) {
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           } catch (Exception _err) {
               TeaException err = new TeaException(_err.getMessage(), _err);
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           }
       }
   ```
3. Call the Server API [Query meeting room groups list](/open/development/query-meeting-rooms-groups) to retrieve the list of meeting room groups.

   ```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
    public void RoomsGroupsList() throws Exception {
           com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
           config.protocol = "https";
           config.regionId = "central";
           com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
           com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupListHeaders queryMeetingRoomGroupListHeaders = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupListHeaders();
           queryMeetingRoomGroupListHeaders.xAcsDingtalkAccessToken = "accessToken";
           com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupListRequest queryMeetingRoomGroupListRequest = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupListRequest()
                   .setUnionId("E9CS6X*******eN7QiEiE");
           try {
               QueryMeetingRoomGroupListResponse queryMeetingRoomGroupListResponse = client.queryMeetingRoomGroupListWithOptions(queryMeetingRoomGroupListRequest, queryMeetingRoomGroupListHeaders, new RuntimeOptions());
               System.out.println(JSON.toJSONString(queryMeetingRoomGroupListResponse.getBody()));
           } catch (TeaException err) {
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           } catch (Exception _err) {
               TeaException err = new TeaException(_err.getMessage(), _err);
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           }
       }
   ```
4. Use the meeting room group ID to call the Server API [Query meeting room group](/open/development/query-meeting-room-groups) to retrieve detailed information about a single meeting room group.

   ```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
   public void RoomsGroupsInfo() throws Exception {
           com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
           config.protocol = "https";
           config.regionId = "central";
           com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
           com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupHeaders queryMeetingRoomGroupHeaders = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupHeaders();
           queryMeetingRoomGroupHeaders.xAcsDingtalkAccessToken = "accessToken";
           com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupRequest queryMeetingRoomGroupRequest = new com.aliyun.dingtalkrooms_1_0.models.QueryMeetingRoomGroupRequest()
                   .setUnionId("E9CS6X*******eN7QiEiE");
           try {
               QueryMeetingRoomGroupResponse queryMeetingRoomGroupResponse = client.queryMeetingRoomGroupWithOptions("39", queryMeetingRoomGroupRequest, queryMeetingRoomGroupHeaders, new RuntimeOptions());
               System.out.println(JSON.toJSONString(queryMeetingRoomGroupResponse.getBody()));
           } catch (TeaException err) {
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }

           } catch (Exception _err) {
               TeaException err = new TeaException(_err.getMessage(), _err);
               if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                   // The err object contains code and message properties, which help developers locate the issue
                   System.out.println(err.code);
                   System.out.println(err.message);
               }
           }
       }
   ```
5. Use the meeting room group ID to call the Server API [Delete a meeting room group](/open/development/delete-a-conference-room-group) to delete the meeting room group.

### Note

A meeting room group cannot be deleted if it contains any meeting rooms.

```java lines theme={"theme":{"light":"github-light","dark":"github-dark"}}
 public void  deleteRoomsGroups() throws Exception {
        com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
        config.protocol = "https";
        config.regionId = "central";
        com.aliyun.dingtalkrooms_1_0.Client client = new com.aliyun.dingtalkrooms_1_0.Client(config);
        com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomGroupHeaders deleteMeetingRoomGroupHeaders = new com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomGroupHeaders();
        deleteMeetingRoomGroupHeaders.xAcsDingtalkAccessToken = "accessToken";
        com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomGroupRequest deleteMeetingRoomGroupRequest = new com.aliyun.dingtalkrooms_1_0.models.DeleteMeetingRoomGroupRequest()
                .setUnionId("E9CS6X*******eN7QiEiE");
        try {
            DeleteMeetingRoomGroupResponse deleteMeetingRoomGroupResponse = client.deleteMeetingRoomGroupWithOptions("40", deleteMeetingRoomGroupRequest, deleteMeetingRoomGroupHeaders, new RuntimeOptions());
            System.out.println(JSON.toJSONString(deleteMeetingRoomGroupResponse.getBody()));
        } catch (TeaException err) {
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // The err object contains code and message properties, which help developers locate the issue
                System.out.println(err.code);
                System.out.println(err.message);
            }
        } catch (Exception _err) {
            TeaException err = new TeaException(_err.getMessage(), _err);
            if (!com.aliyun.teautil.Common.empty(err.code) && !com.aliyun.teautil.Common.empty(err.message)) {
                // The err object contains code and message properties, which help developers locate the issue
                System.out.println(err.code);
                System.out.println(err.message);
            }
        }
    }
```
