Telegram Bot API · error code

Telegram error 400: Bad Request: inline keyboard expected

ConfigurationHTTP 400400 Bad Request: identifiers, content and rights

Last verified against Telegram Bot API reference

What Telegram returns
Bad Request: inline keyboard expected

What error 400 means

A method that only accepts an InlineKeyboardMarkup received a different kind of reply markup, such as a ReplyKeyboardMarkup, ReplyKeyboardRemove or ForceReply. The check lives in TDLib, the library behind the Bot API server, which returns "Inline keyboard expected" whenever a context permits inline keyboards only.

The edit methods are the classic case. The docs for editMessageReplyMarkup, editMessageText and the other edit methods type reply_markup as InlineKeyboardMarkup: a message's custom reply keyboard cannot be changed by editing. Inline query results, messages sent on behalf of inline mode, and channel posts likewise take inline keyboards only.

Usually the bug is a shared helper that builds "the keyboard" for both a new message and an edit. The JSON has a top-level keyboard field (reply keyboard) where the edit needs inline_keyboard. Nothing about the message or chat is wrong.

What it looks like

{"ok":false,"error_code":400,"description":"Bad Request: inline keyboard expected"}

Why it happens

  • An edit method was given JSON with keyboard rows instead of inline_keyboard rows.
  • remove_keyboard or force_reply was passed to an edit call to hide a reply keyboard.
  • An inline query result or a channel post was given a reply keyboard.
  • A keyboard builder returned the wrong markup class for the context it was used in.

How to fix Telegram error 400

  1. 1Send {"inline_keyboard": [[...]]} to edit methods.
  2. 2To remove or replace a custom reply keyboard, send a new message with ReplyKeyboardRemove or a new ReplyKeyboardMarkup.
  3. 3To strip an inline keyboard from a message, call editMessageReplyMarkup with an empty inline keyboard or no reply_markup.
  4. 4Split keyboard helpers by type so edits can only produce inline markup.

How to stop it recurring

Model reply keyboards and inline keyboards as separate types in your code, and type edit functions to accept only the inline one. The keyboard builder outputs both shapes so you can see the field difference, and keyboard limits lists the related constraints.

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?

A method that only accepts an InlineKeyboardMarkup received a different kind of reply markup, such as a ReplyKeyboardMarkup , ReplyKeyboardRemove or ForceReply . The check lives in TDLib, the library behind the Bot API server, which returns "Inline keyboard expected" whenever a context permits inline keyboards only. The edit methods are the classic case.

How do I fix Telegram error 400?

1. Send {"inline_keyboard": [[...]]} to edit methods. 2. To remove or replace a custom reply keyboard, send a new message with ReplyKeyboardRemove or a new ReplyKeyboardMarkup . 3. To strip an inline keyboard from a message, call editMessageReplyMarkup with an empty inline keyboard or no reply_markup. 4. Split keyboard helpers by type so edits can only produce inline markup.

Stop debugging Telegram by hand

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