RU Open Web

Type to search client APIs, Bot API methods, and guides.

Build Your Own Client — Messages, Entities & Formatting
Build Your Own Client Messages, Entities & Formatting

Messages, Entities & Formatting

Message pagination cursors, sending text/media/quotes/spoilers/TTL messages, albums, editing, pins, reactions, drafts, polls, and scheduled posts.

Messages support rich structured formatting (entities), albums (grouped_id), forum topic routing (topic_id), quotes, spoilers, view-once & self-destructing timers, reactions, polls, and cloud drafts.

Fetching message history

GET /api/chats/:id/messages?limit=50
JWT
Query ParamTypeDescription
limitintPage size (default 50)
until_message_idintLoad older messages strictly before this ID
after_message_idintLoad newer messages strictly after this ID
around_message_idintJump directly to a window centered on a target message ID
topic_idintFilter messages to a specific forum topic
tag / saved_peer_keystringFilter Saved Messages by tag or original source peer

Additional history utilities: GET /api/chats/:id/shared-media, GET /api/chats/:id/calendar, GET /api/chats/:id/pinned-messages, and GET /api/chats/:id/unread-info.

Sending messages & albums

POST /api/chats/:id/messages
JWT
POST /api/chats/:id/messages/album
JWT

Key JSON fields on POST /api/chats/:id/messages:

  • Core payload: content, message_type (text, image, video, voice, audio, document, sticker, gif, location, contact), local_id, file_url, file_name.
  • Media metadata: is_round (video circle with message_type: "video"), has_media_spoiler, invert_media, waveform, duration, grouped_id.
  • Ephemerality & effects: is_silent, is_view_once, ttl_seconds (0..60, media messages in non-channel chats), effect_id.
  • Replies, quotes & topics: reply_to_message_id, topic_id, is_quote, quote_text, quote_offset, quote_length.
  • Sender identity: send_as_mode, send_as_chat_id, send_as_anonymous (group admins posting anonymously or via linked channel).
  • Rich geo/contact: latitude, longitude, live_period, contact. Update active live location via PATCH /api/chats/:id/messages/:messageId/live-location.

Formatted entities array

Render formatting using UTF-16 code-unit offset and length ranges alongside plaintext content:

{
  "content": "Ship v1.21 today! #release",
  "entities": [
    { "type": "bold", "offset": 0, "length": 11 },
    { "type": "custom_emoji", "offset": 17, "length": 2, "custom_emoji_id": "9012482" },
    { "type": "hashtag", "offset": 18, "length": 8 }
  ],
  "link_preview_options": {
    "is_disabled": false,
    "prefer_large_media": true
  }
}

Supported entity types include bold, italic, underline, strikethrough, spoiler, code, pre, blockquote, expandable_blockquote, text_link, url, mention, hashtag, bot_command, and custom_emoji.

Edits, deletions, reactions, pins & drafts

ActionEndpoint
Edit text / entitiesPUT /api/chats/:id/messages/:messageId
Delete single messageDELETE /api/chats/:id/messages/:messageId
Batch delete / clear historyPOST /api/chats/:id/messages/delete, DELETE /api/chats/:id/messages
Forward messagesPOST /api/chats/:id/messages/forward
Pin / Unpin / Unpin allPOST/DELETE /api/chats/:id/messages/:messageId/pin, DELETE /api/chats/:id/pinned-messages
Reactions (up to 3 per message)POST /api/chats/:id/messages/:messageId/reactions
Consume view-once / report screenshotPOST /api/chats/:id/messages/:messageId/consume-view-once, POST /api/chats/:id/screenshot
Cloud draftPUT /api/chats/:id/draft
Scheduled messagesGET/POST /api/chats/:id/scheduled, PUT/DELETE /api/chats/:id/scheduled/:schedId, POST .../send-now
Polls & quizzesPOST /api/chats/:id/polls, POST .../vote, POST .../close, GET .../results
On-demand translationPOST /api/chats/:id/messages/:messageId/translate