Skip to content

editMessageText ​

Edit the text content of a previously sent message.

Request ​

POST /:token/editMessageText

Parameters ​

ParameterTypeRequiredDescription
chat_idInteger/StringYesUnique identifier or username of the target chat
message_idIntegerYesID of the message to edit
textStringYesNew text content of the message
parse_modeStringNoText parsing mode, supports HTML or Markdown
reply_markupObjectNoNew inline keyboard markup, JSON-serialized object

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": 1700000060,
    "text": "Updated message content"
  }
}

Error Codes ​

CodeDescription
400Bad request parameters, e.g. message content is unchanged or required parameters are missing
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 ​

cURL ​

bash
curl -X POST "https://api.example.com/<token>/editMessageText" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "message_id": 100,
    "text": "Updated message content",
    "parse_mode": "HTML"
  }'

Edit Message and Update Inline Keyboard ​

bash
curl -X POST "https://api.example.com/<token>/editMessageText" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": 987654321,
    "message_id": 100,
    "text": "Please choose again:",
    "reply_markup": {
      "inline_keyboard": [
        [
          {"text": "New Option A", "callback_data": "new_option_a"},
          {"text": "New Option B", "callback_data": "new_option_b"}
        ]
      ]
    }
  }'