Bad Request: message can't be deleted / message to delete not found — Telegram bot error and how to fix it
Bad Request: message can't be deleted means the message exists but your bot may not delete it: it is older than 48 hours, it belongs to someone else and the bot lacks the right, or it is a service message that can't be removed. Bad Request: message to delete not found means it is already gone or the chat_id and message_id do not match. Delete within 48 hours, give the bot can_delete_messages, and catch both errors.
By Livops team, the people who build and run LivopsUpdated
The errors, as the Telegram Bot API returns them:
{"ok":false,"error_code":400,"description":"Bad Request: message can't be deleted"}
{"ok":false,"error_code":400,"description":"Bad Request: message can't be deleted for everyone"}
{"ok":false,"error_code":400,"description":"Bad Request: message to delete not found"}
Each library wraps them in its own words:
| Library | What you see |
|---|---|
| aiogram 3 | TelegramBadRequest: Telegram server says - Bad Request: message can't be deleted[7][8] |
| python-telegram-bot | telegram.error.BadRequest: Message can't be deleted[9][10] |
| grammY | GrammyError: Call to 'deleteMessage' failed! (400: Bad Request: message can't be deleted)[11] |
| Telegraf | TelegramError: 400: Bad Request: message can't be deleted[13] |
message to delete not found appears the same way in each library.
This page explains what the three texts mean, lists the rules Telegram applies to a bot’s deletes, and shows how to delete inside them, how to catch the errors without hiding real bugs, and how to delete in batches with deleteMessages — in aiogram, python-telegram-bot, grammY and Telegraf. It ends with keeping scheduled deletes across a deploy on Livops.
What do the errors mean?
message to delete not found— the Bot API server looks the message up before it deletes it. Ifmessage_idis missing or zero, if the bot has no access to the chat’s messages, or if there is no such message, it answers with this text[5]. There is nothing to delete.message can't be deleted— the message was found, but the bot may not delete it. TDLib checks this before the request leaves[6]; when Telegram’s own servers refuse instead, withMESSAGE_DELETE_FORBIDDEN, the Bot API server turns that into the same text[5]. Telegram describes that code as “most likely because it is a service message”[3][4].message can't be deleted for everyone— the same refusal for a private chat or a basic group. A bot’s delete always removes the message for everyone[5], and TDLib answers with this text when it can’t[6].
All three are 400s. Telegram says the numeric error_code may change in the future[1], so match on the description.
Which messages can a bot delete?
The deleteMessage documentation lists the limits[1]:
- A message can only be deleted if it was sent less than 48 hours ago.
- Service messages about a supergroup, channel, or forum topic creation can’t be deleted.
- A dice message in a private chat can only be deleted if it was sent more than 24 hours ago.
- Bots can delete outgoing messages in private chats, groups, and supergroups.
- Bots can delete incoming messages in private chats.
- Bots granted
can_post_messagespermissions can delete outgoing messages in channels. - If the bot is an administrator of a group, it can delete any message there.
- If the bot has the
can_delete_messagesadministrator right in a supergroup or a channel, it can delete any message there. - If the bot has the
can_manage_direct_messagesadministrator right in a channel, it can delete any message in the corresponding direct messages chat.
can_delete_messages is the administrator right to delete messages of other users[1].
Message can’t be deleted: causes
1. The message is older than 48 hours
The most common one, and no right lifts it[1]. In TDLib’s check, a bot can’t delete a supergroup or channel message older than two days, which gives message can't be deleted; in a private chat or a basic group the limit comes through the delete-for-everyone rule, which in TDLib’s code is two days by default for bots (the server can set it), which gives message can't be deleted for everyone[6].
A cleanup job that runs once a day, or a bot that was down for two days, hits this for everything it missed.
2. Someone else’s message, without the right
In a supergroup, the bot can delete another user’s message only with can_delete_messages; in a basic group, only as an administrator[1]. Without it you get message can't be deleted in a supergroup and message can't be deleted for everyone in a basic group[6]. Promote the bot with the right to delete messages. To check what it has now, call getChatMember with the bot’s own id.
3. A channel post without can_post_messages
In a channel, the bot deletes its own posts only if it was granted can_post_messages[1].
4. A service message that can’t go
The service messages about creating the supergroup, channel or forum topic can’t be deleted[1]. A dice in a private chat is the reverse: it can be deleted only after 24 hours[1].
Message to delete not found: causes
1. It was already deleted
The usual case. The user deleted their message first, an administrator removed it, or your own code deleted it twice — two handlers on the same update, or a cleanup task retrying after a timeout. The message you wanted gone is gone, so this is safe to treat as success.
2. The ids belong to different messages
message_id is unique only inside its chat[1]. Take chat_id and message_id from the same message — the one a send method returned, or the one an update carries. More on mismatched pairs in message to edit not found, which comes from the same lookup[5].
3. message_id is missing or zero
The Bot API server reads a message_id that is missing or not positive as no message at all[5]. Check for None, undefined or 0 coming from a database row.
4. The bot left the supergroup
In a supergroup the server checks that the bot is still a member before it looks at the message[5]. If it was removed, sends there fail too: see bot was kicked from the group chat.
Catch the errors safely
Treat not found as done, log can't be deleted and move on, and raise everything else. Do not retry either one: the same request gets the same answer.
aiogram 3. A 400 from Telegram is TelegramBadRequest, with Telegram’s description in message[7][8]:
import logging
from aiogram import Bot
from aiogram.exceptions import TelegramBadRequest
async def safe_delete(bot: Bot, chat_id: int, message_id: int) -> bool:
try:
return await bot.delete_message(chat_id, message_id)
except TelegramBadRequest as e:
if "message to delete not found" in e.message:
return False # already gone
if "message can't be deleted" in e.message: # also matches "... for everyone"
logging.warning("can't delete %s/%s: %s", chat_id, message_id, e.message)
return False
raise
python-telegram-bot. A 400 is BadRequest; the library removes Bad Request: and capitalizes the rest, so compare in lower case[9][10]:
import logging
from telegram.error import BadRequest
async def safe_delete(bot, chat_id: int, message_id: int) -> bool:
try:
return await bot.delete_message(chat_id, message_id)
except BadRequest as e:
text = e.message.lower()
if "message to delete not found" in text:
return False
if "message can't be deleted" in text:
logging.warning("can't delete %s/%s: %s", chat_id, message_id, e.message)
return False
raise
grammY. API errors are GrammyError, with Telegram’s description[11][12]:
import { GrammyError } from "grammy";
const IGNORED = /message to delete not found|message can't be deleted/;
async function safeDelete(chatId: number, messageId: number): Promise<boolean> {
try {
return await bot.api.deleteMessage(chatId, messageId);
} catch (e) {
if (e instanceof GrammyError && IGNORED.test(e.description)) return false;
throw e;
}
}
Telegraf. API errors are TelegramError, with a description getter[13][14]:
import { TelegramError } from "telegraf";
const IGNORED = /message to delete not found|message can't be deleted/;
async function safeDelete(chatId: number, messageId: number): Promise<boolean> {
try {
return await bot.telegram.deleteMessage(chatId, messageId);
} catch (e) {
if (e instanceof TelegramError && IGNORED.test(e.description)) return false;
throw e;
}
}
Deleting many messages: deleteMessages
deleteMessages deletes several messages in one request: 1-100 ids, with the same limits as deleteMessage, and ids that can’t be found are skipped[1]. It came with Bot API 7.0[2]. aiogram has bot.delete_messages, python-telegram-bot bot.delete_messages, grammY bot.api.deleteMessages and Telegraf bot.telegram.deleteMessages[12][14].
Two details from the server’s code:
- Missing ids are not an error. The Bot API server looks the ids up and drops those it can’t find[5], so
deleteMessageswith ids that are already gone should still returnTrue. The membership check still applies: a bot that is no longer in the supergroup getsmessage to delete not found[5]. - One refused message can fail the whole request. In TDLib’s code, it checks every message first and returns
message can't be deleted(or... for everyone) for the request if any one of them can’t be deleted[6]. Fall back to one at a time for that batch.
# aiogram 3
async def delete_many(bot: Bot, chat_id: int, message_ids: list[int]) -> None:
for i in range(0, len(message_ids), 100):
batch = message_ids[i : i + 100]
try:
await bot.delete_messages(chat_id, batch)
except TelegramBadRequest as e:
if "message can't be deleted" not in e.message:
raise
for message_id in batch: # find the ones that can go
await safe_delete(bot, chat_id, message_id)
The fallback can send up to 100 requests in a row; if Telegram answers with a 429, wait as it asks — see Telegram 429: Too Many Requests.
Delete inside the 48 hours
If your bot cleans up after itself — a “Processing…” message, a captcha, a reminder — delete it while it is young, and keep the plan somewhere that outlives the process. A timer in memory dies with the process, and a message whose delete was due before a restart may be past 48 hours by the time anyone notices.
Store chat_id, message_id and the time to delete in a table, and let a loop delete what is due:
import asyncio
import os
import sqlite3
import time
db = sqlite3.connect(os.path.join(os.environ.get("DATA_DIR", "."), "deletes.db"))
db.execute("CREATE TABLE IF NOT EXISTS deletes (chat_id INTEGER, message_id INTEGER, due INTEGER)")
def delete_later(chat_id: int, message_id: int, seconds: int) -> None:
db.execute("INSERT INTO deletes VALUES (?, ?, ?)", (chat_id, message_id, int(time.time()) + seconds))
db.commit()
async def delete_loop(bot) -> None:
while True:
now = int(time.time())
for chat_id, message_id in db.execute("SELECT chat_id, message_id FROM deletes WHERE due <= ?", (now,)).fetchall():
await safe_delete(bot, chat_id, message_id)
db.execute("DELETE FROM deletes WHERE chat_id = ? AND message_id = ?", (chat_id, message_id))
db.commit()
await asyncio.sleep(10)
Start delete_loop with asyncio.create_task(delete_loop(bot)) next to your polling. Because safe_delete treats not found and can't be deleted as done, a row never loops forever.
On Livops
These errors happen while the bot runs, when it deletes a message; a deploy does not delete anything, so it can be green while a delete fails.
- Logs. The warning lines from
safe_deleteand any uncaught error are on the project’s Logs page, andlivops logs <service> -ffollows them from the terminal; see CLI. Over MCP,get_logsreturns up to 5000 lines. - Scheduled deletes survive a deploy. A bot’s old version is stopped before the new one starts (see The app did not start), so timers held in memory are lost on every deploy. The project’s disk at
/app/datais kept across deploys and restarts, and its path is inDATA_DIR, which is why the example builds the SQLite path from it; see Files and data. If a separate worker does the deleting, keep the table in PostgreSQL instead: add one under Databases, andDATABASE_URLis written into every service in the environment, including ones added later. - Ship the fix with a push. Every
git pushto the project’s branch starts a new deploy; push the fix, and the new version replaces the old one.
A bot costs 19 credits a month (19,000 so’m); see Pricing.
Questions
Why does deleteMessage say message can't be deleted?
Telegram found the message but your bot may not delete it. The usual reasons: it was sent more than 48 hours ago, it is another user's message in a supergroup and the bot has no can_delete_messages right, or it is a service message about creating the group, channel or topic.
Can a bot delete messages older than 48 hours?
No. The Bot API documents that a message can only be deleted if it was sent less than 48 hours ago, and no admin right lifts that. If a message must go later, delete it before the 48 hours are up, or edit it instead.
Can a bot delete other users' messages in a group?
Yes, with the right rights. In a basic group the bot must be an administrator. In a supergroup or channel it needs the can_delete_messages administrator right. In a private chat it can delete the user's messages without any right.
Is it safe to ignore message to delete not found?
Usually yes. The message you wanted gone is already gone, often because a user or another handler deleted it first. Log it at a low level so a wrong chat_id and message_id pair still shows up in the logs.
What does message can't be deleted for everyone mean?
It is the same refusal from a private chat or a basic group. A bot always deletes for everyone, so when the message is too old, or in a basic group it is another user's message and the bot is not an administrator, the Bot API answers with this text.
How do I delete many messages at once?
Use deleteMessages with 1 to 100 message ids. Ids that can't be found are skipped. But in TDLib's code one message that can't be deleted can fail the whole request, so fall back to deleting that batch one message at a time.
Sources
- Telegram Bot API — Making requests, deleteMessage, deleteMessages, ChatAdministratorRights (core.telegram.org). Checked .
- Telegram Bot API — Changelog (Bot API 7.0) (core.telegram.org). Checked .
- Telegram API — error database (errors.json) (core.telegram.org). Checked .
- Telegram API — messages.deleteMessages (core.telegram.org). Checked .
- Telegram Bot API server source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
- TDLib source — td/telegram/MessagesManager.cpp (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
- aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
- python-telegram-bot source — telegram/error.py (raw.githubusercontent.com). Checked .
- python-telegram-bot source — telegram/request/_baserequest.py (raw.githubusercontent.com). Checked .
- grammY source — src/core/error.ts (raw.githubusercontent.com). Checked .
- grammY source — src/core/api.ts (raw.githubusercontent.com). Checked .
- Telegraf source — src/core/network/error.ts (raw.githubusercontent.com). Checked .
- Telegraf source — src/telegram.ts (raw.githubusercontent.com). Checked .
Put your project online today
Connect GitHub or drop a folder. No card is asked for.
Deploy your botRelated
- Bad Request: message to edit not found / message can't be edited — Telegram bot error and how to fix itBad Request: message to edit not found means Telegram has no message with that message_id in that chat for your bot: the pair is wrong, the message was deleted, or the bot left the group. Bad Request: message can't be edited means the message exists but the bot may not edit it, usually because the bot did not send it. Edit only messages the bot sent, take both ids from the same message, and use inline_message_id for inline messages.
- Telegram 400: Bad Request: not enough rights to send text messages to the chat — how to fix itBad Request: not enough rights to send text messages to the chat means the bot is in the group, but its permissions there do not allow this kind of message: the group's default permissions turn sending off for members, or the bot itself was restricted. Make the bot an administrator, or turn the permission back on; check with getChatMember for the bot's own id. In a channel the bot needs to be an administrator that can post.
- Telegram 400: Bad Request: chat not found — how to fix itThe bot asked Telegram for a chat it does not know. Either the chat_id is wrong (a typo, a channel id without its -100 prefix, a user's @username, an id cut to 32 bits), or it is right but this bot has never been in that chat: the user never pressed Start, the bot was never added to the group or channel, or the token belongs to a different bot.
- Telegram 403: Forbidden: bot was kicked from the group chat — how to handle itSomeone removed the bot from that group, supergroup or channel, and Telegram refuses every message it sends there. Nothing is broken and a retry will not help: mark the chat inactive in your database, skip it in broadcasts, and mark it active again when the bot is added back. The my_chat_member update tells you the moment it happens.
- Telegram 429: Too Many Requests, flood control: retry after N — how to fix itTelegram flood control (429 Too Many Requests) is telling your bot to slow down: wait the number of seconds in retry_after, then send the same request again. It comes from sending too fast — more than about one message a second to one chat, 20 a minute to a group, or about 30 a second in a broadcast. Wait and retry in code, and send broadcasts from one queue at a steady pace.
- Telegram bot hosting in 2026: the options comparedA Telegram bot needs a process that never stops, or a public HTTPS address for a webhook. On Livops it runs from a GitHub push for 19 credits a month (19,000 so'm). Here is how a VPS, Railway, Render, Fly.io and Vercel compare.
- aiogram bot hosting: how to deploy an aiogram 3 botAn aiogram 3 bot needs one process that never stops, the token in an environment variable, state kept outside memory and a clean exit on SIGTERM. On Livops you push a repository with bot.py and requirements.txt, and it runs for 19 credits a month (19,000 so'm), polling or webhook.
- python-telegram-bot hosting: deploying a v22 botA python-telegram-bot bot runs as one Application: run_polling() for polling, run_webhook() with the webhooks extra for a webhook. Both stop cleanly on SIGTERM. On Livops it runs from a push with bot.py and requirements.txt for 19 credits a month (19,000 so'm).
- grammY bot deploy: polling, webhooks and hostingDeploy a grammY bot as one always-on Node.js process: bot.start() for polling, or webhookCallback() behind an HTTP server, with bot.stop() on SIGTERM. On Livops a repository with grammy in package.json runs as a bot from every push, for 19 credits a month (19,000 so'm).
- Telegraf bot hosting: deploying a Telegraf 4 bot on Node.jsA Telegraf bot is one Node.js process: bot.launch() for polling, or bot.webhookCallback() behind an HTTP server for a webhook, with bot.stop() on SIGTERM. On Livops a repository with telegraf in package.json is run as a bot from every push, for 19 credits a month (19,000 so'm).
- Bad Request: message to be replied not found — Telegram bot error and how to fix itBad Request: message to be replied not found means Telegram could not find the message your bot tried to reply to, so nothing was sent: it was deleted, its message_id belongs to another chat or forum topic, or the bot cannot see that chat. Pass reply_parameters with allow_sending_without_reply set to true to send the message anyway, take the message_id from the same chat, and catch the error where the reply is optional.