Introducing Livops 2.0! Promo codeCEOgives you 8,000 so‘m on your balance.What’s new

Bad Request: message to edit not found / message can't be edited — Telegram bot error and how to fix it

Bad 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.

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 to edit not found"}
{"ok":false,"error_code":400,"description":"Bad Request: message can't be edited"}

Each library wraps them in its own words:

Library What you see
aiogram 3 TelegramBadRequest: Telegram server says - Bad Request: message to edit not found[4][5]
python-telegram-bot telegram.error.BadRequest: Message to edit not found[8][9]
grammY GrammyError: Call to 'editMessageText' failed! (400: Bad Request: message to edit not found)[11]
Telegraf TelegramError: 400: Bad Request: message to edit not found[13]

message can't be edited appears the same way in each library.

This page explains what the two errors mean and how they differ from message is not modified, lists the causes of each, and shows the fixes — the right pair of ids, the right method for the message, and inline_message_id for inline messages — in aiogram, python-telegram-bot, grammY and Telegraf. It ends with how to find the failing edit on Livops.

What do the errors mean?

editMessageText, editMessageCaption, editMessageMedia and editMessageReplyMarkup change a message that is already in the chat. Each one finds that message either by chat_id plus message_id, or by inline_message_id for a message sent in inline mode[1].

  • message to edit not found — the Bot API server looks the message up before it edits it. If message_id is 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[2]. Telegram cannot see the message at all.
  • message can't be edited — the message was found, but TDLib’s edit check says the bot may not change it[3]. The message is there; the bot just has no right to edit it.

A wrong chat_id fails earlier, with chat not found: the chat is checked before the message[2].

How they differ from message is not modified

Message is not modified means the edit reached a message the bot may edit, and the new text and keyboard are exactly what it already shows. It is harmless, and it is safe to catch and ignore. message to edit not found and message can't be edited mean the edit could not happen at all — the user does not see the new state. Ignoring them hides a bug.

Message to edit not found: causes, most common first

1. chat_id and message_id from different messages

message_id is unique only inside its chat[1]. Message 42 in one chat has nothing to do with message 42 in another. The usual mistakes:

  • the chat is taken from the user (from.id) but the message from a group — in a group they are different chats;
  • a stored message_id is saved without its chat_id, or with the wrong one;
  • the id of the user’s message (the /start they sent) is used instead of the id of the bot’s reply.

Take both ids from the same Message object: the one the send method returned, or the one the callback query carries.

2. The message was deleted

A user can delete a message in a private chat, and an administrator can delete one in a group; your own code may have deleted it too. The next edit finds nothing[2]. If the button that sent the callback is on a deleted or otherwise inaccessible message, the callback’s message is an InaccessibleMessage, whose date is always 0[1].

3. message_id is missing or zero

The Bot API server reads a message_id that is missing or not a positive number as “no message”, and answers message to edit not found[2]. Check for None, undefined or 0 coming from a database row or a lost variable. A sent message can also come back with message_id 0: an ephemeral message, or, in specific instances, a message the server scheduled instead of sending at once (for example a video sent to a big chat), which is unusable until it is actually sent[1].

4. The bot left the supergroup

In a supergroup the Bot API server checks that the bot is still a member before it looks at any message; if not, the edit fails as not found[2].

Message can’t be edited: causes

TDLib’s check lists when a message can’t be edited[3]. The ones bots run into:

1. The bot did not send the message

In a private chat or a group, a bot can edit only the messages it sent itself — not a user’s message, and not another bot’s[3]. In a channel, a bot that is an administrator with the right to edit messages can edit other posts too[3].

2. The message has a reply keyboard

Only messages without reply_markup, or with an inline keyboard, can be edited[1]. A message sent with a reply keyboard (the buttons under the input field) can’t be edited later.

3. The message was forwarded

A forwarded message can’t be edited[3], even when the bot forwarded it. Send a copy instead if you will need to edit it.

4. An inline message from another bot

A message sent in inline mode through a different bot can’t be edited by yours[3].

5. An old business message

For bots connected to a business account: business messages that were not sent by the bot and have no inline keyboard can be edited only within 48 hours from the time they were sent[1]. This is the only time limit the Bot API documents for editing. For messages the bot sent itself, TDLib’s edit check, which the Bot API server runs, sets no time limit[3].

A media message edited as text

Editing the text of a photo, video or document message gives a third error:

{"ok":false,"error_code":400,"description":"Bad Request: there is no text in the message to edit"}

editMessageText edits text, rich and game messages[1]; TDLib refuses any other kind[3]. A photo has a caption, not text: use editMessageCaption, whose caption is 0-1024 characters[1]. To change the file itself, use editMessageMedia, which can also replace a text message with media[1]. The reverse mistake — editMessageCaption on a text message — gives there is no caption in the message to edit[3].

Inline messages: inline_message_id, not chat_id

A message sent through your bot in inline mode is sent by the user, not by the bot. The callback query’s message field is for messages the bot sent; a button on an inline message sends inline_message_id instead[1]. Edit it with inline_message_id, which is required when chat_id and message_id are not given[1]. With neither, the Bot API server answers message identifier is not specified[2].

Since Bot API 10.5 (November 2026), the same can happen with the bot’s own messages: the callback_query_mode parameter of setMySettings can tell Telegram to send inline_message_id instead of message always (“inline”), or when the message is inaccessible to the bot (“auto”)[1]. If you turned that on, edit by inline_message_id.

How to fix it

Take the ids from the same message

Edit the message the send method returned, or the one the callback carries — never a chat_id from one place and a message_id from another. If you store a message to edit later, store both ids together.

# aiogram 3: keep the pair that send_message returned
sent = await bot.send_message(chat_id, "Working…")
await db.save_progress(chat_id=sent.chat.id, message_id=sent.message_id)

Check the callback before you edit

In a callback handler, the message can be missing (an inline message) or inaccessible (deleted).

aiogram 3. callback.message is optional and may be an InaccessibleMessage; for an inline message, use callback.inline_message_id[6][7]:

from aiogram.types import CallbackQuery, Message

async def on_button(callback: CallbackQuery, bot):
    await callback.answer()
    if isinstance(callback.message, Message):
        await callback.message.edit_text(text, reply_markup=kb)
    elif callback.inline_message_id:
        await bot.edit_message_text(text=text, inline_message_id=callback.inline_message_id, reply_markup=kb)
    # otherwise the message is gone: send a new one if the user still needs it

python-telegram-bot. query.edit_message_text uses inline_message_id when the callback has one, and raises TypeError if the message is inaccessible[10]:

async def on_button(update, context):
    query = update.callback_query
    await query.answer()
    await query.edit_message_text(text, reply_markup=kb)

grammY. ctx.editMessageText edits by inline_message_id when the update has one, and by chat and message id otherwise[12]:

bot.on("callback_query:data", async (ctx) => {
  await ctx.answerCallbackQuery();
  await ctx.editMessageText(text, { reply_markup: kb });
});

Telegraf. ctx.editMessageText passes the chat, the message id and the inline message id it has[14]:

bot.on("callback_query", async (ctx) => {
  await ctx.answerCbQuery();
  await ctx.editMessageText(text, { reply_markup: kb });
});

Use the method that fits the message

editMessageText for text, editMessageCaption for a photo, video or document’s caption, editMessageMedia for the file, editMessageReplyMarkup for the keyboard alone[1]. When one handler edits both kinds, check whether the message has text or a caption first.

When the message is gone, send a new one

A deleted message cannot be brought back. Catch these two errors, send a fresh message, and store its ids in place of the old ones. Raise everything else.

aiogram 3. Telegram’s 400 is TelegramBadRequest, with Telegram’s description in message[4][5]:

from aiogram.exceptions import TelegramBadRequest

GONE = ("message to edit not found", "message can't be edited")

try:
    await bot.edit_message_text(text=text, chat_id=chat_id, message_id=message_id)
except TelegramBadRequest as e:
    if not any(s in e.message for s in GONE):
        raise
    sent = await bot.send_message(chat_id, text)
    message_id = sent.message_id  # save the new id

python-telegram-bot. Telegram’s 400 is BadRequest; the library removes Bad Request: and capitalizes the rest, so compare in lower case[8][9]:

from telegram.error import BadRequest

try:
    await context.bot.edit_message_text(text, chat_id=chat_id, message_id=message_id)
except BadRequest as e:
    if not any(s in e.message.lower() for s in ("message to edit not found", "message can't be edited")):
        raise
    sent = await context.bot.send_message(chat_id, text)

grammY. API errors are GrammyError, with Telegram’s description[11]:

import { GrammyError } from "grammy";

try {
  await bot.api.editMessageText(chatId, messageId, text);
} catch (e) {
  const gone = e instanceof GrammyError &&
    /message to edit not found|message can't be edited/.test(e.description);
  if (!gone) throw e;
  const sent = await bot.api.sendMessage(chatId, text);
}

Telegraf. API errors are TelegramError, with a description getter[13]:

import { TelegramError } from "telegraf";

try {
  await bot.telegram.editMessageText(chatId, messageId, undefined, text);
} catch (e) {
  const gone = e instanceof TelegramError &&
    /message to edit not found|message can't be edited/.test(e.description);
  if (!gone) throw e;
  const sent = await bot.telegram.sendMessage(chatId, text);
}

On Livops

These errors happen while the bot runs, when it edits a message; a deploy does not press your buttons, so it can be green while an edit fails.

  • Logs. The error line is on the project’s Logs page, and livops logs <service> -f follows it from the terminal; see CLI. Log the chat_id and message_id you tried to edit next to it, so you can tell a wrong pair from a deleted message. Over MCP, get_logs returns up to 5000 lines.
  • If it stops the bot right after a deploy. If an uncaught error stops the bot right after it starts — for example, editing a stored status message that has since been deleted — the deploy fails as start_failed, with the bot’s last words on the Logs page. A bot’s old version is stopped before the new one starts, so the bot is down until a deploy succeeds. See The app did not start.
  • Ship the fix with a push. Every git push to 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

What does message to edit not found mean?

Telegram could not find a message with that message_id in that chat for your bot. The message_id is missing or belongs to another chat, the message was deleted, or the bot is no longer a member of the supergroup. Nothing was edited.

What is the difference between message to edit not found and message can't be edited?

Not found means Telegram cannot see the message at all. Can't be edited means the message is there, but the bot may not change it: usually because a user or another bot sent it, it was forwarded, or it has a reply keyboard instead of an inline one.

How is it different from message is not modified?

Message is not modified means the edit reached a message the bot may edit, but the new text and keyboard are exactly what it already shows. It is harmless and can be ignored. Not found and can't be edited mean the edit could not happen at all, so ignoring them hides a real bug.

Can a bot edit messages sent by users?

No. In a private chat or a group a bot can edit only the messages it sent itself. The exception is a channel, where a bot that is an administrator with the right to edit messages can edit other posts.

Is there a time limit for a bot to edit its own messages?

The Bot API documents a 48 hour limit only for business messages that the bot did not send and that have no inline keyboard. The Bot API server's own check sets no time limit for messages the bot sent itself.

Why does editing a photo message fail with editMessageText?

editMessageText changes the text of a text message. A photo, video or document has a caption instead, so the Bot API answers there is no text in the message to edit. Use editMessageCaption for the caption, or editMessageMedia to replace the file.

How do I edit a message sent in inline mode?

Pass inline_message_id instead of chat_id and message_id. The callback query from a button on such a message carries inline_message_id instead of a message. grammY, Telegraf and python-telegram-bot use it on their own when you call the edit shortcut on the callback.

Sources

  1. Telegram Bot API — Making requests, Updating messages, editMessageText, editMessageCaption, editMessageMedia, CallbackQuery, InaccessibleMessage, setMySettings (core.telegram.org). Checked .
  2. Telegram Bot API server source — telegram-bot-api/Client.cpp (raw.githubusercontent.com). Checked .
  3. TDLib source — td/telegram/MessagesManager.cpp (raw.githubusercontent.com). Checked .
  4. aiogram source — aiogram/exceptions.py (raw.githubusercontent.com). Checked .
  5. aiogram source — aiogram/client/session/base.py (raw.githubusercontent.com). Checked .
  6. aiogram source — aiogram/types/callback_query.py (raw.githubusercontent.com). Checked .
  7. aiogram source — aiogram/types/inaccessible_message.py (raw.githubusercontent.com). Checked .
  8. python-telegram-bot source — telegram/error.py (raw.githubusercontent.com). Checked .
  9. python-telegram-bot source — telegram/request/_baserequest.py (raw.githubusercontent.com). Checked .
  10. python-telegram-bot source — telegram/_callbackquery.py (raw.githubusercontent.com). Checked .
  11. grammY source — src/core/error.ts (raw.githubusercontent.com). Checked .
  12. grammY source — src/context.ts (raw.githubusercontent.com). Checked .
  13. Telegraf source — src/core/network/error.ts (raw.githubusercontent.com). Checked .
  14. Telegraf source — src/context.ts (raw.githubusercontent.com). Checked .

Put your project online today

Connect GitHub or drop a folder. No card is asked for.

Deploy your bot

Got a question? — @livops_uz