Telegram Bot API · error code

Telegram error 400: Bad Request: message thread 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 thread not found

What error 400 means

You passed a message_thread_id that does not identify a usable topic in the target chat. The Bot API documents this parameter as the target message thread (topic) of a forum, for forum supergroups and private chats with topic mode only. When the chat is a forum, the server looks the topic up before sending and returns this description if the lookup fails.

Three situations produce it. The topic was deleted. The ID is not a topic ID at all, for example a regular message_id from the chat. Or you passed 1: in the Bot API server source, sending to a forum with message_thread_id equal to the General topic's ID is rejected with exactly this text, so messages for General should simply omit message_thread_id.

In a supergroup that is not a forum, the server does not check the value and sends to the main chat, which is why the same code can work in one group and fail in another. A topic that exists but is closed fails differently; see TOPIC_CLOSED.

What it looks like

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

Why it happens

  • The forum topic was deleted by an admin.
  • message_thread_id=1 was used to target the General topic in a forum.
  • A message_id was stored as if it were a topic ID.
  • The topic ID belongs to a different supergroup than the chat_id.

How to fix Telegram error 400

  1. 1Omit message_thread_id when posting to the General topic.
  2. 2Take the thread ID from message.message_thread_id of an update in that topic, or from the ForumTopic returned by createForumTopic.
  3. 3Store topic IDs together with their chat_id and drop them when you receive a topic deletion.
  4. 4If the topic is gone, recreate it with createForumTopic (requires can_manage_topics) and save the new ID.

How to stop it recurring

Keep a mapping of topic names to IDs per forum and refresh it from forum_topic_created service messages instead of hard-coding numbers. Default to the General topic by leaving message_thread_id out. Topic and chat constraints are collected under chats and topics limits.

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?

You passed a message_thread_id that does not identify a usable topic in the target chat. The Bot API documents this parameter as the target message thread (topic) of a forum, for forum supergroups and private chats with topic mode only. When the chat is a forum, the server looks the topic up before sending and returns this description if the lookup fails. Three situations produce it. The topic was deleted.

How do I fix Telegram error 400?

1. Omit message_thread_id when posting to the General topic. 2. Take the thread ID from message.message_thread_id of an update in that topic, or from the ForumTopic returned by createForumTopic . 3. Store topic IDs together with their chat_id and drop them when you receive a topic deletion. 4. If the topic is gone, recreate it with createForumTopic (requires can_manage_topics ) and save the new ID.

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.