editMessageText
Edit the text content of a previously sent message.
Request
POST /:token/editMessageText
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| chat_id | Integer/String | Yes | Unique identifier or username of the target chat |
| message_id | Integer | Yes | ID of the message to edit |
| text | String | Yes | New text content of the message |
| parse_mode | String | No | Text parsing mode, supports HTML or Markdown |
| reply_markup | Object | No | New 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
| Code | Description |
|---|---|
| 400 | Bad request parameters, e.g. message content is unchanged or required parameters are missing |
| 401 | Invalid or expired token |
| 403 | Bot does not have permission to edit this message (can only edit messages sent by the Bot itself) |
| 404 | Message not found |
| 500 | Internal 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"}
]
]
}
}'