answerCallbackQuery
Answers a callback query.
Returns: On success, returns True.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
callback_query_id | String | Yes | Callback query ID |
text | String | Optional | Notification text (0-200) |
show_alert | Boolean | Optional | Show alert instead of toast |
url | String | Optional | URL to open (Game URL or t.me link) |
cache_time | Integer | Optional | Cache time in seconds |
Example request
curl
curl -s -X POST "https://api.telegram.org/bot$TOKEN/answerCallbackQuery" \
-H "Content-Type: application/json" \
-d '{"callback_query_id":"CALLBACK_QUERY_ID"}'
Python
import requests
TOKEN = "123456789:AAEexampleTokenReplaceWithYours"
resp = requests.post(
f"https://api.telegram.org/bot{TOKEN}/answerCallbackQuery",
json={
"callback_query_id": "CALLBACK_QUERY_ID"
},
timeout=30,
)
print(resp.json())
JavaScript
const TOKEN = "123456789:AAEexampleTokenReplaceWithYours";
const res = await fetch(`https://api.telegram.org/bot${TOKEN}/answerCallbackQuery`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
"callback_query_id": "CALLBACK_QUERY_ID"
}),
});
console.log(await res.json());
Step-by-step guide: How to Send a Message with the Telegram Bot API (sendMessage)
Related methods
answerInlineQueryAnswers an inline query.answerGuestQueryAnswers a guest query - guest mode (Bot API 10.0).answerWebAppQuerySends a Web App interaction result.answerChatJoinRequestQueryAnswers a chat join request query (Bot API 10.1).sendChatJoinRequestWebAppShows a Mini App for a chat join request query (Bot API 10.1).