QivunaDevelopers

Types

The JSON objects of the Bot API. Fields marked ? are left out when empty; nothing is ever sent as null unless the field says so.

All ids are JSON integers below 253, so they are exact in JavaScript. Store them as 64-bit integers.

Update · BotInfo · User · Chat · Message · MessageEntity · InlineKeyboardMarkup · InlineKeyboardButton · CallbackQuery · ChatMemberUpdated · ChatMember · ChatRights · BotCommand · BotCommandScope · BotStarted · File · ChatInviteLink · WebhookInfo · EncryptedMessage · EncryptionKeyInfo

Update#

One update. Exactly one of the optional fields is present.

FieldTypeDescription
update_idIntegerIncreases per bot. Acknowledge with getUpdates(offset = update_id + 1). With webhooks, de-duplicate on it.
message?MessageA message in a private chat or a group (privacy rules apply).
edited_message?MessageAn edited message the bot would receive now. Edits of encrypted rows are never delivered.
channel_post?MessageA post in a channel the bot was added to.
edited_channel_post?MessageAn edited channel post.
callback_query?CallbackQueryA press of one of the bot's buttons.
my_chat_member?ChatMemberUpdatedThe bot was added, its rights changed, it was removed, suspended when a group became encrypted, attached or detached.
chat_member?ChatMemberUpdatedA member joined, left, was banned, muted or unmuted. Opt-in, groups only (see Updates).
bot_started?BotStartedA person pressed Start.
bot_blocked?BotStartedA person stopped or blocked the bot (no start_param).
encrypted_message?EncryptedMessageAn end-to-end encrypted message or press for an encrypted bot.

BotInfo#

The result of getMe.

FieldTypeDescription
idIntegerThe bot number.
is_botBooleanAlways true.
first_nameStringDisplay name.
usernameStringHandle, ends in bot.
can_join_groupsBoolean
can_join_channelsBoolean
privacy_modeBooleantrue: in groups the bot sees only commands, mentions and replies to it.
e2ee_modeStringplain or encrypted.
api_versionString"1.0".
statusStringdevelopment, active, restricted, …
tierStringnew, standard or verified.

User#

A person or a bot. People's ids are pseudonymous: different for every bot owner (see Concepts).

FieldTypeDescription
idIntegerA person: a large positive integer below 253. A bot: its bot number.
is_botBoolean
first_nameStringThe person's name, as other members of a shared room see it; "Qivuna user" when blank.
last_name?String
username?StringOnly if the person lets others find them by username.
e2ee_key?StringEncrypted updates only: the person's public key for this bot's namespace (base64 X25519). The SDKs pin it.

Chat#

FieldTypeDescription
idIntegerPrivate chat: the person's id. Group or channel: a negative integer.
typeStringprivate, group or channel.
title?StringGroups and channels.
username?StringPublic groups and channels with a handle; for a private chat the person's handle (if findable).
first_name?StringPrivate chats.
is_e2eeBooleanEnd-to-end encrypted: an encrypted bot's private chat, or an encrypted group.
description?StringgetChat only.
member_count?IntegergetChat only, groups and channels.

Message#

FieldTypeDescription
message_idIntegerPseudonymous, per bot owner.
dateIntegerUnix time.
edit_date?Integer
chatChat
from?UserAbsent for channel posts.
sender_chat?ChatChannel posts: the channel.
text?StringAbsent when the message has files (then caption) or is end-to-end encrypted (then envelope).
entities?Array of MessageEntityThe bot's own messages: the formatting it sent. People's messages: only the leading bot_command and mentions (people's rich text is not passed on).
command?Object{name, args, addressed_to_me} when a person's message starts with a command. name is lower case, args the rest of the text.
reply_to_message?MessageThe full message if this bot sent it; otherwise only {message_id}.
reply_markup?InlineKeyboardMarkupOnly on the bot's own messages, with its callback_data. Nobody else ever receives callback data.
protect_content?BooleanThe bot's own messages.
photo? / video? / document?FileThe first attachment, by its stored type. One File, not a list of sizes.
attachments?Array of ObjectWhen a person sent more than one file: every file, in order, as {type, …File}.
caption?StringText of a message with files.
caption_entities?Array of MessageEntity
envelope?StringEnd-to-end encrypted rows in an encrypted bot's private chat.

MessageEntity#

Offsets and lengths are in UTF-16 code units (as in Telegram).

FieldTypeDescription
typeStringbold, italic, underline, strikethrough, code, pre, text_link, url, mention, bot_command, spoiler.
offsetInteger≥ 0.
lengthInteger≥ 1; the entity must lie inside the text.
url?Stringtext_link: an https:// URL without user info, at most 2,048 characters.
language?Stringpre: [A-Za-z0-9_+#.-]{1,32}.

InlineKeyboardMarkup#

{"inline_keyboard": [[button, …], …]}. No other key. At most 10 rows, 8 buttons a row, 64 buttons.

FieldTypeDescription
inline_keyboardArray of Array of InlineKeyboardButton[] means no keyboard.

InlineKeyboardButton#

Exactly one of callback_data and url; any other field is refused.

FieldTypeDescription
textString1–40 characters, no control characters; invisible formatting characters are removed first.
callback_data?String1–64 bytes. Comes back in callback_query.data.
url?Stringhttps://, no user info, at most 512 characters. The app shows the registrable domain before opening it.

CallbackQuery#

FieldTypeDescription
idString26 characters. Answer it with answerCallbackQuery within 15 minutes.
fromUserWho pressed.
messageMessageThe bot's message with the keyboard.
dataStringThe button's callback_data.

ChatMemberUpdated#

Used by my_chat_member (the bot itself) and chat_member (a member).

FieldTypeDescription
chatChat
from?UserWho made the change, when known.
dateInteger
user?Userchat_member only: the member.
old_status / new_statusStringmy_chat_member: member, left, suspended_e2ee, attached, detached. chat_member: member, left, kicked, restricted.
rights?ChatRightsmy_chat_member: the rights the bot has now.
mode?Stringserver or addressed (encrypted groups).
consent_receipt_id?StringThe id (a ULID string) of the immutable consent receipt the admin's action created.
until_date?Integerchat_member, restricted: end of a timed mute.

ChatMember#

FieldTypeDescription
userUser
statusStringowner, admin, member, restricted (muted), kicked (banned), left.
until_date?IntegerA bot's timed mute.

ChatRights#

Booleans. Absent = false.

FieldTypeDescription
can_sendBooleanGroups: send text. Default on.
can_send_mediaBooleanGroups and channels: send files. Default on.
can_read_allBooleanPublic groups only, and only with the bot's privacy mode off: receive every message. Off by default; shown to admins in red.
can_delete_messagesBooleanGroups.
can_restrict_membersBooleanGroups: mute.
can_ban_membersBooleanGroups.
can_pinBooleanGroups.
can_inviteBooleanGroups and channels: create invite links.
can_postBooleanChannels: post. Default on.
can_edit_postsBooleanChannels: edit others' posts (own posts are always editable).
can_change_infoBooleanReserved: no v1 method uses it and it cannot be granted.

BotCommand#

FieldTypeDescription
commandString^[a-z0-9_]{1,32}$, without the slash.
descriptionString1–256 characters.

BotCommandScope#

FieldTypeDescription
typeStringdefault, all_private_chats, all_group_chats, all_chat_administrators or chat.
chat_id?IntegerOnly with chat: a room the bot is in, or a person who started it.

BotStarted#

bot_started and bot_blocked.

FieldTypeDescription
fromUser
chatChatThe private chat.
start_param?Stringbot_started: the start value of the link the person opened (≤ 64 of A–Z a–z 0–9 _ -).
dateInteger

File#

FieldTypeDescription
file_idString40 hex characters, valid for this bot only, at most 30 days.
file_unique_idStringStable for the same file within the bot's id namespace (shared by the bots its owner created); unlinkable across namespaces.
file_sizeIntegerBytes.
mime_type?String
file_name?String
file_path?StringgetFile only: download at /v1/file/<file_path> for 1 hour.
FieldTypeDescription
invite_linkString
expire_date?Integer
member_limit?Integer
is_revokedBoolean

WebhookInfo#

FieldTypeDescription
urlString"" when no webhook is set.
has_secretBoolean
pending_update_countInteger
max_connectionsInteger
allowed_updatesArray of StringThe effective list (the default set when none is stored).
encrypt_payloadBoolean
last_error_date? / last_error_message?Integer / StringKept after a disable, so you can see why. Our own wording; never the response body or the URL.
failing_since?IntegerWhile the webhook is enabled and failing.

EncryptedMessage#

encrypted_message: content the server cannot read.

FieldTypeDescription
message_idInteger1:1: the message's id. Encrypted groups: the id of this request (it is not a group message).
dateInteger
chatChatis_e2ee: true. Server-asserted: bind your answer to it, never authorise on it.
fromUserWith e2ee_key (the sender key the envelope opens with).
kindStringmessage or callback.
envelopeStrings2|…, sealed by the person to the bot's key. The plaintext is a QB1 request.
reply_token?StringEncrypted groups: rt1_…, 5 replies within 1 hour.
callback_query_id?StringPresses.

EncryptionKeyInfo#

FieldTypeDescription
activeObject or null{fingerprint, seq, activated_at} (unix seconds).
proposedObject or null{fingerprint, proposed_at}.
bot_idIntegerThe bot account's user id (the bot field of QB1).