Developer docs
19. Disappearing and protected content
On this page
Three features with Telegram semantics, plus capture protection in the clients. What the server enforces is marked server; the rest is up to clients and is a deterrent, not a guarantee (SECURITY.md §9).
19.1 Self-destructing media (Message.self_destruct)
- Sent with
SendMessageRequest.self_destruct:view_once, orseconds1..60 (the app offers view once, 3, 5, 10, 15, 30, 60 s). Photo, video, voice and video note only; private chats with a person only (not groups/channels — like Telegram — not Saved Messages, not bots), single item (not inSendAlbum), not scheduled, not by bots. Violations: 400TTL_MEDIA_INVALID. server - Every copy the server hands out — history, events,
GetDifference, search, push, the sender’s ownSendMessageresponse — carries a placeholder: the media kind, dimensions and duration, no file refs, thumbnails, waveform or caption. server - The recipient calls
MessagesService/OpenSelfDestructMediato get the real media and caption (only in that response; clients keep it in memory, never in their store). The first open setsopened_atand starts the countdown:expires_at = opened_at + max(seconds, duration); view once:opened_at + duration + 60 sas a cap for a viewer that never closes. Both sides get anedit_messageevent (unchangededit_date) with the newself_destruct, so the sender sees “opened” and the countdown. Re-opening is allowed until it expires (crash/restart). The sender gets 403TTL_MEDIA_SENDER. CloseSelfDestructMediadeletes view-once media at once (deleted = true); timed media keeps counting down.- Unopened maximum: 7 days after sending (
expires_atof an unopened item). Telegram documents no limit for cloud chats; we bound it so unopened media doesn’t live forever. - Deletion is “delete for everyone” (one
delete_messagesevent to both sides) by the expiry job (§19.4); the files of the message — every photo size, the video/voice file and its thumbnail — are deleted from blob storage right away, without the usual GC grace period. Self-destructing videos get no server renditions (no transcode job), and the uploaded full-size original of a photo is released for the next GC run. server - Not forwardable/copyable (400
CHAT_FORWARDS_RESTRICTED), not editable (400MESSAGE_EDIT_FORBIDDEN), never indexed for search and not listed in shared-media filters (media_kindis stored as “none”). Push notifications say “🔥 Photo” etc.: no caption, no thumbnail. Replies are allowed; clients render the quoted media as a label. server MessagesService/SendScreenshotNotification(chat_id, reply_to_id)posts the Telegram “X took a screenshot!” service message (ServiceAction.screenshot_taken) in a private chat. Clients send it when the OS reports a screenshot of self-destructing media.
19.2 Chat auto-delete timer (Chat.ttl_period, Message.ttl_period)
ChatsService/SetHistoryTtl(chat_id, period): 0 = off, else 60 s .. 365 days (400TTL_PERIOD_INVALID). Private chats: either side; groups and channels: admins withdelete_messages(403CHAT_ADMIN_REQUIRED); Saved Messages: 400CHAT_TYPE_INVALID. A change postsServiceAction.history_ttl_changed{period, prev_period}and achat_updatedevent.- Applies to messages sent afterwards (like Telegram): each new message gets
ttl_period= the chat’s timer and is deleted for everyone atdate + ttl_period. The timer’s own service message doesn’t expire. - Default for new chats:
ChatsService/Get|SetDefaultHistoryTtl(Telegramaccount.setDefaultHistoryTTL), synced to my devices viaUserEvent.default_history_ttl. It applies to groups and channels I create (announced right after creation withhistory_ttl_changed{from_default}) and to private chats I start (announced before the first message). Chats someone else started keep their own timer. - The app offers Off / 1 day / 1 week / 1 month (31 days) / other (2–6 days, 2–3 weeks, 2, 3, 6 months, 1 year).
19.3 Restrict saving content (Chat.noforwards, Message.noforwards)
ChatsService/ToggleNoForwards(chat_id, enabled): groups and channels, admins withchange_info(Telegrammessages.toggleNoForwards); private chats: 400CHAT_TYPE_INVALID. Sent as achat_updatedevent.- Per message:
SendMessageRequest.protect_content/ForwardMessagesRequest.protect_content(Bot APIprotect_content) storesMessage.noforwards. ForwardMessages(with or withoutdrop_author, i.e. copies too) of any message from a protected chat, of a protected message or of self-destructing media fails with 400CHAT_FORWARDS_RESTRICTED— for everyone, owners included. server- “Save / download”: clients ask
GetFileUrl{download: true, chat_id, message_id}; the server checks the message is visible to the caller and references the file, and refuses protected ones with 403CHAT_FORWARDS_RESTRICTED. server Viewing (GetFile,GetFileUrlwithoutdownload) must keep working, so a modified client can still save what it can display. - Client-only: disabling copy text / text selection, save to gallery, share, the forward picker for multi-select, and capture protection (§19.5).
- Known gap: a file_id taken from a protected message can be re-sent with
SendMessageby a modified client (file ids are capabilities, not tied to messages).
19.4 Expiry job
messages.expire_at (unix ms, 0 = never) = min(auto-delete, self-destruct). Every node
runs it every second (and immediately after an open): pick due chats from the partial
index messages_expire (expire_at) WHERE expire_at > 0 AND NOT deleted, then per chat
take the chat row with FOR UPDATE SKIP LOCKED (nodes spread over chats; a busy chat is
retried next tick) and delete up to 500 due rows (index messages_expire_chat (chat_id, expire_at)) with the normal delete-for-everyone path: bodies and logged events scrubbed,
files released, reactions/translations dropped, one delete_messages event per batch.
Deleted chats have their expiry cleared.
19.5 Capture protection (clients)
Applied to secret chats, the self-destructing media viewer and chats with
noforwards (while visible: a dialog or menu on top keeps it, a page pushed on top
releases it). Implemented with the no_screenshot plugin (no hand-written native code):
| platform | blocking | detection |
|---|---|---|
| Android | FLAG_SECURE (screenshots, recordings, casting and recents come out black) | ScreenCaptureCallback (Android 14+) |
| iOS | content in a secure UITextField layer (left out of screenshots, recordings, mirroring) | userDidTakeScreenshotNotification, UIScreen.isCaptured → content blurred while recording |
| macOS | NSWindow.sharingType = .none | Spotlight screenshot metadata |
| Windows | SetWindowDisplayAffinity(WDA_EXCLUDEFROMCAPTURE) (10 2004+, else WDA_MONITOR) | — |
| Linux | none (no compositor API) | — ; content blurred while the window is unfocused |
| Web | none | — ; blurred while the tab is hidden/unfocused, context menu and selection off |
A detected screenshot of self-destructing media sends SendScreenshotNotification; in
secret chats it sends the encrypted screenshot notice (§7).
19.6 Bot API
protect_content on sendMessage, send{Photo,Video,Audio,Document,Voice,Animation,Sticker,VideoNote},
sendLocation, sendContact, sendPoll, forwardMessage and copyMessage; Message.has_protected_content
(message or chat protected); getChat → has_protected_content, message_auto_delete_time;
service message message_auto_delete_timer_changed{message_auto_delete_time}. Forwarding or
copying protected content answers 400 “Bad Request: message can’t be forwarded”. Bots can’t
send or receive self-destructing media and can’t change the timers (as in Telegram).
Generated from docs/PROTOCOL.md in the Telvoro repository. Wire names such as televo.v1 are unchanged.