Skip to content

editMessageReplyMarkup

Edit the reply markup (inline keyboard) of a previously sent message. Only modifies the keyboard; the message text content remains unchanged.

Request

POST /:token/editMessageReplyMarkup

Parameters

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
message_idIntegerYesID of the message to edit
reply_markupObjectNoNew inline keyboard markup, JSON-serialized object. Omitting this parameter or passing an empty object will remove the existing keyboard

Response

Returns the edited Message object on success.

json
{
  "ok": true,
  "result": {
    "message_id": 100,
    "from": {
      "id": 123456789,
      "is_bot": true,
      "first_name": "MyBot",
      "username": "my_bot"
    },
    "chat": {
      "id": 987654321,
      "first_name": "User",
      "username": "user123",
      "type": "private"
    },
    "date": 1700000000,
    "edit_date": 1700000120,
    "text": "Please choose an option:",
    "reply_markup": {
      "inline_keyboard": [
        [
          {"text": "New Option A", "callback_data": "new_a"},
          {"text": "New Option B", "callback_data": "new_b"}
        ]
      ]
    }
  }
}

Error Codes

CodeDescription
400Bad request parameters, e.g. invalid reply_markup format or keyboard is unchanged
401Invalid or expired token
403Bot does not have permission to edit this message (can only edit messages sent by the Bot itself)
404Message not found
500Internal server error

Examples

Update Inline Keyboard

bash
curl -X POST "https://api.example.com/<token>/editMessageReplyMarkup" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "message_id": 100,
    "reply_markup": {
      "inline_keyboard": [
        [
          {"text": "New Option A", "callback_data": "new_a"},
          {"text": "New Option B", "callback_data": "new_b"}
        ],
        [
          {"text": "Cancel", "callback_data": "cancel"}
        ]
      ]
    }
  }'

Remove Inline Keyboard

bash
curl -X POST "https://api.example.com/<token>/editMessageReplyMarkup" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "message_id": 100,
    "reply_markup": {}
  }'