/api/v1/bots/self/infoWho the token belongs to.
Returns: {id, name, username, description, commands} — commands is the default list.
401 Invalid bot token · 403 Bot owner is banned
Everything a bot can call, what it receives, and its limits. The reference is in English because it is written in field names, paths and JSON.
Create a bot in Settings → Bots. The token (mia_bot_ followed by 48 hex characters) is shown ONCE, at creation and at every regeneration; the server keeps only its SHA-256 hash and cannot show it again.
Every bot call sends the token in the X-Bot-Token header. Without the header the answer is 422 (a required field is missing); a wrong token, or the token of a disabled bot, answers 401 Invalid bot token; a bot whose owner is banned answers 403 Bot owner is banned.
Routes marked "signed-in person" are called by the apps on behalf of a person, with that person's session (Authorization: Bearer <access token> or the session cookie). They are listed so the whole surface is in one place.
Bodies are JSON unless a method says otherwise. An error is {"detail": "..."}; a body that breaks a field rule (type, length, range) answers 422 with the field named in detail.
A bot is an account of its own. Who may write to it is the bot's inbound_policy: owner_only (the default) or anyone, set by the owner. A message from anyone else is refused before it is stored and never reaches the bot.
A bot answers, it does not solicit: it may write to its owner and to a person who has written to it at least once — never to someone who blocked it or whom it blocked. Anything else answers 403 This bot may only message its owner and people who have written to it.
A bot receives the direct messages addressed to it. It does not read groups, channels or its owner's other chats.
A bot receives by ONE transport. While a webhook URL is set, GET /self/updates answers 409 ("Long poll is disabled because a webhook URL is configured…"); clearing the URL brings long poll back.
Long poll: call GET /self/updates with after_id = the last last_id you got and timeout up to 50 seconds; the call returns as soon as something arrives or the window closes. Messages are numbered by id, so a cursor never misses one or reads one twice.
Updates that are not messages (edited_message, callback_query, poll_answer, message_reaction, my_chat_member) are served only when you send after_update_id, with their own cursor last_update_id — a separate numbering from message ids. They are kept for 24 hours; one not fetched within a day is gone.
Webhook: the server POSTs each update to your HTTPS URL. See "Webhooks" below.
| Kind | When | Body |
|---|---|---|
| message | A person wrote to the bot | id (long poll) / update_id (webhook), from_user_id, text, created_at, message_type (text, image, video, file, …), file (long poll: null when there is none; webhook: absent when there is none) |
| edited_message | A person edited their message to the bot | the message fields plus edited_at; a bot's own edit-message call is not echoed back to it |
| callback_query | A person tapped a callback button under the bot's message | id (answer with it), from_user_id, chat_id, message {message_id, text}, data |
| inline_query | A person typed @yourbot text in a chat (only when inline mode is on for the bot) | id (answer with it, within about 5 seconds), from_user_id, query (up to 256 characters), offset, chat_type (private or group), and location (latitude, longitude) only when the bot's owner switched on inline results by location (the owner switch in the bot settings, inline_geo of PUT /bots/{id}/inline) AND the person agreed for your bot; a located answer is never cached. The chat itself is never sent |
| chosen_inline_result | The person picked one of your results (only when inline feedback is on) | result_id, from_user_id, query |
| poll_answer | Someone answered a poll the bot can see | poll_id, from_user_id, option_ids, date. Non-anonymous polls only — an anonymous poll hides who answered |
| message_reaction | A reaction on a message in the bot's chat was added or removed | message_id, from_user_id, emoji, action (added or removed), date — one emoji per update. Opt-in: sent only when allowed_updates names it |
| my_chat_member | A person blocked (kicked) or unblocked (member) the bot, or added it to a group by a startgroup link | chat_id, from_user_id, old_status, new_status, date; for a group add also chat_type: "group", start_payload, text = /start@<bot> <payload> |
A message with an attachment carries file: {file_id, name, mime, size, download_url}. download_url is /api/v1/bots/self/files/{file_id}; fetch it WITH the token and it redirects (307) to a fresh signed link, so it does not expire while an update waits in the queue.
To send a file: upload it with POST /self/upload, then send-message with the returned file_id (text becomes the caption). Images arrive as image, videos as video, everything else as file. A bot may attach a file it uploaded or one it received in a message (its file_id); any other file answers 403 Not your file.
reply_markup on send-message carries exactly ONE of the four forms below. A wrong keyboard is refused with 400 and a message — it is never silently repaired.
Limits for both keyboards: 1-10 rows, 1-8 buttons per row, at most 100 buttons, button text 1-64 characters.
Inline keyboard: each button has text and exactly one of callback_data (1-64 bytes), url (an https:// link, at most 512 characters), web_app ({"url": "https://..."}) or login_url ({"url": ...} plus optional forward_text, bot_username, request_write_access); web_app and login_url open outside the app like url. A tap on a callback button writes no chat message; the bot gets a callback_query and should answer it with answer-callback-query.
Reply keyboard: a tap SENDS the button's text as an ordinary message from the person. A button is a string or {"text": ...}; {"text": ..., "web_app": {"url": "https://..."}} opens the link outside the app instead of sending the text. Any other field (contact, location requests) is refused.
An edit (edit-message-text, edit-message-reply-markup) carries an inline keyboard only; an edit without reply_markup removes the keyboard.
| Form | Shape |
|---|---|
| Inline keyboard | {"inline_keyboard": [[{"text": "Yes", "callback_data": "yes"}, {"text": "Site", "url": "https://example.com"}]]} |
| Reply keyboard | {"keyboard": [["One", {"text": "Two"}]]} plus optional booleans is_persistent, resize_keyboard, one_time_keyboard, selective and input_field_placeholder (1-64 characters) |
| Remove reply keyboard | {"remove_keyboard": true} plus optional selective |
| Force reply | {"force_reply": true} plus optional input_field_placeholder (1-64 characters) and selective |
A command list is up to 100 items of {command, description}: command 1-32 of lowercase a-z, digits and _; description 1-256 characters; no command twice.
scope is {"type": ...} with one of default, all_private_chats, all_group_chats, all_chat_administrators, chat and chat_administrators (both need chat_id), chat_member (needs chat_id and user_id). Omitted = default. language_code is a two-letter ISO 639-1 code; omitted or empty = everyone the scope covers.
What a person sees after typing "/" in a direct chat with the bot: the first list that is set among chat (their chat) → all_private_chats → default, each tried in the person's app language first, then without a language.
The menu button beside the composer opens this list. It is shown by default; set-menu-button with hidden removes it, with web_app and an https url it opens that page as a mini app instead.
A mini app is your https page opened inside the chat app from a web_app button, the menu button (set-menu-button with web_app) or the attach menu. The person confirms the first open of each bot's mini app. The page receives signed launch data (initData, a URL-encoded query string): user (JSON with id, first_name, last_name, username, language_code), auth_date (unix seconds), start_param and hash. Nothing else is sent. The page talks to the app with the reference's postMessage protocol (web_app_ready, web_app_close, web_app_data_send, web_app_expand, web_app_open_link, web_app_request_theme, web_app_request_viewport, web_app_setup_closing_behavior); other events are ignored.
Verify the launch data on your server exactly as the reference documents, with ONE difference: we never hold your bot token (only its sha256), so the secret key is built from sha256(token) hex instead of the token. Build the data-check-string from every field except hash, sorted by key, as key=value lines joined by a newline; then secret = HMAC_SHA256(key="WebAppData", msg=sha256_hex(token)) and hash = hex(HMAC_SHA256(key=secret, msg=data_check_string)). Also check that auth_date is recent.
secret = hmac.new(b"WebAppData", hashlib.sha256(TOKEN.encode()).hexdigest().encode(), hashlib.sha256).digest()
check = "\n".join(f"{k}={v}" for k, v in sorted(fields.items()) if k != "hash")
valid = hmac.compare_digest(hmac.new(secret, check.encode(), hashlib.sha256).hexdigest(), fields["hash"])Data the page sends back with web_app_data_send (at most 4096 bytes) reaches the bot as an update of kind web_app_data: {from_user_id, data, button_text, date}. When the page is opened from a chat (the menu button, a keyboard button or the attach menu) the launch data also carries query_id, a one-use right to send ONE message as that person into that chat with answer-web-app-query below; it is bound to your bot, the person and the chat, and lasts 15 minutes. It is part of the signed fields, so it is covered by the hash.
/u/<bot username>?start=<payload> on the app's address opens the chat with the bot with Start ready; Start sends /start <payload>, which reaches the bot as an ordinary message text. The payload is 1-64 of A-Z, a-z, 0-9, _ and -; an invalid one is dropped and plain /start is sent.
?startgroup=<payload> opens a group picker instead; the bot is added through the ordinary add-members rules and receives a my_chat_member update with start_payload. A bot whose inbound_policy is owner_only can be added this way by its owner only. startapp links are not supported.
The URL must be https://, carry no user or password, and resolve only to public addresses (no localhost, private, link-local or metadata addresses). It is checked when saved AND again before every delivery. With the ip_address option that public address is used instead of DNS.
Options saved with the URL: max_connections (1-100, default 40) caps deliveries in flight; allowed_updates limits the kinds sent (by webhook and long poll); drop_pending_updates skips everything addressed to the bot before the call.
The first time a URL is saved, the response carries webhook_secret — shown once. Saving another URL keeps the secret; clearing the URL clears it; rotate-secret issues a new one and the old one stops at once.
Each delivery is POST <url> with Content-Type: application/json and the headers X-MiaChat-Bot-Update-Id, X-MiaChat-Bot-Update-Kind (message, edited_message, callback_query, poll_answer, message_reaction or my_chat_member), X-MiaChat-Bot-Delivery: 1 and X-MiaChat-Bot-Signature: sha256=<hex> — the HMAC-SHA256 of the raw body with your secret as the key. Verify it against the exact bytes received.
Body for a message: {"update_id", "type": "message", "from_user_id", "text", "message_type", "created_at", "file"?}. Body for the other kinds: {"update_id", "type": kind, kind: {...}, "created_at"}. Messages and other updates are numbered separately, so deduplicate by (kind, update id).
Your endpoint has 5 seconds to answer. A delivery is tried up to 4 times, 0.5 s, 1 s and 2 s apart; network errors, 5xx, 408 and 429 are retried, any other 4xx is not.
After the last attempt the update is dropped: nothing is stored for redelivery, and long poll cannot fetch it while the webhook is set. Answer quickly with a 2xx and do slow work afterwards.
A bot may send 60 messages per minute (send-message and upload share this budget) and 120 chat actions per minute.
A send-message call is counted before its target, write rule and file are checked, so a refused send (403, 404) still spends the budget.
Over the budget the answer is 429 with the body {"detail": "...", "retry_after": N} and the header Retry-After: N — wait N whole seconds, then retry.
A bot receives at most 120 messages per minute across all senders; past that a person's message is refused on their side and never reaches the bot.
A person may tap 30 callback buttons per minute across all bots.
Called by your bot with its token.
/api/v1/bots/self/infoWho the token belongs to.
Returns: {id, name, username, description, commands} — commands is the default list.
401 Invalid bot token · 403 Bot owner is banned/api/v1/bots/self/updatesLong poll for messages and other updates.
| after_id | integer | 0 to 2147483647, default 0. Messages with a greater id. |
| limit | integer | 1-100, default 50. Applies to messages and to updates separately. |
| timeout | integer | 0-50 seconds, default 0 (answer at once). |
| after_update_id | integer | 0 to 2147483647. Send it to also receive callback_query and my_chat_member. |
Returns: {messages: [...], last_id, updates: [{update_id, type, <type>: {...}, created_at}], last_update_id}. The bot's own messages are not included.
401 Invalid bot token · 403 Bot owner is banned · 409 Long poll is disabled because a webhook URL is configured/api/v1/bots/self/send-messageSend a message to a person in the bot's direct chat.
| target_user_id | integer | The person (their user id, as from_user_id in an update). Exactly one of target_user_id / target_group_id. |
| target_group_id | integer | A group the bot is a member of. |
| reply_to_message_id | integer | Groups only. |
| topic_id | integer | Groups only: a topic of a forum group. |
| text | string | Up to 4000 characters. Required unless file_id, location, contact_user_id or poll is set; with file_id it is the caption. |
| file_id | integer | A file from POST /self/upload. Direct chats only. |
| reply_markup | object | A keyboard, see "Keyboards". Direct chats only. |
| parse_mode | string | MarkdownV2, Markdown or HTML (any case). Bold, italic, strikethrough, spoiler, inline code, pre blocks, http(s) links and block quotes are shown; underline shows as plain text; a link to anything but http(s) shows its label only. Omitted = text is shown as sent (our own markdown: **bold**, *italic*, ~~strike~~, ||spoiler||). |
| location | object | {latitude, longitude, address?} — a location message; nothing else beside it. |
| contact_user_id | integer | Share an account as a contact: the owner or a person who wrote to the bot. |
| poll | object | {question, options (2-12), is_anonymous?, allow_multi_choice?, is_quiz?, quiz_correct_idx?, explanation?, closes_in_minutes?}. |
Returns: {ok: true, message_id}
401 Invalid bot token · 403 Bot owner is banned · 400 (target_user_id missing) · 400 text, file_id, location, contact_user_id or poll required · 400 exactly one of target_user_id or target_group_id required · 400 (a keyboard rule) · 400 Unsupported parse_mode / can't parse entities: … (an unknown mode, an unsupported or unclosed tag, a bad numeric entity) · 403 This bot may only message its owner and people who have written to it · 403 Not your file · 404 Target user not found · 404 File not found · 429 rate limit, see "Errors and rate limits"/api/v1/bots/self/uploadUpload a photo, video or document as the bot: multipart/form-data with one field file, the same type checks and size limits as a person's upload.
Returns: {ok, file_id, original_name, size_bytes, content_type, url, …} — pass file_id to send-message.
401 Invalid bot token · 403 Bot owner is banned · 429 rate limit (shares the 60 messages/min budget)/api/v1/bots/self/files/{file_id}Download a file from an update.
Returns: 307 redirect to a short-lived signed link.
401 Invalid bot token · 403 Bot owner is banned · 404 File not found (not in a live message to or from this bot)/api/v1/bots/self/edit-message-textEdit the text of one of the bot's own messages.
| message_id | integer · required | A message this bot sent. |
| text | string · required | 1-4000 characters. |
| reply_markup | object | Inline keyboard only; omitted removes the keyboard. |
| parse_mode | string | MarkdownV2, Markdown or HTML (any case). Bold, italic, strikethrough, spoiler, inline code, pre blocks, http(s) links and block quotes are shown; underline shows as plain text; a link to anything but http(s) shows its label only. Omitted = text is shown as sent (our own markdown: **bold**, *italic*, ~~strike~~, ||spoiler||). |
Returns: {ok: true, message_id, edited_at}
401 Invalid bot token · 403 Bot owner is banned · 400 (a keyboard rule) · 400 Unsupported parse_mode / can't parse entities: … (an unknown mode, an unsupported or unclosed tag, a bad numeric entity) · 400 text is empty after parse_mode · 404 Message not found/api/v1/bots/self/edit-message-reply-markupReplace or remove the inline keyboard of one of the bot's own messages; the text is kept.
| message_id | integer · required | A message this bot sent. |
| group_id | integer | Set for a group message; omitted = a direct message. |
| reply_markup | object | Inline keyboard only; omitted removes the keyboard. |
Returns: {ok: true, message_id, edited_at}
401 Invalid bot token · 403 Bot owner is banned · 400 (a keyboard rule) · 403 This bot is not a member of that group · 404 Message not found/api/v1/bots/self/delete-messageDelete one of the bot's own messages, for everyone.
| message_id | integer · required | A message this bot sent. |
Returns: {ok: true, message_id}
401 Invalid bot token · 403 Bot owner is banned · 404 Message not found/api/v1/bots/self/answer-callback-queryAnswer a button tap. The person sees text as a short notice, or as an alert with show_alert. Once per query.
| callback_query_id | string · required | The id of the callback_query. |
| text | string | Up to 200 characters. |
| show_alert | boolean | Default false. |
| url | string | An https:// link (up to 512 characters) the person's app offers to open, after an "Open this link?" confirm. |
| cache_time | integer | 0-86400 seconds, default 0. For that long the same person's tap on the same button of the same message gets this answer again without a new callback_query reaching the bot. |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 Query is unknown or already answered · 422 (url not https, cache_time out of range)/api/v1/bots/self/answer-inline-queryAnswer an inline_query with a list of results the person can pick. Once per query. A picked result is sent into the chat as the person, marked "via @yourbot". Inline mode is switched on in the bot's settings (with an optional input hint).
| inline_query_id | string · required | The id of the inline_query. |
| results | array · required | At most 50 objects with a unique id (1-64 bytes) and a type: article (title, input_message_content {message_text, up to 4000 characters}, optional url, description, thumbnail_url), photo (photo_url) or gif (gif_url). Photo and gif links must be https://; our server downloads the picture (public addresses only, up to 5 MB, a gif up to 4096 px and 300 frames) and sends it as an image message. A picture that cannot be loaded makes the pick fail. |
| cache_time | integer | 0-86400 seconds, default 300. The same query is answered from the cache for that long. |
| is_personal | boolean | Default false. True keeps the cached answer for the asking person only. |
| next_offset | string | Up to 64 bytes. Empty or omitted = no more pages; otherwise it comes back as offset of the next inline_query. |
| button | object | {text, start_parameter} or {text, web_app: {url}} (exactly one): a button above the results that either opens a private chat with the bot and passes start_parameter (A-Z a-z 0-9 _ -, up to 64) as the start payload, or opens the bot's mini app at the https url. |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 Query is unknown or already answered · 400 (a result, cache_time, next_offset or button rule)/api/v1/bots/self/answer-web-app-queryAnswer a mini app's query_id (a field of its signed launch data): the message is sent into the chat the page was opened from, as the person who opened it, marked "via @yourbot". Once per query, within 15 minutes; the same send rules as a picked inline result apply to the person (blocks, bans, mutes, slow mode).
| web_app_query_id | string · required | The query_id of the launch data. |
| result | object · required | One inline result in the same form as in answer-inline-query: an article (id, title, input_message_content {message_text}), a photo or a gif. |
Returns: {ok: true, message_id}
401 Invalid bot token · 403 Bot owner is banned · 400 Query is unknown, expired, already answered or not this bot's · 400 (a result rule) · 403 The message could not be sent to this chat/api/v1/bots/self/send-gameSend one of the bot's registered games to a person as a message with a Play button. The owner registers games in Bots > the bot > Games; a tap on Play records a callback_query update with game_short_name and opens the game's https link after the same "Open this link?" confirm as a url button.
| target_user_id | integer · required | The person. The same write rule as send-message. |
| game_short_name | string · required | 3-64 letters, digits or underscores; a game of THIS bot (404 otherwise). |
| reply_markup | object | An inline_keyboard that must carry a callback_game button; omitted = one "Play" button. The button is bound to the game on our side. |
Returns: {ok: true, message_id}
401 Invalid bot token · 403 Bot owner is banned · 400 reply_markup of a game must carry a callback_game button · 403 This bot may only message its owner and people who have written to it · 404 Game not found · 404 Target user not found · 429 rate limit (60 messages/min)/api/v1/bots/self/send-invoiceSend a Stars invoice (currency XTR, no provider token) to a person as a message with a Pay button. When the person pays, the bot receives a pre_checkout_query update and must answer it within 10 seconds; an ok answer charges the person and credits the bot owner, then a successful_payment update follows.
| target_user_id | integer · required | The person. The same write rule as send-message. |
| title | string · required | 1-32 characters. |
| description | string · required | 1-255 characters. |
| payload | string · required | 1-128 characters, opaque to us; echoed back as invoice_payload. |
| currency | string | Must be XTR (Stars). Default XTR. |
| prices | array · required | Exactly one item {label, amount}; amount 1-10000 Stars. |
| provider_token | string | Must be empty or absent. |
Returns: {ok: true, message_id, invoice}
401 Invalid bot token · 403 Bot owner is banned · 400 currency must be XTR · 422 (a field rule) · 403 This bot may only message its owner and people who have written to it · 404 Target user not found · 429 rate limit (60 messages/min)/api/v1/bots/self/answer-pre-checkout-queryAnswer a pre_checkout_query update. ok: true lets the payment go through (nothing is charged before this); ok: false with error_message cancels it and the person sees the message. Unanswered for 10 seconds = cancelled.
| pre_checkout_query_id | string · required | The id of the update's pre_checkout_query. |
| ok | boolean · required | True to proceed. |
| error_message | string | Required when ok is false; at most 255 characters. |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 error_message is required when ok is false · 400 Query is unknown, already answered or expired/api/v1/bots/self/refund-star-paymentRefund a completed Stars payment: the Stars move from the bot owner back to the person. Once per payment.
| user_id | integer · required | The person who paid. |
| payment_charge_id | string · required | The payment_charge_id of the successful_payment update. |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 Payment already refunded · 400 The bot owner does not have enough Stars to refund · 404 Payment not found/api/v1/bots/self/set-game-scoreSet a person's score in one of the bot's games. A lower score than the stored one, or a person who never tapped Play, needs force.
| user_id | integer · required | The person. |
| score | integer · required | 0 to 2147483647. |
| game_short_name | string · required | A game of this bot. |
| force | boolean | Default false. Allows a lower score and a first score for a person who has not played (the write rule of send-message still applies). |
Returns: {ok: true, score}
401 Invalid bot token · 403 Bot owner is banned · 400 The new score is lower than the current one; pass force to lower it · 400 This person has not played the game; pass force to set a score anyway · 403 This bot may only message its owner and people who have written to it · 404 Game not found/api/v1/bots/self/get-game-high-scoresThe top 10 of a game's table, and optionally one person's own place.
| game_short_name | string · required | A game of this bot. |
| user_id | integer | Adds user with that person's score and position when they have a score above 0. |
Returns: {scores: [{position, user_id, name, score}], user?: {user_id, score, position}}
401 Invalid bot token · 403 Bot owner is banned · 404 Game not found/api/v1/bots/self/send-chat-actionShow "typing…" in the chat with a person or in a group the bot is in. It disappears about 3 seconds after the last call, so repeat it while the bot works.
| target_user_id | integer | The person. Exactly one of this or target_group_id. |
| target_group_id | integer | A group the bot is a member of (403 otherwise). |
| action | string | Only typing (the default). |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 exactly one of target_user_id or target_group_id required · 400 Only the 'typing' action is supported · 403 This bot may only message its owner and people who have written to it · 403 This bot is not a member of that group · 429 rate limit (120 actions/min)/api/v1/bots/self/set-my-commandsSet the command list of a scope and language.
| commands | array · required | [{command, description}], see "Commands and scopes". |
| scope | object | See "Commands and scopes". Omitted = default. |
| language_code | string | Two letters, or empty for every language. |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 (a scope, language or command rule)/api/v1/bots/self/get-my-commandsThe list stored for exactly this scope and language (no fallback). POST because the scope is a JSON object.
| scope | object | See "Commands and scopes". Omitted = default. |
| language_code | string | Two letters, or empty for every language. |
Returns: {commands: [...]} — [] when none is set.
401 Invalid bot token · 403 Bot owner is banned · 400 (a scope or language rule)/api/v1/bots/self/delete-my-commandsDelete the list of a scope and language; the next broader list then applies.
| scope | object | See "Commands and scopes". Omitted = default. |
| language_code | string | Two letters, or empty for every language. |
Returns: {ok: true}
401 Invalid bot token · 403 Bot owner is banned · 400 (a scope or language rule)/api/v1/bots/self/set-menu-buttonShow or hide the menu button beside the composer in chats with the bot, or make it open a mini app.
| type | string · required | commands, hidden or web_app. |
| url | string | Required with web_app (an https:// page, at most 1024 characters); refused with the other types. |
Returns: {ok: true, menu_button, url}
401 Invalid bot token · 403 Bot owner is banned · 400 (web_app without an https url, or url with another type)/api/v1/bots/self/webhook-infoThe state of the bot's webhook delivery.
Returns: {url, has_custom_certificate: false, pending_update_count, dropped_update_count, last_error_date, last_error_message, max_connections, allowed_updates}. pending_update_count = deliveries in flight right now (updates are never queued); dropped_update_count = updates that failed since the last successful delivery; the last error is kept until the URL is set again or removed.
401 Invalid bot token · 403 Bot owner is banned/api/v1/bots/self/set-message-reactionReact to a message in the bot's direct chat or in a group it is in. Like a person's tap it toggles: a second call with the same emoji removes it. The bot is not told of its own reaction.
| message_id | integer · required | The message. |
| group_id | integer | Set for a group message; omitted = a direct message. |
| emoji | string · required | 1-32 characters; the group's reaction rules apply. |
| big | boolean | Default false. |
Returns: {action: "added" | "removed", …}
401 Invalid bot token · 403 Bot owner is banned · 403 (not a member of the group, or the reaction is not allowed) · 404 Message not found · 429 rate limit/api/v1/bots/self/pin-messagePin a message. In a group the bot needs the pin_messages right, as a member would.
| message_id | integer · required | The message. |
| group_id | integer | Set for a group message; omitted = a direct message. |
| silent | boolean | Groups only: no "pinned a message" service line. |
Returns: {ok: true, is_pinned: true, …}
401 Invalid bot token · 403 Bot owner is banned · 403 (not a member, or no `pin_messages` right) · 404 Message not found · 429 rate limit/api/v1/bots/self/unpin-messageUnpin a message; the same body and rules as pin-message.
| message_id | integer · required | The message. |
| group_id | integer | Set for a group message; omitted = a direct message. |
Returns: {ok: true, is_pinned: false, …}
401 Invalid bot token · 403 Bot owner is banned · 403 (not a member, or no `pin_messages` right) · 404 Message not found · 429 rate limit/api/v1/bots/self/stop-pollClose a poll the bot sent itself (in a direct chat of its own or in a group it is in). Members get the same "poll closed" update as when a person closes a poll.
| message_id | integer · required | The poll message. |
| group_id | integer | Set for a group message; omitted = a direct message. |
Returns: {ok: true, poll_id, closed_at}
401 Invalid bot token · 403 Bot owner is banned · 400 That message is not a poll · 400 The poll could not be closed · 403 A bot may close only a poll it sent itself · 403 This bot is not a member of that group · 404 Message not found · 409 The poll is already closed/api/v1/bots/self/forward-messageForward a message the bot can read (its direct chat, or a group it is in) to a person or a group, with the "Forwarded from" header.
| message_id | integer · required | The source message. |
| from_group_id | integer | Set when the source is a group message. |
| target_user_id | integer | Exactly one of target_user_id / target_group_id; a person must be one the bot may write to. |
| target_group_id | integer | A group the bot is a member of. |
| hide_captions | boolean | Drop the caption of a photo or file. |
Returns: The forwarded message's ids.
401 Invalid bot token · 403 Bot owner is banned · 400 exactly one of target_user_id or target_group_id required · 403 This bot may only message its owner and people who have written to it · 403 (not a member of a group, or content protection) · 404 Message not found · 429 rate limit/api/v1/bots/self/copy-messageCopy a message: the same as forward-message without the "Forwarded from" header.
| message_id | integer · required | The source message. |
| from_group_id | integer | Set when the source is a group message. |
| target_user_id | integer | Exactly one of target_user_id / target_group_id. |
| target_group_id | integer | A group the bot is a member of. |
| hide_captions | boolean | Drop the caption of a photo or file. |
Returns: The copied message's ids.
401 Invalid bot token · 403 Bot owner is banned · 400 exactly one of target_user_id or target_group_id required · 403 This bot may only message its owner and people who have written to it · 403 (not a member of a group, or content protection) · 404 Message not found · 429 rate limit/api/v1/bots/self/default-admin-rightsThe rights the bot asks for when it is added as an administrator.
Returns: {group, channel} — each {right: bool}, or null when none is requested.
401 Invalid bot token · 403 Bot owner is banned/api/v1/bots/self/chat-memberA person's standing in a group the bot is a member of. Query: chat_id, user_id.
Returns: {user_id, status} — creator, administrator (with rights: {right: bool}), member, left or kicked.
401 Invalid bot token · 403 Bot owner is banned · 403 (the bot is not a member of the group)What Settings → Bots calls. Only the bot's owner may call them for a bot; any other bot id answers 404.
/api/v1/bots/meThe caller's bots, newest first.
Returns: [{id, name, username, description, about, avatar_url, commands, webhook_url, enabled, inbound_policy, transfer_pending_to, created_at}] — never the token.
/api/v1/botsCreate a bot. Up to 10 bots per person.
| name | string · required | 1-64 characters. |
| username | string · required | 5-32 of A-Z, a-z, 0-9, _, ending in bot (any case); stored lowercase. |
| description | string | Up to 500 characters; shown in an empty chat with the bot. |
| about | string | Up to 120 characters. |
Returns: The bot as in GET /me, plus bot_token — the only time it is shown.
403 Max 10 bots per user · 409 Username already taken · 422 (a username rule)/api/v1/bots/{bot_id}Change the bot's profile and who may write to it. Only the fields sent are changed.
| name | string | 1-64 characters. |
| description | string | Up to 500; empty clears it. |
| about | string | Up to 120; empty clears it. |
| avatar_url | string | Up to 512 characters. |
| enabled | boolean | A disabled bot's token answers 401. |
| inbound_policy | string | owner_only or anyone. |
Returns: {ok: true}
404 Bot not found/api/v1/bots/{bot_id}/default-admin-rightsSet the rights the bot asks for when it is added as an administrator — to groups, or to channels.
| for_channels | boolean | Default false (groups). |
| rights | object | {right: bool} from the group permissions (or channel rights); null clears the request. |
Returns: {ok: true, for_channels, rights}
400 Unknown right(s): … · 404 Bot not found/api/v1/bots/{bot_id}/transferOffer the bot to another person. Nothing moves until they accept within 48 hours; a new offer replaces a pending one. Needs a confirmed sign-in.
| username | string · required | The new owner's username (a leading @ is fine). They must have written to the bot at least once. |
Returns: {ok: true, transfer_pending_to, expires_at}; GET /me shows transfer_pending_to while the offer waits.
400 You already own this bot · 403 session_unconfirmed · 403 Max 10 bots per user (the new owner's limit) · 404 Bot not found · 404 User not found · 409 The new owner must have written to this bot at least once/api/v1/bots/{bot_id}/transferWithdraw a pending transfer offer.
Returns: {ok: true}
404 Bot not found/api/v1/bots/transfer-offersBots offered to the caller and still waiting for an answer.
Returns: [{bot_id, name, username, avatar_url, from_username, from_display_name, expires_at}]
/api/v1/bots/{bot_id}/transfer/acceptTake the bot offered to you. In the same step its token is replaced (the old one stops at once) and its webhook URL, secret and options are cleared. Needs a confirmed sign-in.
Returns: The bot as in GET /me, plus the new bot_token — the only time it is shown.
403 session_unconfirmed · 403 Max 10 bots per user · 404 No such transfer offer · 410 This transfer offer has expired/api/v1/bots/{bot_id}/transfer/declineTurn down a transfer offer; the bot stays with its owner.
Returns: {ok: true}
404 No such transfer offer/api/v1/bots/{bot_id}Delete the bot. Its chats leave every list, the message history stays readable, and the username becomes free.
Returns: {ok: true}
404 Bot not found/api/v1/bots/{bot_id}/regenerate-tokenIssue a new token; the old one stops working at once.
Returns: {bot_token} — shown once.
404 Bot not found/api/v1/bots/{bot_id}/tokenA token cannot be read back; this route says so.
Returns: Always 410 for the owner's bot — regenerate instead.
404 Bot not found · 410 shown once at creation or regeneration/api/v1/bots/{bot_id}/preview-mediaReplace the bot's profile preview pictures with up to 5 images the owner uploaded; an empty list clears them.
| file_ids | array · required | Ids of the owner's own uploaded images, in display order; duplicates are dropped. |
Returns: {preview_media: [...]} as stored.
404 Bot not found · 404 File not found (missing or not the owner's) · 400 Preview media must be images/api/v1/bots/{bot_id}/commandsReplace the default command list (no scope, no language). Items without a command or a description are dropped; at most 50 are kept.
| commands | array · required | [{command, description}]; the command is lowercased and cut to 32, the description cut to 256. |
Returns: {commands: [...]} as stored.
404 Bot not found/api/v1/bots/{bot_id}/webhookSet or clear the webhook URL and its options. While a URL is set, long poll answers 409. An option left out keeps its stored value.
| url | string | Up to 512 characters, see "Webhooks". Null or omitted clears the URL, its secret, max_connections and ip_address. |
| max_connections | integer | 1-100, default 40: how many deliveries to your URL may be in flight at once. |
| allowed_updates | array | Kinds to receive: message, callback_query, my_chat_member; [] = all (the default). Applies to long poll too. An unknown kind is refused (422). |
| drop_pending_updates | boolean | Default false. True: nothing addressed to the bot before this call is served again, by webhook or long poll. |
| ip_address | string | A public IPv4/IPv6 address to deliver to instead of resolving the URL's host (the host still goes as Host and TLS name); "" clears it. |
Returns: {webhook_url, max_connections, allowed_updates, ip_address}, plus webhook_secret the first time a URL is set.
400 Webhook URL rejected: <reason> · 404 Bot not found · 422 (an option out of range)/api/v1/bots/{bot_id}/webhook/rotate-secretIssue a new webhook signing secret; the old one stops at once.
Returns: {webhook_secret} — shown once.
404 Bot not found · 409 Set a webhook URL firstCalled by the apps when a person meets a bot. A bot never calls these; they are listed so you know what happens on the person's side.
/api/v1/bots/webapp/initSigned launch data for a bot's mini app (the app calls this when a person opens one).
| bot_user_id | integer · required | The bot's account id. |
| url | string · required | The https page being opened. |
| start_param | string | A-Za-z0-9_-, at most 512. |
Returns: {init_data, url, bot}
400 (not an https url) · 403 (the person may not message the bot) · 404 Bot not found/api/v1/bots/webapp/dataA mini app sent data back; the bot gets a web_app_data update.
| bot_user_id | integer · required | The bot's account id. |
| data | string · required | 1-4096 bytes. |
| button_text | string | The label of the button that opened the app, at most 64. |
Returns: {ok: true}
400 (over 4096 bytes) · 403 · 404 Bot not found/api/v1/bots/by-username/{username}Resolve a bot for a link.
Returns: {bot_user_id, username, name, description, about, avatar_url, is_bot, can_message, commands}
404 Bot not found/api/v1/bots/peer/{peer_id}/commandsThe "/" list a person sees in their chat with the bot whose account id is peer_id.
Returns: {is_bot, commands, menu_button}; {is_bot: false, commands: []} for a person.
/api/v1/bots/group/{group_id}/commandsThe "/" lists a group member sees: every enabled bot in the group, its group-scope commands resolved for the caller (admin scopes only for owners and admins).
Returns: {bots: [{bot_user_id, username, commands}]}; a bot with no command for this caller is left out.
404 Group not found (the caller is not a member)/api/v1/bots/callbackA person tapped a callback button; it becomes a callback_query for the bot.
| message_id | integer · required | The bot's message the button is under. |
| group_id | integer | Set when the message is a group message: any current member may tap, the update carries chat_id = the group and chat_type: "group". |
| callback_data | string · required | 1-64 bytes; must be a button on that message. |
Returns: {ok: true, callback_query_id}; while the bot's answer to this same tap is cached (cache_time) the answer is replayed over WS and the body adds cached: true — no new update reaches the bot.
400 No such button on this message · 403 This bot only accepts messages from its owner · 404 Message not found · 429 Too many button taps/api/v1/bots/share-pickA person answered a request_users / request_chat reply-keyboard button with a pick; it becomes a users_shared / chat_shared update for the bot.
| message_id | integer · required | The bot's DM message that carries the keyboard; only its recipient may answer. |
| request_id | integer · required | The button's request_id; must be a button on that message. |
| user_ids | array | 1-10 friends of the person, no more than the button allows. Send this or group_id. |
| group_id | integer | A group the person belongs to. Send this or user_ids. |
Returns: {ok: true, update_id}
400 Send either user_ids or group_id · 400 No such button on this message · 400 Too many people picked · 400 Only friends can be picked · 403 This bot only accepts messages from its owner · 404 Message not found · 404 Chat not found · 429 Too many button taps/api/v1/bots/attach-menuThe bots this person keeps in the attach menu of the composer, oldest first. A disabled or deleted bot is not listed.
Returns: [{bot_user_id, username, name, avatar_url}]
/api/v1/bots/attach-menu/{bot_user_id}Put a bot into the person's attach menu. The owner must have allowed it (attach_menu_enabled) and the person must be able to write to the bot.
Returns: {ok: true}
404 Bot not found · 403 This bot cannot be added to the attach menu · 409 The attach menu holds at most 8 bots/api/v1/bots/attach-menu/{bot_user_id}Take a bot out of the person's attach menu.
Returns: {ok: true}
/api/v1/bots/start-groupA person followed a startgroup link and picked a group: add the bot and queue a my_chat_member update.
| username | string · required | The bot's username. |
| group_id | integer · required | A group where the person may add members. |
| payload | string | 1-64 of A-Z a-z 0-9 _ -. |
Returns: {ok: true, added, group_id}
403 This bot only accepts messages from its owner · 404 Bot not found · 409 The bot could not be added to this group (<reason>)/api/v1/bots/self/get-business-connectionRead a business connection a person made with this bot: its rights and whether it is enabled. The bot learns of a connection by a business_connection update; messages of the chats the person chose arrive as business_message updates (chat_id, from_user_id, text, business_connection_id, and file for a photo or document: {file_id, name, mime, size, download_url}, fetched with the bot token). When the peer edits such a message the bot gets edited_business_message (the same fields plus edited_at); when the peer deletes it, deleted_business_messages (business_connection_id, chat_id, message_ids). Needs the can_read_messages right. The person's own messages in a covered chat arrive too, flagged is_outgoing: true. Never delivered: one-time and disappearing messages, secret chats, messages from bots, the bot's own sends, paused chats, and messages written before the connection.
| business_connection_id | string · required | The id from a business_connection update. |
Returns: {id, user_id, can_reply, can_read_messages, can_delete_messages, is_enabled, date}
401 Invalid bot token · 403 Bot owner is banned · 404 business connection not found (also for another bot's connection)/api/v1/bots/self/business/send-messageSend a text into one of the chats a person gave this bot, as that person. The peer sees an ordinary message from the person with no via mark; only the person sees the mark. Never available for secret chats.
| business_connection_id | string · required | The connection to send through. |
| chat_id | integer · required | The peer's user id; must be one of the chats the person chose. |
| text | string · required | 1-4000 characters. |
| parse_mode | string | As for sendMessage. |
Returns: {ok: true, message_id}
401 Invalid bot token · 403 Bot owner is banned · 403 business connection is disabled · 403 the can_reply right was not granted · 403 this chat was not given to the bot · 403 the owner paused the bot in this chat · 403 secret chats are never open to a bot · 404 business connection not found · 429 rate limit/api/v1/bots/self/business/delete-messagesDelete messages the person wrote in one of the chats they gave this bot, on their behalf. Needs the can_delete_messages right (off until the person grants it). Only the person's own messages of that chat can be deleted, the same as the person could do by hand; one id that is not such a message refuses the whole call and nothing is deleted. The person's own messages in the chat also reach the bot as business_message updates with is_outgoing: true (from_user_id is the person); one-time and disappearing messages and the bot's own sends are never reported.
| business_connection_id | string · required | The connection to act through. |
| chat_id | integer · required | The peer's user id; must be one of the chats the person chose. |
| message_ids | integer[] · required | 1-100 ids of the person's own messages in that chat. |
Returns: {ok: true, deleted: [message_id, ...]}
401 Invalid bot token · 403 Bot owner is banned · 403 business connection is disabled · 403 the can_delete_messages right was not granted · 403 this chat was not given to the bot · 403 the owner paused the bot in this chat · 404 business connection not found · 404 message not found (not the person's own message of this chat, or already deleted) · 429 rate limit