Zernio
APIFor you
Zernio
APIFor you
Platforms

Telegram

Overview

Set up

Connect

Publish

PublishPlatform Fields & Media

Engage

Inbox

Reference

Limits & Errors
Dashboard
OverviewPlatformsAPI ReferenceResources
Telegram

Publish

Publish text, photos, videos, documents and albums to a Telegram channel or group, and edit published messages.


A plain post becomes a text message. One media item becomes a photo, video or document message with content as its caption, and 2 to 10 items become an album with the caption on the first message. Text is parsed as HTML unless parseMode says otherwise.

Text message

const { data: published } = await zernio.posts.createPost({
  body: {
    content: '<b>Release 2.3 is out.</b>\n\nRead the <a href="https://example.com/changelog">changelog</a>.',
    platforms: [
      {
        platform: 'telegram',
        accountId: '66b2e19d8c3f5a7e9d0b1c2d',
        platformSpecificData: { parseMode: 'HTML' }
      }
    ],
    publishNow: true
  }
});

console.log(published.post.platforms[0].platformPostUrl);

Response (201):

{
  "post": {
    "_id": "65f1c0a9e2b5af0012ab34cd",
    "status": "published",
    "platforms": [
      {
        "platform": "telegram",
        "status": "published",
        "platformPostUrl": "https://t.me/mychannel/42"
      }
    ]
  }
}

Every sample below changes only the mediaItems or the platforms entry of this request.

Photo message

A single image with content as the caption (1,024 characters):

"mediaItems": [
  { "type": "image", "url": "https://cdn.example.com/launch.jpg" }
]

Video message

A single video with content as the caption:

"mediaItems": [
  { "type": "video", "url": "https://cdn.example.com/demo.mp4" }
]

Document message

Any file type, sent as a document:

"mediaItems": [
  { "type": "document", "url": "https://cdn.example.com/report.pdf" }
]

Album

Up to 10 items, images and videos mixed, sent as one album:

"mediaItems": [
  { "type": "image", "url": "https://cdn.example.com/photo1.jpg" },
  { "type": "image", "url": "https://cdn.example.com/photo2.jpg" },
  { "type": "video", "url": "https://cdn.example.com/clip.mp4" },
  { "type": "image", "url": "https://cdn.example.com/photo3.jpg" }
]

Formatting

parseMode selects how Telegram reads content. HTML is the default:

<b>bold</b>
<i>italic</i>
<u>underline</u>
<s>strikethrough</s>
<code>inline code</code>
<pre>code block</pre>
<a href="https://example.com">link</a>

"Markdown" supports *bold*, _italic_, [link](https://example.com) and backtick-wrapped inline code. "MarkdownV2" adds __underline__, ~strikethrough~ and ||spoiler||, and needs a backslash before every one of these characters:

_ * [ ] ( ) ~ ` > # + - = | { } . !

An unescaped character fails the post with "Can't parse entities".

Silent and protected messages

disableNotification delivers the message without a notification sound, protectContent stops recipients from forwarding or saving it, and disableWebPagePreview suppresses the link preview:

{
  "platform": "telegram",
  "accountId": "66b2e19d8c3f5a7e9d0b1c2d",
  "platformSpecificData": {
    "parseMode": "HTML",
    "disableWebPagePreview": true,
    "disableNotification": true,
    "protectContent": true
  }
}

Channels and groups

DestinationShown as the author
ChannelThe channel's name and logo
GroupZernioScheduleBot

Edit a published message

Edit post replaces the text of a published Telegram message. Messages stay editable with no time window and no limit on the number of edits, and the message id does not change. What content replaces depends on the original post:

Original postWhat content replacesLimit
Text onlyThe message text4,096 characters
Single photo, video or documentThe caption1,024 characters
AlbumThe caption on the album (its first message)1,024 characters

The media itself cannot be swapped, added or removed, and an edit with unchanged content is rejected with 400. Check which limit applies before sending: a 2,000-character edit fits a text message and is too long for a photo caption.

const { data: edited } = await zernio.posts.editPost({
  path: { postId: published.post._id },
  body: {
    platform: 'telegram',
    content: '<b>Updated.</b> The webinar starts at 18:00 CET.'
  }
});

console.log(edited.id, edited.url);

Response (200):

{
  "success": true,
  "id": "42",
  "url": "https://t.me/mychannel/42"
}

If the post went to several Telegram channels or groups, pass accountId to pick which copy to edit. Without it, the first telegram entry on the post is edited.

Was this page helpful?

Connect

Connect a Telegram account with the Zernio API, every step with code.

Platform Fields & Media

Every Telegram platformSpecificData field and the image and video requirements.

On this page

Text messagePhoto messageVideo messageDocument messageAlbumFormattingSilent and protected messagesChannels and groupsEdit a published message