Docs

Methods

Every HTTP Bot API method with its parameters and result.

Every method is called as POST /bot/v1/<method> with the token (basics). Required parameters are in bold. The User, Chat and Message objects are in objects.

MethodWhat it does
getMeThe bot's profile
getUpdatesReceive updates
setWebhook, deleteWebhook, getWebhookInfoThe webhook
sendMessageSend a message or an ephemeral message
editMessageEdit a message
deleteMessageDelete messages
answerCallbackQueryAnswer a button press
answerAutocompleteQuerySuggest values for an option
setMyCommands, getMyCommands, deleteMyCommandsCommands
editEphemeralMessage, deleteEphemeralMessageEphemeral messages
getChatChat details
readPersonalMessagesMark read on someone's behalf

getMe

No parameters. The result is the bot's User and its switches:

{ "id": "…", "is_bot": true, "first_name": "Weather", "username": "weather_bot",
  "can_join_groups": true, "reads_all_messages": false, "supports_personal": false }

getUpdates

ParameterType
offsetintegerThe first update_id you want; lower ones are deleted.
limitinteger1–100, 100 by default.
timeoutintegerSeconds to wait, 0–50, 0 by default.
allowed_updatesstringsKinds of updates. Remembered.

The result is an array of updates. 409 when a webhook is set. Details in updates.

setWebhook

ParameterType
urlstringHTTPS on a public address.
secretstring16–256 characters A-Z a-z 0-9 _ -; turns on the X-Comon-Signature signature.
allowed_updatesstringsKinds of updates.
drop_pending_updatesbooleanDelete the waiting updates.

The result is true. Calling it again replaces the webhook and clears the last error.

deleteWebhook

ParameterType
drop_pending_updatesbooleanDelete the waiting updates.

The result is true.

getWebhookInfo

No parameters. The result:

FieldType
urlstringEmpty when there is no webhook.
has_secretbooleanWhether a secret is set.
pending_update_countintegerHow many updates wait.
last_error_dateintegerTime of the last error, Unix seconds.
last_error_messagestringThe last error: HTTP status 502, Timed out, Connection failed: ….

sendMessage

ParameterType
chat_idstringWhere. The bot must be in the chat, and in a direct chat the person must have started the bot.
textstringThe text. text or document is required.
entitiesarrayFormatting of text (messages).
documentobjectA document with headings, lists, code and other blocks (messages). Instead of text.
buttonsarray of rowsButtons (buttons).
reply_to_message_idstringA reply to a message of this chat.
idempotency_keystring1–128 characters; a retry with the same key returns the same message.
on_behalf_ofstringA person's ID: a personal bot answers on their behalf (personal bots).
ephemeralobjectSend an ephemeral message instead of an ordinary one.

The result is the sent Message.

With ephemeral the result is different:

{ "ephemeral_message_id": "…", "chat": {...}, "receiver": {...}, "expires_at": 1793136400 }

editMessage

ParameterType
chat_idstring
message_idstringThe bot's message (or the person's, for a personal bot with on_behalf_of).
text, entities, document, buttons, reply_to_message_idThe new content, as in sendMessage. Buttons are replaced entirely.
on_behalf_ofstringA person's ID, for a personal bot.

The result is the edited Message or true.

deleteMessage

ParameterType
chat_idstring
message_idstringOne message.
message_idsstringsOr up to 100 messages at once.
on_behalf_ofstringA person's ID, for a personal bot.

The result is true. A bot deletes its own messages, and others' when it has the right to delete in the chat.

answerCallbackQuery

ParameterType
callback_query_idstringid of the callback_query update.
textstringUp to 200 characters: a toast.
show_alertbooleanShow text in a dialog the person closes.
urlstringOpen an address.

The result is true. Without text and url nothing is shown. Answer within 10 seconds; later gets 400.

answerAutocompleteQuery

ParameterType
autocomplete_query_idstringid of the autocomplete_query update.
choicesarrayUp to 25 choices {"name": "Almaty", "value": "almaty"}; value has the option's type.

The result is true. Answer within 3 seconds.

setMyCommands

ParameterType
commandsarrayUp to 100 commands (commands). An empty array deletes the scope's commands.
scopeobject{"type": "default"} (the default), all_private_chats, all_group_chats or {"type": "chat", "chat_id": "…"}.

The result is true.

getMyCommands

ParameterType
scopeobjectAs in setMyCommands.

The result is the scope's commands in the shape they were set.

deleteMyCommands

ParameterType
scopeobjectAs in setMyCommands.

The result is true.

editEphemeralMessage

ParameterType
ephemeral_message_idstringAn ephemeral message of this bot.
text, entities, document, buttonsThe new content.

The result is {"ephemeral_message_id": "…"}. The lifetime is not extended.

deleteEphemeralMessage

ParameterType
ephemeral_message_idstring

The result is true.

getChat

ParameterType
chat_idstringA chat the bot belongs to.

The result is a Chat, with member_count for direct chats and groups. 404 when the chat does not exist or the bot is not in it.

readPersonalMessages

ParameterType
owner_idstringThe person who connected the bot.
chat_idstringTheir direct chat.
read_through_orderintegerorder of the last message read.

The result is true. Needs the "Mark messages read" right (personal bots).

On this page