服务端 API/消息/消息管理/撤回消息
# 撤回消息

机器人撤回机器人自己发送的消息或群主撤回群内消息。

**注意事项**：注意事项:
- 需要开启[机器人能力](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)  ，撤回消息时机器人仍需要在会话内
- 机器人可以撤回单聊和群组内，自己发送 且 发送时间不超过租户管理员配置的可撤回时限的消息（默认为24小时）
- 若机器人要撤回群内他人发送的消息，则机器人必须是该群的群主、管理员 或者 创建者，且消息发送时间不超过1年
- 无法撤回通过「[批量发送消息](https://open.larksuite.com/document/ukTMukTMukTM/ucDO1EjL3gTNx4yN4UTM)」接口发送的消息

## 请求

基本 | &nbsp;
---|---
HTTP URL | https://open.larksuite.com/open-apis/im/v1/messages/:message_id
HTTP Method | DELETE
接口频率限制 | [1000 次/分钟、50 次/秒](https://open.larksuite.com/document/ukTMukTMukTM/uUzN04SN3QjL1cDN)
支持的应用类型 | Custom App、Store App
权限要求<br>**调用该 API 所需的权限。开启其中任意一项权限即可调用**<br>开启任一权限即可 | 获取与发送单聊、群组消息(im:message)<br>撤回消息(im:message:recall)<br>以应用的身份发消息(im:message:send_as_bot)

### 请求头

名称 | 类型 | 必填 | 描述
---|---|---|---
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)

Access token与发起撤回的主体相对应

### 路径参数

名称 | 类型 | 描述
---|---|---
message_id | string | 待撤回的消息的ID<br>**示例值**："om_dc13264520392913993dd051dba21dcf"

## 响应

### 响应体

名称 | 类型 | 描述
---|---|---
code | int | 错误码，非 0 表示失败
msg | string | 错误描述
data | \- | \-

### 响应体示例
```json
{
    "code": 0,
    "msg": "success",
    "data": {}
}
```

### 错误码

HTTP状态码 | 错误码 | 描述 | 排查建议
---|---|---|---
400 | 230001 | Your request contains an invalid request parameter. | 参数错误，请根据接口返回的错误信息并参考文档检查输入参数。
400 | 230002 | The bot can not be outside the group. | 机器人不在对应群组中。
400 | 230006 | Bot ability is not activated. | [机器人能力](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/trouble-shooting/how-to-enable-bot-ability)未启用 。可在[开发者后台](https://open.larksuite.com/app) -> 应用能力 -> 添加应用能力页面添加机器人功能，发布新版本后生效。
400 | 230009 | Message can only be recalled within one days. | 消息发出时间过长（1天），不能执行当前操作。
400 | 230013 | Bot has NO availability to this user. | 机器人对用户没有[可用性](https://open.larksuite.com/document/home/introduction-to-scope-and-authorization/availability)。可在[开发者后台](https://open.larksuite.com/app) -> 应用发布 -> 版本管理与发布 -> 创建版本页面编辑应用的可用范围，发布新版本后生效。
400 | 230026 | No permission to recall this message. | 机器人没有权限撤回该消息，只能撤回机器人自己发出的消息。
400 | 230027 | Lack of necessary permissions. | 暂不支持在外部群进行本操作。
400 | 230050 | The message is invisible to the operator. | 该消息对于操作者不可见，无法进行本操作。
400 | 230054 | This operation is not supported for this message type. | 该消息类型不支持本操作，详情参见[消息与群组部分API增加不支持的消息类型校验<br>](https://open.larksuite.com/document/uAjLw4CM/ugTN1YjL4UTN24CO1UjN/breaking-change/unsupported-message-type-verification)。
400 | 230110 | Action unavailable as the message has been deleted. | 消息已被删除.
400 | 232009 | Your request specifies a chat which has already been dissolved. | 群组已被解散。

