# Get chat menus

Get the chat menu information in the specified group, including the names, jump links, icons and other information of all top level or second level menus.

## Prerequisites

- The application needs to enable [bot capability](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability).
- The robot calling the current interface must be in the corresponding group.

## Usage restrictions

This interface only supports groups with group mode as `group`. You can call the [Get group information](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/get) interface and check whether the `chat_mode` parameter value is `group` in the returned result.

## Request

Facts | &nbsp;
---|---
HTTP URL | https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/menu_tree
HTTP Method | GET
Rate Limit | [1000 per minute & 50 per second](https://open.feishu.cn/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
Supported app types | Custom App、Store App
Required scopes<br>**To use this API, you must have at least 1 of the listed scopes.**<br>Enable any scope from the list | Obtain and update group information(im:chat)<br>View group menu(im:chat.menu_tree:read)<br>Obtain group information(im:chat:readonly)

### Request header

Parameter | Type | Required | Description
---|---|---|---
Authorization | string | Yes | `tenant_access_token`<br>**Value format**: "Bearer `access_token`"<br>**Example value**: "Bearer t-7f1bcd13fc57d46bac21793a18e560"<br>[How to choose and get access token](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)

### Path parameters

Parameter | Type | Description
---|---|---
chat_id | string | Group ID. How to get it:<br>- [Create a group](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/create), get the chat_id of the group from the returned result.<br>- Call the [Get the list of groups that the user or robot is in](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/list) interface to query the chat_id of the group that the user or robot is in.<br>- Call the [Search the list of groups visible to the user or robot](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/search) to search for the chat_id of the group that the user or robot is in and the group that is open to the user or robot.<br>**Note**: Only group IDs with group mode **Group** are supported. You can call the [get group information](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat/get) interface and check whether the value of the `chat_mode` parameter is `group` in the returned result.<br>**Example value**: "oc_a0553eda9014c201e6969b478895c230"

## Response

### Response body

Parameter | Type | Description
---|---|---
code | int | Error codes, fail if not zero
msg | string | Error descriptions
data | \- | \-
menu_tree | chat.menu_tree | All menus in the chat.
chat_menu_top_levels | chat_menu_top_level\[\] | Top level menu
chat_menu_top_level_id | string | Top level chat menu's id. Chat menu management operations such as deletion, modification, and sorting all require the use of menu IDs.
chat_menu_item | chat_menu_item | Top level menu info
action_type | string | Menu type<br>**Optional values are**:<br>- NONE：NONE type, when only the top level menu has a second level menu, the top level menu is set to NONE type.<br>- REDIRECT_LINK：REDIRECT_LINK type
redirect_link | chat_menu_item_redirect_link | Redirect link
common_url | string | Common redirect link
ios_url | string | IOS client redirect link, when this field is not filled, IOS client will use common_url.
android_url | string | Android client redirect link, when this field is not filled, Android client will use common_url.
pc_url | string | PC client redirect link, when this field is not filled, PC client will use common_url. <br>**Note**: Links starting with `https://applink.feishu.cn/client/web_url/open?mode=sidebar-semi&url=` are expanded in the Feishu sidebar.
web_url | string | Web client redirect link, when this field is not filled, Web client will use common_url.
image_key | string | The key value of the icon. The icon can be downloaded to the local computer through the [Download Image](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/get) interface (only images uploaded by the current robot can be downloaded).<br>**Note**: The icon cannot be set when there is a second level menu under the top level menu.
name | string | Menu name.
i18n_names | i18n_names | Menu I18n names.
zh_cn | string | Chinese name
en_us | string | English name
ja_jp | string | Japanese name
children | chat_menu_second_level\[\] | Second level menu
chat_menu_second_level_id | string | Second level chat menu's id
chat_menu_item | chat_menu_item | Second level menu
action_type | string | Menu type<br>**Optional values are**:<br>- NONE：NONE type<br>- REDIRECT_LINK：REDIRECT_LINK type
redirect_link | chat_menu_item_redirect_link | Redirect link
common_url | string | Common redirect link
ios_url | string | IOS client redirect link, when this field is not filled, IOS client will use common_url.
android_url | string | Android client redirect link, when this field is not filled, Android client will use common_url.
pc_url | string | PC client redirect link, when this field is not filled, PC client will use common_url. <br>**Note**: Links starting with `https://applink.feishu.cn/client/web_url/open?mode=sidebar-semi&url=` are expanded in the Feishu sidebar.
web_url | string | Web client redirect link, when this field is not filled, Web client will use common_url.
image_key | string | The key value of the icon. The icon can be downloaded to the local computer through the [Download Image](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/image/get) interface (only images uploaded by the current robot can be downloaded).
name | string | Menu name.
i18n_names | i18n_names | Menu I18n names.
zh_cn | string | Chinese name
en_us | string | English name
ja_jp | string | Japanese name

### Response body example
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "menu_tree": {
            "chat_menu_top_levels": [
                {
                    "chat_menu_top_level_id": "7117116451961487361",
                    "chat_menu_item": {
                        "action_type": "NONE",
                        "redirect_link": {
                            "common_url": "https://open.feishu.cn/",
                            "ios_url": "https://open.feishu.cn/",
                            "android_url": "https://open.feishu.cn/",
                            "pc_url": "https://open.feishu.cn/",
                            "web_url": "https://open.feishu.cn/"
                        },
                        "image_key": "img_v2_b0fbe905-7988-4282-b882-82edd010336j",
                        "name": "菜单",
                        "i18n_names": {
                            "zh_cn": "菜单",
                            "en_us": "Menu",
                            "ja_jp": "メニュー"
                        }
                    },
                    "children": [
                        {
                            "chat_menu_second_level_id": "7039638308221468675",
                            "chat_menu_item": {
                                "action_type": "REDIRECT_LINK",
                                "redirect_link": {
                                    "common_url": "https://open.feishu.cn/",
                                    "ios_url": "https://open.feishu.cn/",
                                    "android_url": "https://open.feishu.cn/",
                                    "pc_url": "https://open.feishu.cn/",
                                    "web_url": "https://open.feishu.cn/"
                                },
                                "image_key": "img_v2_b0fbe905-7988-4282-b882-82edd010336j",
                                "name": "报名",
                                "i18n_names": {
                                    "zh_cn": "报名",
                                    "en_us": "Sign up",
                                    "ja_jp": "サインアップ"
                                }
                            }
                        }
                    ]
                }
            ]
        }
    }
}
```

### Error code

HTTP status code | Error code | Description | Troubleshooting suggestions
---|---|---|---
400 | 232001 | Your request contains an invalid request parameter. | Parameter error. Check the input parameters according to the appropriate document.
400 | 232011 | Operator can NOT be out of the chat. | The operator is not in the group. You need to [add the application or user currently calling the API to the group to be operated](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-members/create) and try again.
400 | 232014 | The token used in the request does NOT have the permissions necessary to complete the request. | The operator does not have permission to perform this operation, please check whether it has the corresponding permission.
400 | 232024 | Users do not have the visibility of the app, or the operator does not have collaboration permissions with the target users. | The robot is not visible to the user, or the operator does not have collaboration permissions with the user.<br>- If the robot is not visible to the user, you need to edit the visibility of the application to the user and publish the application in [Developer Console](https://open.feishu.cn/app) > **Application Details Page** > **App Versions** > **Version Management & Release**. For specific operations, refer to [Configure Application Availability](https://open.feishu.cn/document/home/introduction-to-scope-and-authorization/availability).<br>- If the operator does not have collaboration permissions with the user, please check whether you have collaboration permissions with the target user, such as blocking or not adding as a contact.
400 | 232025 | Bot ability is not activated. | The app does not have bot capabilities enabled. You need to log in to the [Developer Console](https://open.feishu.cn/app), add the **Bot** capability in **Features** > **Add Features** on the app details page, and publish the app to make the configuration effective. For specific operations, see [Bot Capabilities](https://open.feishu.cn/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability).
400 | 232033 | The operator or invited bots does NOT have the authority to manage external chats without the scope. | The group being operated on is an external group, and operations on external groups are not currently supported. Only bots with external sharing capabilities can support external groups. For more details, please refer to [Bot support for external groups and One-on-One chats with external users](https://open.feishu.cn/document/uAjLw4CM/ukzMukzMukzM/develop-robots/add-bot-to-external-group).
400 | 232034 | The app is unavailable or inactivated by the tenant. | The app is unavailable or inactivated by the tenant.

For more error code information, see [General error codes](https://open.feishu.cn/document/ukTMukTMukTM/ugjM14COyUjL4ITN).

