# Telegram

Publish text, photos, videos, documents and albums to Telegram channels and groups with the Zernio API, edit published messages, and run DMs and bot commands from the inbox.

import { Tab, Tabs } from 'fumadocs-ui/components/tabs';

Publish text, photos, videos, documents and albums to a Telegram channel or group with `POST /v1/posts` and `platform: "telegram"`. The same bot serves DMs and bot commands in the inbox.

## Quick reference

| Property | Value |
|----------|-------|
| Text limit | 4,096 characters (text messages) |
| Caption limit | 1,024 characters (media captions) |
| Images per album | 10 |
| Videos per album | 10 |
| Mixed media | Yes (images and videos in the same album) |
| Image formats | JPEG, PNG, GIF, WebP |
| Image max size | 10 MB (auto-compressed) |
| Video formats | MP4, MOV |
| Video max size | 50 MB (auto-compressed) |
| Scheduling | Yes |
| Editing published posts | Yes (text or caption, media cannot be changed) |
| Inbox (DMs) | Yes |
| Inbox (comments) | No |
| Analytics | No (Telegram limitation) |

## Before you start

Telegram requires Zernio's bot, `@ZernioScheduleBot`, to be an administrator of your channel or group with permission to post.

There is no OAuth and there are no scopes. What the bot can do comes from the admin permissions you grant it.

In a channel, posts appear as the channel's name and logo. In a group, posts appear as sent by "ZernioScheduleBot", and that cannot be changed.

<Callout type="warn">
Add `@ZernioScheduleBot` as an administrator with the Post Messages permission before you connect.
</Callout>

A bot that is a plain member, or an admin without post permission, is the most common setup failure.

The connect call returns `400` and every post fails with "Bot is not a member of the channel".

## Connect

Call `GET /v1/connect/telegram` with `profileId` to [generate an access code](/connect/get-telegram-connect-status), valid for 15 minutes.

The user adds the bot to the channel or group and sends it the code. You poll until the connection completes.

The full flow, with code for every step, is on [Connect](/platforms/telegram/connect).

## Publish a post

This request sends an HTML-formatted message to a Telegram channel or group right away.

<Tabs items={['Node.js', 'Python', 'curl']}>
<Tab value="Node.js">
```typescript
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);
```
</Tab>
<Tab value="Python">
```python
published = client.posts.create_post(
    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"}
        }
    ],
    publish_now=True
)

print(published["post"]["platforms"][0]["platformPostUrl"])
```
</Tab>
<Tab value="curl">
```bash
curl -X POST https://zernio.com/api/v1/posts \
  -H "Authorization: Bearer $ZERNIO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "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
  }'
```
</Tab>
</Tabs>

Every option is on [Publish](/platforms/telegram/posts).

## In this section

<PlatformPages platform="telegram" />

## Related

- [Connecting accounts](/guides/connecting-accounts#telegram): the access code flow next to the OAuth platforms.
- [Create post](/posts/create-post): every field of the request.
- [Edit post](/posts/edit-post): edit the text or caption of a published message.
- [Media uploads](/guides/media-uploads): upload images and videos instead of hosting them.
- [Messages](/messages/list-inbox-conversations) and [Account settings](/account-settings/get-telegram-commands): the inbox API and bot commands.
- [Pricing](/pricing): what the inbox and outbound messages cost.