Telegram · 400

Telegram: message to edit not found

Your bot tried to change a message that is no longer there to change — deleted, too old, or never yours in the first place. A close cousin, "message is not modified", means the edit changed nothing at all.

← All errors

What you are seeing

Bot API

Bad Request: message to edit not found

Bot API

Bad Request: message can't be edited

Bot API

Bad Request: message is not modified

What each message means

"Message to edit not found": the message was deleted, or the chat or message ID is wrong — the message has to be in the chat you ask about. A stored message ID from a chat the bot has since left gives this too.

"Message can't be edited": the message is more than 48 hours old, which is Telegram's limit for edits, or it is not one of the bot's own messages. A bot can only edit what it sent; a user's message, or a service message like "user joined", cannot be edited at all.

"Message is not modified": the edit asked for exactly what is already there — the same text and the same keyboard. A loop that edits a progress message on every tick trips this as soon as a tick changes nothing.

Edit only when something changed

Keep the text and keyboard you last sent, and only call edit when the new ones differ. When an edit does fail, treat each reason differently: "not modified" is safe to ignore; "not found" or "can't be edited" means sending a fresh message instead.

python-telegram-bot

from telegram.error import BadRequest

try:
    await message.edit_text(new_text, reply_markup=new_keyboard)
except BadRequest as error:
    if "message is not modified" in str(error):
        pass  # Nothing changed; nothing to do.
    elif "message to edit not found" in str(error) or "can't be edited" in str(error):
        await context.bot.send_message(chat_id, new_text, reply_markup=new_keyboard)
    else:
        raise

grammY

const { GrammyError } = require('grammy');

try {
    await ctx.editMessageText(newText, { reply_markup: newKeyboard });
} catch (error) {
    if (error instanceof GrammyError && error.description.includes('message is not modified')) {
        // Nothing changed; nothing to do.
    } else if (error instanceof GrammyError && error.description.includes('message to edit not found')) {
        await ctx.reply(newText, { reply_markup: newKeyboard });
    } else {
        throw error;
    }
}

FAQ

Questions

How old is too old to edit?

48 hours after the message was sent. After that, send a new message; the old one stays as it is.

Can a bot edit a user's message?

No — only its own. If your bot needs to change what a user sees, it edits its own reply to them.

Why does it happen every few seconds?

A loop is editing with the same text on every tick. Only edit when the text or keyboard actually changed, and ignore "message is not modified" when it slips through.

Read next