更新群置顶
更新群组中的群置顶信息,可以将群中的某一条消息,或群公告置顶展示。
前提条件
应用需要开启机器人能力。
使用限制
调用接口的机器人或者用户必须要在群组内,且和该群组属于同一租户。
请求
| 项目 | 值 |
|---|---|
| HTTP URL | https://open.feishu.cn/open-apis/im/v1/chats/:chat_id/top_notice/put_top_notice |
| HTTP Method | POST |
| 接口频率限制 | 1000 次/分钟、50 次/秒 |
| 支持的应用类型 | custom,isv |
| 权限要求 调用该 API 所需的权限。开启其中任意一项权限即可调用 开启任一权限即可 | im:chat 获取与更新群组信息 im:chat.top_notice:write_only 操作群置顶 |
请求头
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
| Authorization | string | 是 | tenant_access_token 或 user_access_token 值格式:"Bearer access_token" 示例值:"Bearer u-7f1bcd13fc57d46bac21793a18e560" 了解更多:如何选择与获取 access token |
| Content-Type | string | 是 | 固定值:"application/json; charset=utf-8" |
路径参数
| 名称 | 类型 | 描述 |
|---|---|---|
chat_id | string | 群 ID。获取方式: - 创建群,从返回结果中获取该群的 chat_id。 - 调用获取用户或机器人所在的群列表接口,可以查询用户或机器人所在群的 chat_id。 - 调用搜索对用户或机器人可见的群列表,可搜索用户或机器人所在的群、对用户或机器人公开的群的 chat_id。 示例值:"oc_5ad11d72b830411d72b836c20" |
请求体
| 名称 | 类型 | 必填 | 描述 |
|---|---|---|---|
chat_top_notice | chat.top_notice\[\] | 是 | 群置顶配置 |
└ action_type | string | 否 | 置顶类型 示例值:"2" 可选值有: - 1: 消息类型,必需填写 message_id - 2: 群公告类型,无需填写 message_id默认值: 2 |
└ message_id | string | 否 | 消息 ID。ID 获取方式: - 调用发送消息接口后,从响应结果的 message_id 参数获取。 - 监听接收消息事件,当触发该事件后可以从事件体内获取消息的 message_id。 - 调用获取会话历史消息接口,从响应结果的 message_id 参数获取。示例值:"om_dc13264520392913993dd051dba21dcf" |
请求体示例
json
{
"chat_top_notice": [
{
"action_type": "2",
"message_id": "om_dc13264520392913993dd051dba21dcf"
}
]
}响应
响应体
| 名称 | 类型 | 描述 |
|---|---|---|
code | int | 错误码,非 0 表示失败 |
msg | string | 错误描述 |
data | \- | - |
响应体示例
json
{
"code": 0,
"msg": "success",
"data": {}
}错误码
| HTTP状态码 | 错误码 | 描述 | 排查建议 |
|---|---|---|---|
| 400 | 230111 | Action unavailable as the message will self-destruct soon. | 消息将过期,无法进行操作。 |
| 400 | 232001 | Your request contains an invalid request parameter. | 参数错误。请参考 API 文档参数描述,排查请求时参数是否填写有误。 |
| 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. | 调用接口的操作者不在群组内,无法操作。你需要将当前调用 API 的应用或用户加入待操作的群组后重试。 |
| 400 | 232014 | The token used in the request does NOT have the permissions necessary to complete the request. | 操作者没有权限进行该操作,请检查当前操作者在群组内是否有权限管理置顶消息。 |
| 400 | 232024 | Users do not have the visibility of the app, or the operator does not have collaboration permissions with the target users. | 机器人对用户没有可见性,或操作者与用户间没有协作权限。 - 如果是机器人对用户没有可见性,需要在开发者后台 > 应用详情页 > 应用发布 > 版本管理与发布 编辑应用对用户的可见性并发布应用。具体操作参考配置应用可用范围。 - 如果是操作者与用户之间没有协作权限,请检查是否与目标用户有协作权限,如屏蔽、未添加为联系人等。 |
| 400 | 232025 | Bot ability is not activated. | 应用未启用机器人能力。你需要登录开发者后台,在应用详情页的 应用能力 > 添加应用能力 页面内,添加 机器人 能力,并发布应用使配置生效。具体操作参见机器人能力。 |
| 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 inactivate in the tenant. | 应用在本租户下未安装或未启用。需要先安装应用,再使用应用调用接口。 |
更多错误码信息,参见通用错误码。
