Recalls a message β deletes it for everyone, not just for you.
π‘ The recalled message still comes back in the response, but with"status": "deleted"and itstextset tonull.
Request
method is "recallMessage".Field | Type | Required | Description |
message_id | String | Yes | The message to recall. |
chat_id | String | Yes | The chat the message is in. |
app_id | String | Yes | The app the message belongs to. |
reference | Long | Yes | Your local id for this request. Echoed back in messageAck. |
from_user_id | String | Conditional | The original sender of the message. Required when your API is recalling someone else's message as a chat admin. |
to_user_id | String | Optional | Target a single user inside a group or channel. |
Preconditions
Requirement | Needed for |
"Delete Message" permission | Recalling any message. |
Chat type | Your API must be |
--- | --- |
User chat | Started by the user, and the original sender of the message |
Group | An admin |
Channel | An admin |
Response
When | Method | What it tells you |
Always | messageAck | The recall was accepted. Carries "status": "deleted". |
Always | message | The recalled message, with "status": "deleted" and text set to null. |
SDKs
SDK | Call | Callback |
Java | api.recallMessage(chatId, messageId, toUserId, reference, appId); | onMessagAckCallback(MessageAck msgAck) |
JavaScript | api.recallMessage(chatId, messageId, toUserId, reference, appId); | onMessagAckCallback(msgAck) |
Python | napi.recall_message(chat_id=chat_id, message_id=message_id, to_user_id=to_user_id, reference=reference, app_id=app_id) | on_message_ack_callback(self, msg_ack) |
π‘ The SDK helpers setto_user_id. To recall another user's message as an admin you needfrom_user_id, which means building aRecallOutMessagedirectly and sending it with the genericsend.
Example
Request
json{ "method": "recallMessage", "message_id": "d1_l4OtAvMz126176", "chat_id": "90090684438172188", "reference": 111111170, "app_id": "90090684293000559" }
javaapi.recallMessage(chatId, messageId, toUserId, reference, appId);
javascriptapi.recallMessage(chatId, messageId, toUserId, reference, appId);
pythonnapi.recall_message(chat_id=chat_id, message_id=message_id, to_user_id=to_user_id, reference=reference, app_id=app_id)
Response
json{ "method": "messageAck", "ack": { "message_id": "d1_l4OtAvMz126176", "reference": 111111170, "date": 1742649426917, "gmid": 38, "status": "deleted" } }
json{ "method": "message", "app_id": 90090684293000559, "message": { "message_id": "d1_l4OtAvMz126176", "reference": 111111170, "date": 1742649426917, "gmid": "38", "type": "text", "text": null, "status": "deleted", "from_admin": 1, "chat": { "id": "90090684438172188", "title": "New Chat", "type": "Group" }, "from": { "id": "90091783822039252", "name": "My First API", "type": "Bot", "terminal": "API" } } }