// Type Benty Protocol Schema // File: protocol/benty.tb // Status: draft v0 approved product scope // Owner: Benty // Note: TB is Benty's own protocol schema format. It is not Telegram TL. protocol Benty { name = "benty" schema = "TB" schema_name = "Type Benty" current_layer = 1 min_supported_layer = 1 byte_order = "little_endian" id_width = "u32" } // ═══════════════════════════════════════════════════════════════ // Core // ═══════════════════════════════════════════════════════════════ namespace core { type BoolFalse #00000001 = {} type BoolTrue #00000002 = {} type Error #00000003 = { code: i32 message: string } type Null #00000004 = {} } // ═══════════════════════════════════════════════════════════════ // Session / layer negotiation // ═══════════════════════════════════════════════════════════════ namespace session { rpc clientHello #10000010 = { app_version: string engine_version: string platform: string device_id: string protocol_layer: i32 supported_layers: vector feature_flags: vector } -> serverHello type serverHello #20000010 = { selected_layer: i32 min_supported_layer: i32 max_supported_layer: i32 server_time: i64 feature_flags: vector } } // ═══════════════════════════════════════════════════════════════ // Auth / profile / devices / security / privacy // ═══════════════════════════════════════════════════════════════ namespace auth { rpc registerDevice #10000001 = { device_id: string platform: string push_token: optional } -> profile.User rpc getMe #10000002 = {} -> profile.User rpc listDevices #10000003 = {} -> devices.DeviceList rpc updateProfile #10000004 = { display_name: optional bio: optional avatar_media_id: optional } -> profile.User rpc requestCode #19000001 = { email: string } -> core.BoolTrue rpc verifyCode #19000002 = { email: string code: string device_id: string } -> AuthSession type AuthSession #01000003 = { account_id: i64 token: string expires_at: i64 } } namespace profile { type User #01000001 = { account_id: i64 display_name: string username: optional bio: optional avatar_url: optional premium: bool verified: bool } rpc getUser #11010010 = { account_id: i64 } -> User rpc searchUsers #17000020 = { query: string offset: i32 limit: i32 } -> UserSearchResult rpc setUsername #11010004 = { username: string } -> User rpc setBio #11010005 = { bio: string } -> User type UserSearchResult #27000020 = { users: vector } } namespace devices { type Device #01000002 = { id: i64 device_id: string platform: string name: optional last_active_at: i64 trusted: bool } type DeviceList #01000020 = { devices: vector } rpc list #11020001 = {} -> DeviceList rpc revoke #11020002 = { device_id: string } -> core.BoolTrue rpc revokeAllExceptCurrent #11020003 = {} -> core.BoolTrue rpc rename #11020004 = { device_id: string name: string } -> Device rpc setTrusted #11020005 = { device_id: string trusted: bool } -> Device } namespace security { rpc listSessions #11030001 = {} -> AuthSessionList rpc terminateSession #11030002 = { session_id: i64 } -> core.BoolTrue rpc terminateAllSessions #11030003 = {} -> core.BoolTrue rpc setPassword #11030004 = { password_hash: bytes } -> core.BoolTrue rpc changePassword #11030005 = { old_password_hash: bytes new_password_hash: bytes } -> core.BoolTrue rpc disablePassword #11030006 = {} -> core.BoolTrue rpc set2fa #11030007 = { enabled: bool } -> core.BoolTrue type AuthSessionList #11031001 = { sessions: vector } } namespace privacy { rpc getSettings #11040001 = {} -> PrivacySettings rpc setLastSeen #11040002 = { mode: PrivacyMode } -> PrivacySettings rpc setProfilePhoto #11040003 = { mode: PrivacyMode } -> PrivacySettings rpc setCalls #11040004 = { mode: PrivacyMode } -> PrivacySettings rpc setGroupInvites #11040005 = { mode: PrivacyMode } -> PrivacySettings rpc setStories #11040006 = { mode: PrivacyMode } -> PrivacySettings rpc blockUser #11040007 = { account_id: i64 } -> core.BoolTrue rpc unblockUser #11040008 = { account_id: i64 } -> core.BoolTrue rpc getBlocked #11040009 = { offset: i32 limit: i32 } -> BlockedUsers enum PrivacyMode { everyone contacts nobody custom } type PrivacySettings #11041001 = { last_seen: PrivacyMode profile_photo: PrivacyMode calls: PrivacyMode group_invites: PrivacyMode stories: PrivacyMode } type BlockedUsers #11041002 = { users: vector } } // ═══════════════════════════════════════════════════════════════ // Contacts / dialogs / archive / folders // ═══════════════════════════════════════════════════════════════ namespace contacts { type Contact #02000001 = { account_id: i64 display_name: string username: optional avatar_url: optional } rpc list #17000010 = { offset: i32 limit: i32 } -> ContactList rpc add #17000001 = { account_id: i64 message: optional } -> ContactRequest rpc accept #17000002 = { request_id: i64 } -> core.BoolTrue rpc decline #17000003 = { request_id: i64 } -> core.BoolTrue rpc delete #17000004 = { account_id: i64 } -> core.BoolTrue rpc createInvite #17000005 = { expires_at: optional max_uses: optional } -> ContactInvite rpc redeemInvite #17000006 = { code: string } -> Contact rpc importPhonebook #17000030 = { contacts: vector } -> ImportResult rpc deleteImported #17000031 = {} -> core.BoolTrue rpc getImportStatus #17000032 = {} -> ImportStatus type ContactList #28000003 = { contacts: vector } type ContactRequest #02000002 = { request_id: i64 from_account_id: i64 to_account_id: i64 message: optional } type ContactInvite #02000003 = { code: string url: string expires_at: optional } type PhonebookContact #17001001 = { phone: optional email: optional name: optional } type ImportResult #17001002 = { imported: i32 matched: i32 } type ImportStatus #17001003 = { imported_count: i32 last_import_at: optional } } namespace dialogs { type Dialog #03000001 = { dialog_id: i64 kind: DialogKind title: string avatar_url: optional last_message: optional unread_count: i32 pinned: bool muted_until: optional archived: bool } enum DialogKind { private group channel public_chat saved_messages bot } rpc getDialogs #12000001 = { offset_date: optional limit: i32 } -> DialogList rpc getHistory #12000002 = { dialog_id: i64 before_message_id: optional limit: i32 } -> messages.MessageList rpc create #18000001 = { kind: DialogKind title: optional participant_ids: vector } -> Dialog rpc delete #18000002 = { dialog_id: i64 } -> core.BoolTrue rpc list #18000003 = { offset: i32 limit: i32 } -> DialogList rpc history #18000004 = { dialog_id: i64 before_message_id: optional limit: i32 } -> messages.MessageList rpc archive #12000101 = { dialog_id: i64 } -> core.BoolTrue rpc unarchive #12000102 = { dialog_id: i64 } -> core.BoolTrue rpc mute #12000103 = { dialog_id: i64 muted_until: optional } -> core.BoolTrue rpc unmute #12000104 = { dialog_id: i64 } -> core.BoolTrue rpc pin #12000105 = { dialog_id: i64 } -> core.BoolTrue rpc unpin #12000106 = { dialog_id: i64 } -> core.BoolTrue rpc markRead #12000107 = { dialog_id: i64 max_message_id: i64 } -> core.BoolTrue rpc deleteHistory #12000108 = { dialog_id: i64 revoke: bool } -> core.BoolTrue type DialogList #28000001 = { dialogs: vector } } namespace archive { rpc addDialog #1f000001 = { dialog_id: i64 } -> core.BoolTrue rpc removeDialog #1f000002 = { dialog_id: i64 } -> core.BoolTrue rpc getDialogs #1f000003 = { offset: i32 limit: i32 } -> dialogs.DialogList rpc clearDialog #1f000004 = { dialog_id: i64 } -> core.BoolTrue rpc setAutoArchive #1f000005 = { muted: bool unknown: bool } -> ArchiveSettings rpc getSettings #1f000006 = {} -> ArchiveSettings rpc updateSettings #1f000007 = { auto_archive_muted: bool auto_archive_unknown: bool } -> ArchiveSettings type ArchiveSettings #1f010001 = { auto_archive_muted: bool auto_archive_unknown: bool } } namespace folders { rpc create #1f100001 = { title: string included_dialog_ids: vector excluded_dialog_ids: vector } -> Folder rpc edit #1f100002 = { folder_id: i64 title: optional included_dialog_ids: optional> excluded_dialog_ids: optional> } -> Folder rpc delete #1f100003 = { folder_id: i64 } -> core.BoolTrue rpc addDialog #1f100004 = { folder_id: i64 dialog_id: i64 } -> core.BoolTrue rpc removeDialog #1f100005 = { folder_id: i64 dialog_id: i64 } -> core.BoolTrue rpc reorder #1f100006 = { folder_ids: vector } -> core.BoolTrue type Folder #1f110001 = { folder_id: i64 title: string included_dialog_ids: vector excluded_dialog_ids: vector } } // ═══════════════════════════════════════════════════════════════ // Groups / channels / public chats // ═══════════════════════════════════════════════════════════════ namespace groups { rpc create #1b100001 = { title: string participant_ids: vector avatar_media_id: optional } -> Group rpc edit #1b100002 = { group_id: i64 title: optional avatar_media_id: optional } -> Group rpc addMember #1b100003 = { group_id: i64 account_id: i64 } -> core.BoolTrue rpc removeMember #1b100004 = { group_id: i64 account_id: i64 } -> core.BoolTrue rpc leave #1b100005 = { group_id: i64 } -> core.BoolTrue rpc setAdmin #1b100006 = { group_id: i64 account_id: i64 admin: bool } -> core.BoolTrue rpc setPermissions #1b100007 = { group_id: i64 account_id: i64 permissions: ChatPermissions } -> core.BoolTrue rpc getMembers #1b100008 = { group_id: i64 offset: i32 limit: i32 } -> GroupMembers rpc inviteLinkCreate #1b100009 = { group_id: i64 expires_at: optional max_uses: optional } -> invites.InviteLink rpc inviteLinkRevoke #1b10000a = { group_id: i64 invite_id: i64 } -> core.BoolTrue type Group #1b110001 = { group_id: i64 dialog_id: i64 title: string avatar_url: optional member_count: i32 } type GroupMembers #1b110002 = { members: vector } type ChatPermissions #1b110003 = { can_send_messages: bool can_send_media: bool can_invite_users: bool can_pin_messages: bool } } namespace channels { rpc create #1b000001 = { title: string username: optional description: optional avatar_media_id: optional is_public: bool } -> Channel rpc edit #1b000002 = { channel_id: i64 title: optional username: optional description: optional avatar_media_id: optional } -> Channel rpc delete #1b000003 = { channel_id: i64 } -> core.BoolTrue rpc get #1b000004 = { channel_id: i64 } -> Channel rpc getByUsername #1b000005 = { username: string } -> Channel rpc join #1b000006 = { channel_id: i64 } -> core.BoolTrue rpc leave #1b000007 = { channel_id: i64 } -> core.BoolTrue rpc subscribe #1b000008 = { channel_id: i64 } -> core.BoolTrue rpc unsubscribe #1b000009 = { channel_id: i64 } -> core.BoolTrue rpc getMembers #1b00000a = { channel_id: i64 offset: i32 limit: i32 } -> ChannelMembers rpc setAdmin #1b00000b = { channel_id: i64 account_id: i64 admin: bool } -> core.BoolTrue rpc banMember #1b00000c = { channel_id: i64 account_id: i64 reason: optional } -> core.BoolTrue rpc unbanMember #1b00000d = { channel_id: i64 account_id: i64 } -> core.BoolTrue rpc postMessage #1b00000e = { channel_id: i64 random_id: i64 content: messages.MessageContent } -> messages.MessageAck rpc editMessage #1b00000f = { channel_id: i64 message_id: i64 content: messages.MessageContent } -> messages.Message rpc deleteMessage #1b000010 = { channel_id: i64 message_id: i64 } -> core.BoolTrue rpc pinMessage #1b000011 = { channel_id: i64 message_id: i64 } -> core.BoolTrue rpc unpinMessage #1b000012 = { channel_id: i64 message_id: i64 } -> core.BoolTrue rpc getHistory #1b000013 = { channel_id: i64 before_message_id: optional limit: i32 } -> messages.MessageList rpc getStats #1b000014 = { channel_id: i64 } -> stats.ChannelStats type Channel #1b010001 = { channel_id: i64 dialog_id: i64 title: string username: optional description: optional avatar_url: optional is_public: bool subscriber_count: i32 } type ChannelMembers #1b010002 = { members: vector } } namespace publicChats { rpc create #1c000001 = { title: string username: optional description: optional avatar_media_id: optional category: optional rules: optional } -> PublicChat rpc edit #1c000002 = { chat_id: i64 title: optional username: optional description: optional avatar_media_id: optional category: optional rules: optional } -> PublicChat rpc get #1c000003 = { chat_id: i64 } -> PublicChat rpc getByUsername #1c000004 = { username: string } -> PublicChat rpc search #1c000005 = { query: string offset: i32 limit: i32 } -> PublicChatSearchResult rpc join #1c000006 = { chat_id: i64 } -> core.BoolTrue rpc leave #1c000007 = { chat_id: i64 } -> core.BoolTrue rpc getMembers #1c000008 = { chat_id: i64 offset: i32 limit: i32 } -> PublicChatMembers rpc setAdmin #1c000009 = { chat_id: i64 account_id: i64 admin: bool } -> core.BoolTrue rpc banMember #1c00000a = { chat_id: i64 account_id: i64 reason: optional } -> core.BoolTrue rpc unbanMember #1c00000b = { chat_id: i64 account_id: i64 } -> core.BoolTrue rpc setRules #1c00000c = { chat_id: i64 rules: string } -> core.BoolTrue rpc getRules #1c00000d = { chat_id: i64 } -> PublicChatRules rpc report #1c00000e = { chat_id: i64 reason: safety.ReportReason comment: optional } -> safety.ReportTicket type PublicChat #1c010001 = { chat_id: i64 dialog_id: i64 title: string username: optional description: optional category: optional rules: optional member_count: i32 } type PublicChatMembers #1c010002 = { members: vector } type PublicChatSearchResult #1c010003 = { chats: vector } type PublicChatRules #1c010004 = { chat_id: i64 rules: string } } // ═══════════════════════════════════════════════════════════════ // Messages / media / files // ═══════════════════════════════════════════════════════════════ namespace messages { type Message #03000002 = { id: i64 dialog_id: i64 sender_id: i64 date: i64 content: MessageContent outgoing: bool edited_at: optional } union MessageContent { text = TextContent photo = PhotoContent video = VideoContent videoNote = VideoNoteContent voice = VoiceContent file = FileContent sticker = StickerContent gif = GifContent poll = PollContent location = LocationContent contact = ContactContent service = ServiceContent } type TextContent #03001001 = { text: string } type PhotoContent #03001002 = { media_id: string caption: optional } type VideoContent #03001003 = { media_id: string caption: optional duration_sec: i32 } type VideoNoteContent #03001004 = { media_id: string duration_sec: i32 } type VoiceContent #03001005 = { media_id: string duration_sec: i32 waveform: optional } type FileContent #03001006 = { file_id: string file_name: string size: i64 } type StickerContent #03001007 = { sticker_id: i64 } type GifContent #03001008 = { media_id: string } type PollContent #03001009 = { poll_id: i64 } type LocationContent #0300100a = { latitude: f64 longitude: f64 live_period_sec: optional } type ContactContent #0300100b = { account_id: optional phone: optional name: string } type ServiceContent #0300100c = { action: string value: optional } rpc sendEncrypted #12000003 = { dialog_id: i64 random_id: i64 encrypted_payload: bytes } -> MessageAck rpc sendCloud #12000004 = { dialog_id: i64 local_id: string random_id: i64 content: MessageContent } -> MessageAck rpc setActivity #12000005 = { dialog_id: i64 activity: string } -> core.BoolTrue rpc delete #12000006 = { dialog_id: i64 message_ids: vector revoke: bool } -> core.BoolTrue rpc toggleReaction #12000007 = { dialog_id: i64 message_id: i64 reaction: string } -> core.BoolTrue rpc deliveryAck #12000010 = { dialog_id: i64 message_ids: vector } -> core.BoolTrue rpc readAck #12000011 = { dialog_id: i64 max_message_id: i64 } -> core.BoolTrue rpc edit #12000012 = { dialog_id: i64 message_id: i64 content: MessageContent } -> Message rpc sendVideoNote #12000013 = { dialog_id: i64 local_id: string random_id: i64 media_id: string duration_sec: i32 } -> MessageAck rpc sendSticker #12000014 = { dialog_id: i64 local_id: string random_id: i64 sticker_id: i64 } -> MessageAck rpc sendVoice #12000015 = { dialog_id: i64 local_id: string random_id: i64 media_id: string duration_sec: i32 waveform: optional } -> MessageAck rpc sendLocation #12000016 = { dialog_id: i64 local_id: string random_id: i64 latitude: f64 longitude: f64 } -> MessageAck rpc sendLiveLocation #12000017 = { dialog_id: i64 local_id: string random_id: i64 latitude: f64 longitude: f64 live_period_sec: i32 } -> MessageAck rpc stopLiveLocation #12000018 = { dialog_id: i64 message_id: i64 } -> core.BoolTrue type MessageAck #03000004 = { local_id: string random_id: i64 message_id: i64 server_date: i64 } type MessageList #03000020 = { messages: vector has_more: bool } } namespace media { type Media #03000003 = { id: string kind: MediaKind mime: string size: i64 width: optional height: optional duration_sec: optional thumbnail: optional } enum MediaKind { photo video video_note voice gif document sticker_thumbnail } rpc upload #15000001 = { local_id: string mime: string bytes: bytes } -> UploadAck rpc uploadStart #15000010 = { local_id: string mime: string file_name: string total_size: i64 sha256: optional } -> UploadSession rpc uploadChunk #15000011 = { upload_id: string part_index: i32 bytes: bytes } -> UploadPartAck rpc uploadFinish #15000012 = { upload_id: string } -> Media rpc download #15000003 = { media_id: string offset: i64 limit: i32 } -> FileChunk rpc uploadVideoNote #15000020 = { local_id: string mime: string total_size: i64 duration_sec: i32 } -> UploadSession rpc uploadVoice #15000021 = { local_id: string mime: string total_size: i64 duration_sec: i32 waveform: optional } -> UploadSession type UploadAck #15000002 = { media_id: string } type UploadSession #25000010 = { upload_id: string part_size: i32 total_parts: i32 } type UploadPartAck #25000011 = { upload_id: string part_index: i32 received: bool } type FileChunk #25000003 = { media_id: string offset: i64 bytes: bytes complete: bool } } namespace files { rpc uploadStart #15010001 = { local_id: string file_name: string mime: string total_size: i64 sha256: optional } -> FileUploadSession rpc uploadPart #15010002 = { upload_id: string part_index: i32 bytes: bytes } -> FileUploadPartAck rpc uploadFinish #15010003 = { upload_id: string } -> File rpc download #15010004 = { file_id: string offset: i64 limit: i32 } -> FileChunk rpc getMetadata #15010005 = { file_id: string } -> File rpc delete #15010006 = { file_id: string } -> core.BoolTrue type File #15011001 = { file_id: string file_name: string mime: string size: i64 sha256: optional } type FileUploadSession #15011002 = { upload_id: string part_size: i32 total_parts: i32 } type FileUploadPartAck #15011003 = { upload_id: string part_index: i32 received: bool } type FileChunk #15011004 = { file_id: string offset: i64 bytes: bytes complete: bool } } // ═══════════════════════════════════════════════════════════════ // Stories / calls // ═══════════════════════════════════════════════════════════════ namespace stories { rpc create #1a000001 = { media_id: string caption: optional duration_sec: i32 privacy: StoryPrivacy } -> Story rpc delete #1a000002 = { story_id: i64 } -> core.BoolTrue rpc get #1a000003 = { story_id: i64 } -> Story rpc getArchive #1a000004 = { offset_id: optional limit: i32 } -> StoryFeed rpc getFeed #1a000005 = { offset_id: optional limit: i32 } -> StoryFeed rpc markViewed #1a000006 = { story_id: i64 } -> core.BoolTrue rpc getViewers #1a000007 = { story_id: i64 offset_id: optional limit: i32 } -> StoryViewers rpc react #1a000008 = { story_id: i64 reaction: string } -> core.BoolTrue rpc reply #1a000009 = { story_id: i64 text: string } -> messages.MessageAck rpc setPrivacy #1a00000a = { story_id: i64 privacy: StoryPrivacy } -> Story enum StoryPrivacy { everyone contacts close_friends custom } type Story #1a010001 = { story_id: i64 author_id: i64 media_id: string caption: optional created_at: i64 expires_at: i64 views_count: i32 } type StoryFeed #1a010002 = { stories: vector has_more: bool } type StoryViewers #1a010003 = { users: vector has_more: bool } } namespace calls { rpc start #1e000001 = { peer_id: i64 dialog_id: optional call_type: CallType random_id: i64 } -> CallSession rpc accept #1e000002 = { call_id: i64 } -> CallSession rpc decline #1e000003 = { call_id: i64 reason: string } -> core.BoolTrue rpc end #1e000004 = { call_id: i64 duration_sec: i32 } -> core.BoolTrue rpc getActive #1e000005 = {} -> ActiveCalls rpc getHistory #1e000006 = { offset: i32 limit: i32 } -> CallHistory rpc rate #1e000007 = { call_id: i64 rating: i32 comment: optional } -> core.BoolTrue rpc reportProblem #1e000008 = { call_id: i64 reason: string debug_info: optional } -> core.BoolTrue enum CallType { voice video group_voice group_video } type CallSession #1e100001 = { call_id: i64 peer_id: i64 dialog_id: optional call_type: CallType status: string created_at: i64 started_at: optional ended_at: optional } type ActiveCalls #1e100002 = { calls: vector } type CallHistory #1e100003 = { calls: vector has_more: bool } } namespace callSignaling { rpc sendOffer #1e000020 = { call_id: i64 sdp: string } -> core.BoolTrue rpc sendAnswer #1e000021 = { call_id: i64 sdp: string } -> core.BoolTrue rpc sendIceCandidate #1e000022 = { call_id: i64 candidate: string sdp_mid: optional sdp_mline_index: optional } -> core.BoolTrue rpc updateNetworkState #1e000023 = { call_id: i64 state: string } -> core.BoolTrue } // ═══════════════════════════════════════════════════════════════ // Stickers / emoji / reactions / polls // ═══════════════════════════════════════════════════════════════ namespace stickers { rpc createSet #1d000001 = { title: string short_name: string stickers: vector } -> StickerSet rpc editSet #1d000002 = { set_id: i64 title: optional short_name: optional } -> StickerSet rpc deleteSet #1d000003 = { set_id: i64 } -> core.BoolTrue rpc getSet #1d000004 = { set_id: i64 } -> StickerSet rpc getByShortName #1d000005 = { short_name: string } -> StickerSet rpc addToSet #1d000006 = { set_id: i64 sticker: StickerInput } -> StickerSet rpc removeFromSet #1d000007 = { set_id: i64 sticker_id: i64 } -> StickerSet rpc installSet #1d000008 = { set_id: i64 } -> core.BoolTrue rpc uninstallSet #1d000009 = { set_id: i64 } -> core.BoolTrue rpc getInstalled #1d00000a = {} -> StickerSetList rpc search #1d00000b = { query: string limit: i32 } -> StickerSearchResult rpc getTrending #1d00000c = { offset: i32 limit: i32 } -> StickerSetList type StickerInput #1d010001 = { media_id: string emoji: string } type Sticker #1d010002 = { sticker_id: i64 media_id: string emoji: string } type StickerSet #1d010003 = { set_id: i64 title: string short_name: string stickers: vector installed: bool } type StickerSetList #1d010004 = { sets: vector } type StickerSearchResult #1d010005 = { stickers: vector sets: vector } } namespace emoji { rpc getPacks #1d100001 = {} -> EmojiPackList rpc installPack #1d100002 = { pack_id: i64 } -> core.BoolTrue rpc uninstallPack #1d100003 = { pack_id: i64 } -> core.BoolTrue rpc search #1d100004 = { query: string limit: i32 } -> EmojiSearchResult rpc getByShortcode #1d100005 = { shortcode: string } -> Emoji type Emoji #1d110001 = { emoji_id: i64 shortcode: string media_id: optional unicode: optional } type EmojiPack #1d110002 = { pack_id: i64 title: string emojis: vector } type EmojiPackList #1d110003 = { packs: vector } type EmojiSearchResult #1d110004 = { emojis: vector } } namespace reactions { rpc getAvailable #1d200001 = {} -> ReactionList rpc set #1d200002 = { dialog_id: i64 message_id: i64 reaction: string } -> core.BoolTrue rpc remove #1d200003 = { dialog_id: i64 message_id: i64 reaction: string } -> core.BoolTrue rpc getMessageReactions #1d200004 = { dialog_id: i64 message_id: i64 } -> MessageReactions rpc getTop #1d200005 = {} -> ReactionList type ReactionList #1d210001 = { reactions: vector } type MessageReactions #1d210002 = { reactions: vector } type ReactionCount #1d210003 = { reaction: string count: i32 selected: bool } } namespace polls { rpc create #1d300001 = { dialog_id: i64 question: string options: vector multiple_choice: bool anonymous: bool } -> Poll rpc vote #1d300002 = { poll_id: i64 option_ids: vector } -> Poll rpc close #1d300003 = { poll_id: i64 } -> Poll rpc getResults #1d300004 = { poll_id: i64 } -> PollResults type Poll #1d310001 = { poll_id: i64 question: string options: vector closed: bool } type PollOption #1d310002 = { option_id: i32 text: string votes: i32 selected: bool } type PollResults #1d310003 = { poll: Poll total_votes: i32 } } // ═══════════════════════════════════════════════════════════════ // Search / notifications / payments / premium / bots // ═══════════════════════════════════════════════════════════════ namespace search { rpc messages #1d400001 = { query: string dialog_id: optional offset: i32 limit: i32 } -> messages.MessageList rpc dialogs #1d400002 = { query: string offset: i32 limit: i32 } -> dialogs.DialogList rpc publicChats #1d400003 = { query: string offset: i32 limit: i32 } -> publicChats.PublicChatSearchResult rpc channels #1d400004 = { query: string offset: i32 limit: i32 } -> ChannelSearchResult rpc users #1d400005 = { query: string offset: i32 limit: i32 } -> profile.UserSearchResult rpc media #1d400006 = { query: string dialog_id: optional offset: i32 limit: i32 } -> MediaSearchResult rpc hashtags #1d400007 = { query: string offset: i32 limit: i32 } -> HashtagSearchResult type ChannelSearchResult #1d410001 = { channels: vector } type MediaSearchResult #1d410002 = { media: vector } type HashtagSearchResult #1d410003 = { tags: vector } } namespace notifications { rpc registerPush #1d500001 = { platform: string token: string device_id: string } -> core.BoolTrue rpc unregisterPush #1d500002 = { device_id: string } -> core.BoolTrue rpc setSettings #1d500003 = { settings: NotificationSettings } -> NotificationSettings rpc getSettings #1d500004 = {} -> NotificationSettings rpc muteDialog #1d500005 = { dialog_id: i64 muted_until: optional } -> core.BoolTrue rpc unmuteDialog #1d500006 = { dialog_id: i64 } -> core.BoolTrue type NotificationSettings #1d510001 = { enabled: bool message_preview: bool sound: bool } } namespace payments { rpc getBalance #20010001 = {} -> Balance rpc createInvoice #20010002 = { product_id: string amount: i64 currency: string } -> Invoice rpc payInvoice #20010003 = { invoice_id: i64 payment_token: string } -> PaymentResult rpc getHistory #20010004 = { offset: i32 limit: i32 } -> PaymentHistory rpc transfer #20010005 = { to_account_id: i64 amount: i64 currency: string comment: optional } -> PaymentResult rpc refund #20010006 = { payment_id: i64 reason: optional } -> PaymentResult rpc getProducts #20010007 = {} -> ProductList type Balance #20011001 = { amount: i64 currency: string } type Invoice #20011002 = { invoice_id: i64 product_id: string amount: i64 currency: string status: string } type PaymentResult #20011003 = { payment_id: i64 status: string } type PaymentHistory #20011004 = { items: vector has_more: bool } type Product #20011005 = { product_id: string title: string amount: i64 currency: string } type ProductList #20011006 = { products: vector } } namespace premium { rpc getStatus #20000001 = {} -> PremiumStatus rpc getPlans #20000002 = { platform: string } -> PremiumPlans rpc subscribe #20000006 = { plan_id: string platform: string } -> PremiumStatus rpc cancel #20000007 = {} -> PremiumStatus rpc gift #20000008 = { to_account_id: i64 plan_id: string } -> PremiumStatus rpc validateReceiptIos #20000003 = { transaction_id: string receipt_data: string } -> PremiumStatus rpc validateReceiptAndroid #20000004 = { package_name: string product_id: string purchase_token: string } -> PremiumStatus rpc getFeatureLimits #20000005 = {} -> PremiumFeatureLimits type PremiumStatus #20001001 = { active: bool plan_id: optional expires_at: optional } type PremiumPlan #20001002 = { plan_id: string title: string price: string platform_product_id: optional } type PremiumPlans #20001003 = { plans: vector } type PremiumFeatureLimits #20001004 = { max_upload_size: i64 max_folders: i32 max_pinned_dialogs: i32 } } namespace bots { rpc create #21010001 = { name: string username: string description: optional avatar_media_id: optional } -> Bot rpc edit #21010002 = { bot_id: i64 name: optional description: optional avatar_media_id: optional } -> Bot rpc delete #21010003 = { bot_id: i64 } -> core.BoolTrue rpc get #21010004 = { bot_id: i64 } -> Bot rpc getByUsername #21010005 = { username: string } -> Bot rpc setCommands #21010006 = { bot_id: i64 commands: vector } -> core.BoolTrue rpc getCommands #21010007 = { bot_id: i64 } -> BotCommandList rpc sendCommand #21010008 = { bot_id: i64 dialog_id: i64 command: string payload: optional } -> messages.MessageAck rpc setWebhook #21010009 = { bot_id: i64 url: string secret: optional } -> core.BoolTrue rpc deleteWebhook #2101000a = { bot_id: i64 } -> core.BoolTrue rpc getUpdates #2101000b = { bot_id: i64 offset: i32 limit: i32 } -> BotUpdateList rpc authorizeInline #2101000c = { bot_id: i64 query: string } -> core.BoolTrue rpc sendInlineResult #2101000d = { bot_id: i64 dialog_id: i64 result_id: string } -> messages.MessageAck rpc report #2101000e = { bot_id: i64 reason: safety.ReportReason comment: optional } -> safety.ReportTicket type Bot #21011001 = { bot_id: i64 account_id: i64 name: string username: string description: optional avatar_url: optional } type BotCommand #21011002 = { command: string description: string } type BotCommandList #21011003 = { commands: vector } type BotUpdate #21011004 = { update_id: i64 payload: bytes } type BotUpdateList #21011005 = { updates: vector } } // ═══════════════════════════════════════════════════════════════ // Safety / moderation / legal / app config // ═══════════════════════════════════════════════════════════════ namespace safety { enum ReportReason { spam violence adult_content child_safety scam illegal_content harassment other } rpc reportUser #22000001 = { account_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc reportMessage #22000002 = { dialog_id: i64 message_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc reportStory #22000003 = { story_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc reportChannel #22000004 = { channel_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc reportPublicChat #22000005 = { chat_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc reportBot #22000006 = { bot_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc reportStickerSet #22000007 = { set_id: i64 reason: ReportReason comment: optional } -> ReportTicket rpc blockUser #22000008 = { account_id: i64 } -> core.BoolTrue rpc unblockUser #22000009 = { account_id: i64 } -> core.BoolTrue rpc getBlocked #2200000a = { offset: i32 limit: i32 } -> privacy.BlockedUsers rpc getContentPolicy #2200000b = { locale: string } -> ContentPolicy rpc appealModeration #2200000c = { ticket_id: i64 comment: string } -> ReportTicket type ReportTicket #22001001 = { ticket_id: i64 status: string created_at: i64 } type ContentPolicy #22001002 = { version: string text: string } } namespace moderation { rpc deleteMessage #22010001 = { dialog_id: i64 message_id: i64 reason: optional } -> core.BoolTrue rpc deleteStory #22010002 = { story_id: i64 reason: optional } -> core.BoolTrue rpc banUser #22010003 = { scope: string scope_id: i64 account_id: i64 reason: optional } -> core.BoolTrue rpc unbanUser #22010004 = { scope: string scope_id: i64 account_id: i64 } -> core.BoolTrue rpc muteUser #22010005 = { scope: string scope_id: i64 account_id: i64 until: optional } -> core.BoolTrue rpc unmuteUser #22010006 = { scope: string scope_id: i64 account_id: i64 } -> core.BoolTrue rpc setSlowmode #22010007 = { scope: string scope_id: i64 seconds: i32 } -> core.BoolTrue rpc setPublicChatRules #22010008 = { chat_id: i64 rules: string } -> core.BoolTrue rpc getAuditLog #22010009 = { scope: string scope_id: i64 offset: i32 limit: i32 } -> AuditLog rpc reviewReport #2201000a = { ticket_id: i64 } -> safety.ReportTicket rpc resolveReport #2201000b = { ticket_id: i64 resolution: string } -> safety.ReportTicket type AuditLog #22011001 = { events: vector has_more: bool } type AuditEvent #22011002 = { event_id: i64 actor_id: i64 action: string created_at: i64 } } namespace legal { rpc getTerms #23000001 = { locale: string } -> LegalDocument rpc acceptTerms #23000002 = { version: string } -> core.BoolTrue rpc getPrivacyPolicy #23000003 = { locale: string } -> LegalDocument rpc acceptPrivacyPolicy #23000004 = { version: string } -> core.BoolTrue rpc getAgeGate #23000005 = { locale: string } -> AgeGate rpc confirmAge #23000006 = { age_confirmed: bool } -> core.BoolTrue type LegalDocument #23001001 = { version: string locale: string text: string url: optional } type AgeGate #23001002 = { min_age: i32 text: string } } namespace appConfig { rpc get #24000001 = { platform: string app_version: string locale: string } -> AppConfig rpc getCapabilities #24000002 = { platform: string app_version: string } -> AppCapabilities rpc setReviewMode #24000003 = { enabled: bool reason: optional } -> AppConfig type AppConfig #24010001 = { review_mode: bool bots_enabled: bool public_chats_enabled: bool channels_enabled: bool premium_enabled: bool external_payments_enabled: bool nsfw_allowed: bool max_upload_size: i64 } type AppCapabilities #24010002 = { features: vector } } // ═══════════════════════════════════════════════════════════════ // Stats / admin log / banners / saved messages / presence / activity // ═══════════════════════════════════════════════════════════════ namespace stats { rpc getChannel #24020001 = { channel_id: i64 } -> ChannelStats rpc getPublicChat #24020002 = { chat_id: i64 } -> PublicChatStats rpc getPost #24020003 = { channel_id: i64 message_id: i64 } -> PostStats rpc getStory #24020004 = { story_id: i64 } -> StoryStats type ChannelStats #24021001 = { subscribers: i32 views: i64 posts: i32 } type PublicChatStats #24021002 = { members: i32 messages: i64 active_users: i32 } type PostStats #24021003 = { views: i64 reactions: i32 shares: i32 } type StoryStats #24021004 = { views: i32 reactions: i32 replies: i32 } } namespace adminLog { rpc get #24030001 = { scope: string scope_id: i64 offset: i32 limit: i32 } -> moderation.AuditLog rpc search #24030002 = { scope: string scope_id: i64 query: string offset: i32 limit: i32 } -> moderation.AuditLog } namespace banners { type Banner #30000021 = { id: string placement: string title: string icon: string text: string priority: i32 expires_at: optional action: optional } type BannerAction #30000022 = { kind: string value: string } type BannerList #30000023 = { banners: vector } rpc get #31000001 = { placement: string } -> BannerList rpc dismiss #31000002 = { banner_id: string } -> core.BoolTrue rpc track #31000003 = { banner_id: string event: string } -> core.BoolTrue } namespace savedMessages { rpc get #24040001 = { before_message_id: optional limit: i32 } -> messages.MessageList rpc send #24040002 = { local_id: string random_id: i64 content: messages.MessageContent } -> messages.MessageAck rpc delete #24040003 = { message_ids: vector } -> core.BoolTrue } namespace presence { rpc setStatus #24050001 = { status: PresenceStatus } -> core.BoolTrue rpc getStatus #24050002 = { account_id: i64 } -> Presence rpc subscribe #24050003 = { account_ids: vector } -> core.BoolTrue rpc unsubscribe #24050004 = { account_ids: vector } -> core.BoolTrue enum PresenceStatus { online offline invisible } type Presence #24051001 = { account_id: i64 status: PresenceStatus last_seen_at: optional } } namespace activity { rpc setTyping #24060001 = { dialog_id: i64 } -> core.BoolTrue rpc setRecordingVoice #24060002 = { dialog_id: i64 } -> core.BoolTrue rpc setRecordingVideoNote #24060003 = { dialog_id: i64 } -> core.BoolTrue rpc clear #24060004 = { dialog_id: i64 } -> core.BoolTrue } // ═══════════════════════════════════════════════════════════════ // Updates // ═══════════════════════════════════════════════════════════════ namespace updates { type State #04000001 = { seq: i64 date: i64 dialogs: vector } type DialogState #04000010 = { dialog_id: i64 pts: i64 last_message_id: i64 } type Difference #04000005 = { new_state: State updates: vector has_more: bool } type UpdateEnvelope #21000000 = { update_id: i64 seq: i64 dialog_id: optional pts: optional pts_count: optional date: i64 payload: Update } rpc getState #13000001 = {} -> State rpc getDifference #13000002 = { seq: i64 dialog_states: vector } -> Difference union Update { newMessage = UpdateNewMessage messageRead = UpdateMessageRead messageDelivered = UpdateMessageDelivered presence = UpdatePresence user = UpdateUser messageEdited = UpdateMessageEdited messagesDeleted = UpdateMessagesDeleted typing = UpdateTyping newStory = UpdateNewStory storyDeleted = UpdateStoryDeleted storyViewed = UpdateStoryViewed storyReaction = UpdateStoryReaction channelCreated = UpdateChannelCreated channelUpdated = UpdateChannelUpdated channelNewPost = UpdateChannelNewPost channelMessageEdited = UpdateChannelMessageEdited channelMessageDeleted = UpdateChannelMessageDeleted channelMemberJoined = UpdateChannelMemberJoined channelMemberLeft = UpdateChannelMemberLeft publicChatUpdated = UpdatePublicChatUpdated publicChatMemberJoined = UpdatePublicChatMemberJoined publicChatMemberLeft = UpdatePublicChatMemberLeft stickerSetUpdated = UpdateStickerSetUpdated stickerSetInstalled = UpdateStickerSetInstalled stickerSetUninstalled = UpdateStickerSetUninstalled callIncoming = UpdateCallIncoming callAccepted = UpdateCallAccepted callDeclined = UpdateCallDeclined callEnded = UpdateCallEnded callSignaling = UpdateCallSignaling callParticipantJoined = UpdateCallParticipantJoined callParticipantLeft = UpdateCallParticipantLeft } type UpdateNewMessage #21000001 = { message: messages.Message } type UpdateMessageRead #21000002 = { dialog_id: i64 account_id: i64 max_message_id: i64 } type UpdateMessageDelivered #21000003 = { dialog_id: i64 account_id: i64 message_ids: vector } type UpdatePresence #21000004 = { presence: presence.Presence } type UpdateUser #21000010 = { user: profile.User } type UpdateMessageEdited #21000011 = { message: messages.Message } type UpdateMessagesDeleted #21000012 = { dialog_id: i64 message_ids: vector } type UpdateTyping #21000013 = { dialog_id: i64 account_id: i64 action: string } type UpdateNewStory #21000030 = { story: stories.Story } type UpdateStoryDeleted #21000031 = { story_id: i64 } type UpdateStoryViewed #21000032 = { story_id: i64 account_id: i64 } type UpdateStoryReaction #21000033 = { story_id: i64 account_id: i64 reaction: string } type UpdateChannelCreated #21000040 = { channel: channels.Channel } type UpdateChannelUpdated #21000041 = { channel: channels.Channel } type UpdateChannelNewPost #21000042 = { channel_id: i64 message: messages.Message } type UpdateChannelMessageEdited #21000043 = { channel_id: i64 message: messages.Message } type UpdateChannelMessageDeleted #21000044 = { channel_id: i64 message_id: i64 } type UpdateChannelMemberJoined #21000045 = { channel_id: i64 account_id: i64 } type UpdateChannelMemberLeft #21000046 = { channel_id: i64 account_id: i64 } type UpdatePublicChatUpdated #21000050 = { chat: publicChats.PublicChat } type UpdatePublicChatMemberJoined #21000051 = { chat_id: i64 account_id: i64 } type UpdatePublicChatMemberLeft #21000052 = { chat_id: i64 account_id: i64 } type UpdateStickerSetUpdated #21000060 = { set_id: i64 } type UpdateStickerSetInstalled #21000061 = { set_id: i64 } type UpdateStickerSetUninstalled #21000062 = { set_id: i64 } type UpdateCallIncoming #21000070 = { call: calls.CallSession } type UpdateCallAccepted #21000071 = { call_id: i64 account_id: i64 } type UpdateCallDeclined #21000072 = { call_id: i64 account_id: i64 reason: string } type UpdateCallEnded #21000073 = { call_id: i64 duration_sec: i32 } type UpdateCallSignaling #21000074 = { call_id: i64 from_account_id: i64 payload_type: string payload: string } type UpdateCallParticipantJoined #21000075 = { call_id: i64 account_id: i64 } type UpdateCallParticipantLeft #21000076 = { call_id: i64 account_id: i64 } } // ═══════════════════════════════════════════════════════════════ // Reserved / deprecated IDs // ═══════════════════════════════════════════════════════════════ reserved { // Current production conflict in legacy backend: keep sendCloud on this ID, // do not reuse for markRead. Mark-read moves to readAck/dialogs.markRead. #12000004 = messages.sendCloud deprecated #12000004 messages.markRead { replaced_by = messages.readAck #12000011 reason = "conflicted with messages.sendCloud" } // Legacy collisions from src/codec.rs. These IDs must be normalized in generated TB outputs. deprecated #11000001 engine.registerDevice { replaced_by = auth.registerDevice #10000001 reason = "conflicted with contacts.list" } deprecated #11000002 engine.updateProfile { replaced_by = auth.updateProfile #10000004 reason = "conflicted with contacts.search" } deprecated #11000003 engine.registerPush { replaced_by = notifications.registerPush #1d500001 reason = "conflicted with contacts.requests" } deprecated #11000004 engine.setUsername { replaced_by = profile.setUsername #11010004 reason = "conflicted with contacts.createRequest" } deprecated #11000005 engine.setBio { replaced_by = profile.setBio #11010005 reason = "conflicted with contacts.acceptRequest" } deprecated #11000010 engine.getUser { replaced_by = profile.getUser #11010010 reason = "conflicted with messageAck constructor" } deprecated #18000001 engine.dialogCreateResponse { replaced_by = dialogs.create #18000001 reason = "constructor/method naming collision; keep namespace ownership explicit" } } // ═══════════════════════════════════════════════════════════════ // Future reserved blocks // ═══════════════════════════════════════════════════════════════ future e2ee_reserved { status = "reserved_not_active" reason = "Deferred: multi-device keys, recovery, moderation, compliance, bots/public chats complexity." } future username_marketplace_reserved { status = "reserved_not_active" reason = "Potential monetization/app-review risk; reserve only." } future advanced_crypto_backup_reserved { status = "reserved_not_active" reason = "Deferred until security model is approved." }