Telegram Bot API · error code

Telegram error 400: Bad Request: can't restrict self

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

Last verified against Telegram Bot API reference

What Telegram returns
Bad Request: can't restrict self

What error 400 means

The bot passed its own user ID as user_id to restrictChatMember or banChatMember. TDLib refuses to apply a restriction or ban to the account making the request and returns this sentence before anything reaches Telegram's servers.

Nobody writes this intentionally. It is a bug in how the target is chosen: the handler reads message.from on a message the bot itself sent, picks the wrong participant out of a chat_member update (the bot instead of the affected user), or uses getMe().id as a default. Replies are a common trap: moderating "the replied-to user" goes wrong when an admin replies to one of the bot's own messages.

The bot's rights and the chat are fine. The same call aimed at the correct user would most likely succeed. If you actually want the bot out of the chat, the documented method is leaveChat.

What it looks like

{"ok":false,"error_code":400,"description":"Bad Request: can't restrict self"}

Why it happens

  • The target user ID was read from a message the bot sent itself.
  • In a chat_member update, the bot's ID was taken from the wrong field.
  • A moderation command was used as a reply to one of the bot's messages.
  • A default or fallback user ID was set to the bot's own ID.

How to fix Telegram error 400

  1. 1Compare the target ID with your bot ID from getMe and skip the call when they match.
  2. 2For reply-based commands, use reply_to_message.from.id and reject replies to the bot.
  3. 3In chat_member updates, read the affected user from new_chat_member.user.
  4. 4Use leaveChat if the goal is to remove the bot from the chat.

How to stop it recurring

Add a guard in your moderation layer that rejects the bot's own ID and other admins before calling Telegram. Cache the bot ID at startup and log the resolved target with every moderation action so mistakes in target selection are visible during testing.

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?

The bot passed its own user ID as user_id to restrictChatMember or banChatMember . TDLib refuses to apply a restriction or ban to the account making the request and returns this sentence before anything reaches Telegram's servers. Nobody writes this intentionally.

How do I fix Telegram error 400?

1. Compare the target ID with your bot ID from getMe and skip the call when they match. 2. For reply-based commands, use reply_to_message.from.id and reject replies to the bot. 3. In chat_member updates, read the affected user from new_chat_member.user . 4. Use leaveChat if the goal is to remove the bot from the chat.

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.