服务端 API/群组/群成员/获取群成员列表
# 获取群成员列表

获取用户/机器人所在群的群成员列表。

**注意事项**：注意事项：
 - 应用需要开启[机器人能力](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)
 - 机器人或授权用户必须在群组中
 - 该接口不会返回群内的机器人成员
 - 由于返回的群成员列表会过滤掉机器人成员，因此返回的群成员个数可能会小于指定的page_size
 - 如果有同一时间加入群的群成员，会一次性返回，这会导致返回的群成员个数可能会大于指定的page_size
- 获取内部群信息时，操作者须与群组在同一租户下

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.larksuite.com/open-apis/im/v1/chats/:chat_id/members
HTTP Method | GET
接口频率限制 | [1000 次/分钟、50 次/秒](https://open.larksuite.com/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用**<br>开启任一权限即可 | 获取与更新群组信息(im:chat)<br>读取群信息(im:chat.group_info:readonly)<br>查看群成员(im:chat.members:read)<br>获取群组信息(im:chat:readonly)
字段权限要求 | **注意事项**：该接口返回体中存在下列敏感字段，仅当开启对应的权限后才会返回；如果无需获取这些字段，则不建议申请<br>获取用户 user ID(contact:user.employee_id:readonly)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
Authorization | string | 是 | `tenant_access_token`<br>或<br>`user_access_token`<br>**值格式**："Bearer `access_token`"<br>**示例值**："Bearer u-7f1bcd13fc57d46bac21793a18e560"<br>[了解更多：如何选择与获取 access token](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-choose-which-type-of-token-to-use)

### 路径参数

名称 | 类型 | 描述
---|---|---
chat_id | string | 群 ID，详情参见[群ID 说明](https://open.larksuite.com/document/uAjLw4CM/ukTMukTMukTM/reference/im-v1/chat-id-description)<br>**示例值**："oc_a0553eda9014c201e6969b478895c230"

### 查询参数

名称 | 类型 | 必填 | 描述
---|---|---|---
member_id_type | string | 否 | 用户 ID 类型<br>**示例值**：open_id<br>**可选值有**：<br><br>- open_id：以 open_id 来识别成员<br>**当值为 `user_id`，字段权限要求**：<br>获取用户 user ID(contact:user.employee_id:readonly)
- union_id：以 union_id 来识别成员<br>- user_id：以 user_id 来识别成员<br><br>**默认值**：`open_id`<br>**当值为 `user_id`，字段权限要求**：<br>获取用户 user ID(contact:user.employee_id:readonly)
page_size | int | 否 | 分页大小<br>**示例值**：20<br>**默认值**：`20`<br>**数据校验规则**：<br>- 最大值：`100`
page_token | string | 否 | 分页标记，第一次请求不填，表示从头开始遍历；分页查询结果还有更多项时会同时返回新的 page_token，下次遍历可采用该 page_token 获取查询结果<br>**示例值**：WWxHTStrOEs5WHZpNktGbU94bUcvMWlxdDUzTWt1OXNrRmlLaGRNVG0yaz0=

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-
items | list_member\[\] | 成员列表
member_id_type | string | 成员的用户 ID 类型，与查询参数中的 member_id_type 相同。取值为：`open_id`、`user_id`、`union_id`其中之一。
member_id | string | 成员的用户ID，ID值与查询参数中的 member_id_type 对应。<br>不同 ID 的说明参见 [用户相关的 ID 概念](https://open.larksuite.com/document/home/user-identity-introduction/introduction)
name | string | 名字
tenant_key | string | 租户Key，为租户在Lark上的唯一标识，用来换取对应的tenant_access_token，也可以用作租户在应用中的唯一标识
page_token | string | 分页标记，当 has_more 为 true 时，会同时返回新的 page_token，否则不返回 page_token
has_more | boolean | 是否还有更多项
member_total | int | 成员总数

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {
        "items": [
            {
                "member_id_type": "open_id",
                "member_id": "ou_9204a37300b3700d61effaa439f34295",
                "name": "张三",
                "tenant_key": "736588c9260f175d"
            }
        ],
        "page_token": "dmJCRHhpd3JRbGV1VEVNRFFyTitRWDY5ZFkybmYrMEUwMUFYT0VMMWdENEtuYUhsNUxGMDIwemtvdE5ORjBNQQ==",
        "has_more": true,
        "member_total": 2
    }
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 232001 | Your request contains an invalid request parameter. | 参数错误，参考本文档检查输入参数。
400 | 232004 | Such an app does NOT exist. | 作为操作者的 app_id 不存在，请联系[技术支持](https://applink.larksuite.com/TLJsX982)。
400 | 232006 | Your request specifies a chat_id which is invalid. | 无效的 chat_id，请检查chat_id是否正确。
400 | 232009 | Your request specifies a chat which has already been dissolved. | 群组已被解散。
400 | 232010 | Operator and chat can NOT be in different tenants. | 操作者和被操作的群组应该在同一租户下。
400 | 232011 | Operator can NOT be out of the chat. | 操作者需要在群组中。
400 | 232025 | Bot ability is not activated. | 应用需要开启[机器人能力](https://open.larksuite.com/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. | 没有权限操作外部群，且暂不支持申请该权限。
400 | 232034 | The app is unavailable or inactivated by the tenant. | 应用在本租户下未安装或未启用。

