Receiving updates
getUpdateslong polling; pass offset = last update_id + 1setWebhookurl, secret_token, allowed_updates, drop_pending_updatesgetWebhookInfolast_error_message, pending_update_countdeleteWebhookrequired before using getUpdates again- Header X-Telegram-Bot-Api-Secret-Token carries your secret_token
curl -s "https://api.telegram.org/bot$TOKEN/setWebhook" \
-d url=https://example.com/tg \
-d secret_token=$SECRETSending
sendMessagechat_id, text, parse_mode, reply_markup, link_preview_optionssendPhoto/sendDocument/sendMediaGroupeditMessageText,deleteMessagesendChatActiontyping indicator for slow repliesanswerCallbackQueryalways answer button pressessetMyCommandsthe command menu; scope and language_code
Update types
message,edited_messagecallback_queryinline button pressedinline_query@yourbot query in any chatmy_chat_memberbot added, removed or blockedchat_memberneeds explicit allowed_updatespre_checkout_querypayments; answer within 10 seconds
Formatting
- HTML: <b>, <i>, <u>, <s>, <code>, <pre>, <a href>, <tg-spoiler>, <blockquote>; escape &, < and >
- MarkdownV2: *bold* _italic_ __underline__ ~strike~ ||spoiler|| `code`
- In MarkdownV2 escape these with a backslash: _ * [ ] ( ) ~ ` > # + - = | { } . !
Convert between formats with the Markdown converter tool. Open
Keyboards and links
inline_keyboard: url, callback_data (1-64 bytes), web_app, switch_inline_querykeyboard+ resize_keyboard, one_time_keyboard, is_persistentremove_keyboard,force_replyt.me/<bot>?start=<param>arrives as "/start param"t.me/<bot>?startgroup=<param>add to a group
Common errors
400 Bad Request: can't parse entitiesunescaped MarkdownV2 or broken HTML400 message is too longover 4096 characters403 bot was blocked by the userstop messaging this chat409 Conflicttwo getUpdates consumers, or a webhook is set429 Too Many Requestswait parameters.retry_after seconds
Source: core.telegram.org/bots/api.
Last checked against official documentation: