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.
| Method | What it does |
|---|---|
getMe | The bot's profile |
getUpdates | Receive updates |
setWebhook, deleteWebhook, getWebhookInfo | The webhook |
sendMessage | Send a message or an ephemeral message |
editMessage | Edit a message |
deleteMessage | Delete messages |
answerCallbackQuery | Answer a button press |
answerAutocompleteQuery | Suggest values for an option |
setMyCommands, getMyCommands, deleteMyCommands | Commands |
editEphemeralMessage, deleteEphemeralMessage | Ephemeral messages |
getChat | Chat details |
readPersonalMessages | Mark 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
| Parameter | Type | |
|---|---|---|
offset | integer | The first update_id you want; lower ones are deleted. |
limit | integer | 1–100, 100 by default. |
timeout | integer | Seconds to wait, 0–50, 0 by default. |
allowed_updates | strings | Kinds of updates. Remembered. |
The result is an array of updates. 409 when a webhook is set. Details in updates.
setWebhook
| Parameter | Type | |
|---|---|---|
url | string | HTTPS on a public address. |
secret | string | 16–256 characters A-Z a-z 0-9 _ -; turns on the X-Comon-Signature signature. |
allowed_updates | strings | Kinds of updates. |
drop_pending_updates | boolean | Delete the waiting updates. |
The result is true. Calling it again replaces the webhook and clears the last error.
deleteWebhook
| Parameter | Type | |
|---|---|---|
drop_pending_updates | boolean | Delete the waiting updates. |
The result is true.
getWebhookInfo
No parameters. The result:
| Field | Type | |
|---|---|---|
url | string | Empty when there is no webhook. |
has_secret | boolean | Whether a secret is set. |
pending_update_count | integer | How many updates wait. |
last_error_date | integer | Time of the last error, Unix seconds. |
last_error_message | string | The last error: HTTP status 502, Timed out, Connection failed: …. |
sendMessage
| Parameter | Type | |
|---|---|---|
chat_id | string | Where. The bot must be in the chat, and in a direct chat the person must have started the bot. |
text | string | The text. text or document is required. |
entities | array | Formatting of text (messages). |
document | object | A document with headings, lists, code and other blocks (messages). Instead of text. |
buttons | array of rows | Buttons (buttons). |
reply_to_message_id | string | A reply to a message of this chat. |
idempotency_key | string | 1–128 characters; a retry with the same key returns the same message. |
on_behalf_of | string | A person's ID: a personal bot answers on their behalf (personal bots). |
ephemeral | object | Send 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
| Parameter | Type | |
|---|---|---|
chat_id | string | |
message_id | string | The bot's message (or the person's, for a personal bot with on_behalf_of). |
text, entities, document, buttons, reply_to_message_id | The new content, as in sendMessage. Buttons are replaced entirely. | |
on_behalf_of | string | A person's ID, for a personal bot. |
The result is the edited Message or true.
deleteMessage
| Parameter | Type | |
|---|---|---|
chat_id | string | |
message_id | string | One message. |
message_ids | strings | Or up to 100 messages at once. |
on_behalf_of | string | A 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
| Parameter | Type | |
|---|---|---|
callback_query_id | string | id of the callback_query update. |
text | string | Up to 200 characters: a toast. |
show_alert | boolean | Show text in a dialog the person closes. |
url | string | Open an address. |
The result is true. Without text and url nothing is shown. Answer within 10 seconds; later
gets 400.
answerAutocompleteQuery
| Parameter | Type | |
|---|---|---|
autocomplete_query_id | string | id of the autocomplete_query update. |
choices | array | Up to 25 choices {"name": "Almaty", "value": "almaty"}; value has the option's type. |
The result is true. Answer within 3 seconds.
setMyCommands
| Parameter | Type | |
|---|---|---|
commands | array | Up to 100 commands (commands). An empty array deletes the scope's commands. |
scope | object | {"type": "default"} (the default), all_private_chats, all_group_chats or {"type": "chat", "chat_id": "…"}. |
The result is true.
getMyCommands
| Parameter | Type | |
|---|---|---|
scope | object | As in setMyCommands. |
The result is the scope's commands in the shape they were set.
deleteMyCommands
| Parameter | Type | |
|---|---|---|
scope | object | As in setMyCommands. |
The result is true.
editEphemeralMessage
| Parameter | Type | |
|---|---|---|
ephemeral_message_id | string | An ephemeral message of this bot. |
text, entities, document, buttons | The new content. |
The result is {"ephemeral_message_id": "…"}. The lifetime is not extended.
deleteEphemeralMessage
| Parameter | Type | |
|---|---|---|
ephemeral_message_id | string |
The result is true.
getChat
| Parameter | Type | |
|---|---|---|
chat_id | string | A 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
| Parameter | Type | |
|---|---|---|
owner_id | string | The person who connected the bot. |
chat_id | string | Their direct chat. |
read_through_order | integer | order of the last message read. |
The result is true. Needs the "Mark messages read" right (personal bots).