Quick summary
Answer each
callback_query.idonce to stop the button’s loading indicator.Callback delivery lasts at most 150 seconds. The answer window is 300 seconds from the callback.
Send the full button or caption value when a compound edit must preserve it.
Handle button callbacks and edit messages
Receive and answer the callback
Subscribe to
callback_query, alongside the other event types you need. Omittingallowed_updateskeeps the stored policy. An empty array resets to defaults.Deduplicate retried updates by
update_id. Check the actor and the current business state before applying changes. Each press has a distinct callback ID.Call
answerCallbackQuerypromptly. Only the first accepted answer for the same ID succeeds. Repeated, in-flight, expired, and invalid IDs return400.
curl -X POST "https://call.mp.net/bot/answerCallbackQuery" \
-H "Authorization: Bearer $MPCHAT_BOT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"callback_query_id":"REPLACE_WITH_CALLBACK_ID"}'
The server accepts text and show_alert for compatibility. Clients currently display neither a toast nor an alert. To report an outcome, edit or send a message. copy_text copies locally and produces no callback.
Choose the edit method
Method | What it can change |
| Native text or media-free Inline text, including entities, link preview and buttons. |
| Caption and entities on photo, video, animation or document. Non-empty buttons require V2 media. |
| Replace photo, video, animation or document with the same media type. Non-empty buttons require V2 media. |
| Change buttons on supported native text or Inline messages while preserving the other content. |
All four methods edit messages sent by the current bot and return Message on success. editMessageText rejects parse_mode with 400. Omitting link_preview_options resets explicit preview settings.
Preserve or clear existing content
In compound edits, omitted or null
reply_markup, or an empty keyboard, clears existing buttons. Send the complete keyboard again to retain it.When editing media, an omitted or empty caption clears the old caption and entities. Send both values again to retain them.
When editing text, omitting
entitiesreruns mention detection. An explicit empty array clears entities without re-detecting them.
{"chat_id":"12345","message_id":678,"text":"Approved","reply_markup":{"inline_keyboard":[[{"text":"Details","url":"https://example.com/details"}]]}}This editMessageText request explicitly keeps the Details button. Use the original chat_id and message_id of the message you can edit.
To clear the buttons while preserving the rest of the message, use editMessageReplyMarkup with an empty keyboard.
{"chat_id":"12345","message_id":678,"reply_markup":{"inline_keyboard":[]}}
