Telegram Bot API · error code

Telegram error 400: Bad Request: message to edit not found

Permanent - do not retryHTTP 400400 Bad Request: identifiers, content and rights

Last verified against Telegram Bot API reference

What Telegram returns
Bad Request: message to edit not found

What error 400 means

One of the edit methods (editMessageText, editMessageCaption, editMessageMedia, editMessageReplyMarkup, editMessageLiveLocation) was given a chat_id and message_id pair that the bot cannot load. The Bot API server builds this description from the phrase "message to edit" plus "not found", so the wording tells you exactly which lookup failed: the target message, not the chat and not your new content.

The chat itself resolved, otherwise you would see chat not found or a 403 membership error first. What did not resolve is the message inside it. It was deleted (by a user, an admin, or your own cleanup job), the ID belongs to a different chat, or the value is zero or negative because a variable was never filled.

Callback-driven bots hit this most. A user taps a button on an old menu, the handler edits callback_query.message, but that message was removed minutes earlier. When the message is an inline-mode result, there is no chat-scoped ID at all; you must edit it with inline_message_id, and passing a chat-based pair instead fails here.

What it looks like

{"ok":false,"error_code":400,"description":"Bad Request: message to edit not found"}

Why it happens

  • The message was deleted before the edit ran, often by an admin, an auto-delete timer, or a concurrent handler.
  • A stored message_id is paired with the wrong chat_id, for example after a group migrated to a supergroup.
  • The message_id is 0, null or a stringified placeholder because the original send call failed and its result was not checked.
  • The message came from inline mode, so it must be edited through inline_message_id rather than chat_id plus message_id.

How to fix Telegram error 400

  1. 1Log the chat_id and message_id actually sent and compare them with the message object in the triggering update.
  2. 2For callback queries, take both values from callback_query.message; for inline results use callback_query.inline_message_id.
  3. 3Check that the initial send succeeded and that you stored the ID from its result, not from the incoming user message.
  4. 4Catch this description and fall back to sending a fresh message, then store the new message_id for later edits.
  5. 5If the chat was upgraded, rewrite stored IDs using migrate_to_chat_id before retrying.

How to stop it recurring

Treat stored message IDs as perishable. Keep them next to their chat_id, expire old menus, and design edit handlers so a missing target degrades into a new send rather than a crash. Answer the callback query either way so the user's spinner stops. For edit windows, see the editing rules.

Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.

Related codes

Error 400 - quick answers

What does Telegram error 400 mean?

One of the edit methods ( editMessageText , editMessageCaption , editMessageMedia , editMessageReplyMarkup , editMessageLiveLocation ) was given a chat_id and message_id pair that the bot cannot load. The Bot API server builds this description from the phrase "message to edit" plus "not found", so the wording tells you exactly which lookup failed: the target message, not the chat and not your new content.

How do I fix Telegram error 400?

1. Log the chat_id and message_id actually sent and compare them with the message object in the triggering update. 2. For callback queries, take both values from callback_query.message ; for inline results use callback_query.inline_message_id . 3. Check that the initial send succeeded and that you stored the ID from its result, not from the incoming user message. 4. Catch this description and fall back to sending a fresh message, then store the new message_id for later…

Should I retry after error 400?

No. Retrying the same request produces the same error; the condition has to be fixed first. Treat it as a permanent failure for that message and surface it, rather than looping.

Stop debugging Telegram by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.