# Telegram Bot API: Send Messages, Photos and Media Groups to a Channel

> Send messages, photos and albums to a Telegram channel with the Bot API: bot setup, chat ids, sendMessage, sendMediaGroup, formatting, file limits and flood control.

Canonical: https://tesselith.com/blog/telegram-bot-api-send-to-channel
Last updated: 2026-11-27

**To post to a Telegram channel with the Bot API, create a bot with @BotFather, add it to the channel as an administrator with the Post Messages right, then call `https://api.telegram.org/bot<token>/sendMessage` with `chat_id` set to the channel's `@username` (or its numeric id, which starts with -100) and your `text`.** Photos use `sendPhoto`, and albums of 2 to 10 photos or videos use `sendMediaGroup`. Messages can be 4,096 characters, but media captions only 1,024. Telegram limits bots to roughly one message per second in a single chat, and returns `429` with a `retry_after` when you go over.

**Key takeaways**
- The bot must be a channel admin with Post Messages. Being a member isn't enough.
- Public channels take @username as chat_id. Private channels need the numeric -100... id.
- Text: 4,096 characters. Captions: 1,024. A long caption fails the whole send.
- Albums (sendMediaGroup) take 2 to 10 items, and only the first item's caption shows as the album caption.
- Telegram reports most failures as ok: false in the body. Check it, not just the HTTP status.

## Step 1: create the bot and make it a channel admin

1. In Telegram, open a chat with **@BotFather**, send `/newbot`, pick a display name and a username ending in `bot`.
2. BotFather replies with a token like `123456789:AA...`. That token is the bot's full credential. Store it like a password.
3. Open your channel, tap its name, then **Administrators**, **Add Admin**, search for your bot, and keep **Post Messages** enabled.
4. Note the channel's public link. For `t.me/bakerynews`, the chat id is `@bakerynews`.

If you're new to channels, [how to create a Telegram channel](https://tesselith.com/blog/how-to-create-a-telegram-channel) walks through setup, and [Telegram channel vs group](https://tesselith.com/blog/telegram-channel-vs-group) explains which one you want. A bot can post to both, but the rate limits differ.

Before your first send, check the target with `getChat`. It confirms the bot can see the chat and tells you its `type`: `channel`, `group`, `supergroup` or `private`. That check saved us a class of support tickets: `getChat` happily resolves a bot or a private chat, so someone entering their bot's own `@username` as the channel looked fine at connect time and only failed at publish, three retries later. Reject `private` at setup, while the person is still looking at the form.

```bash
curl "https://api.telegram.org/bot$BOT_TOKEN/getChat?chat_id=@bakerynews"

# {"ok": true, "result": {"id": -1001234567890, "title": "Bakery News", "type": "channel", "username": "bakerynews"}}
```

Save the numeric `id` too. If the channel's username changes, or the channel goes private, `@username` stops working but the numeric id doesn't.

## Step 2: send a text message

```bash
curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "@bakerynews",
    "text": "Fresh croissants until 11. Pre-orders for Saturday close tonight.",
    "link_preview_options": {"is_disabled": false},
    "disable_notification": false
  }'

# {"ok": true, "result": {"message_id": 418, "date": 1795849200, "chat": {...}, "text": "..."}}
```

Store `message_id`. You need it to edit (`editMessageText`), delete (`deleteMessage`) or reply to the post. `date` is Unix seconds. Set `disable_notification: true` for a silent post that arrives without a sound, which is good manners for late-night or low-priority updates.

Current parameter names, as of Bot API 10.5 (November 22, 2026): link previews are controlled with `link_preview_options`, and replies use `reply_parameters` with a `message_id`. The older `disable_web_page_preview` and `reply_to_message_id` fields no longer appear in the docs. Code written before 2024 often still sends them.

## Formatting: HTML is safer than MarkdownV2

Without `parse_mode`, text goes out exactly as written, which is the safe default for user-written copy. To add bold, italics or links, you have two options. `MarkdownV2` requires a backslash before every underscore, asterisk, bracket, parenthesis, tilde, backtick, greater-than sign, hash, plus, minus, equals sign, pipe, brace, period and exclamation mark that appears in plain text, and a single unescaped period or hyphen makes Telegram reject the whole message. `HTML` only needs `<`, `>` and `&` escaped. For anything that includes user input, use HTML.

```ts
const escapeHtml = (s: string) =>
  s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")

const text =
  "<b>" + escapeHtml(title) + "</b>\n" +
  escapeHtml(summary) + "\n" +
  '<a href="' + escapeHtml(url) + '">Read more</a>'

await tg("sendMessage", { chat_id: "@bakerynews", text, parse_mode: "HTML" })
```

## Photos, videos and documents

`sendPhoto`, `sendVideo` and `sendDocument` each take the file in one of three ways, with different limits:

| How you send the file | Photo limit | Other files |
| --- | --- | --- |
| Public HTTP URL (Telegram downloads it) | 5 MB | 20 MB |
| Multipart upload | 10 MB | 50 MB |
| file_id of a file Telegram already has | No limit | No limit |

Passing a URL is the easiest: Telegram fetches from your storage directly and your server never touches the bytes. Watch the URL limits, though. A 30 MB video works as a multipart upload and fails as a URL. Once a file is sent, the response includes a `file_id`, and reusing it for later posts costs nothing and has no size limit.

```bash
curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendPhoto" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "@bakerynews",
    "photo": "https://cdn.example.com/croissants.jpg",
    "caption": "Saturday batch. Pre-order by 8pm Friday."
  }'
```

Captions max out at 1,024 characters after entity parsing, a quarter of the message limit. If your post text is longer, either send the photo with a short caption and the full text as a separate message, or send the text first with a link preview. Truncating silently is worse than either. Send GIFs as documents or animations if you want to avoid Telegram re-encoding them as photos.

## Albums with sendMediaGroup

`sendMediaGroup` posts 2 to 10 items as one album. Each item is an object with `type` (`photo`, `video`, `document` or `audio`) and `media`. Put the caption on the first item only. Captions on later items show up per item, which looks like the same text repeated. Documents and audio can only be grouped with items of the same type, so a PDF can't join a photo album.

```bash
curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMediaGroup" \
  -H "Content-Type: application/json" \
  -d '{
    "chat_id": "@bakerynews",
    "media": [
      {"type": "photo", "media": "https://cdn.example.com/a.jpg", "caption": "This week at the bakery"},
      {"type": "photo", "media": "https://cdn.example.com/b.jpg"},
      {"type": "video", "media": "https://cdn.example.com/c.mp4"}
    ]
  }'

# {"ok": true, "result": [{"message_id": 420, ...}, {"message_id": 421, ...}, {"message_id": 422, ...}]}
```

The result is an array, one message per item. Store the first `message_id` as the album's id, since that's the message a reply or comment should point at.

## Errors and flood control

Telegram's responses always carry `ok`. On failure you get `ok: false`, an `error_code` and a `description`, sometimes with HTTP 200 and sometimes with a 4xx. Parse the body every time.

| error_code | Typical description | Retry? |
| --- | --- | --- |
| 400 | Bad Request: chat not found / message is too long / can't parse entities | No. Fix the request |
| 401 | Unauthorized (token revoked or wrong) | No. Get a new token |
| 403 | Forbidden: bot is not a member / was kicked / not enough rights | No. Re-add the bot as admin |
| 429 | Too Many Requests: retry after N | Yes, after parameters.retry_after seconds |
| 5xx | Telegram's side | Yes, with backoff |

Limits from Telegram's bot FAQ: avoid more than one message per second in a single chat (short bursts are tolerated), no more than 20 messages per minute in a group, and about 30 messages per second for bulk broadcasts across chats. Paid broadcasts, enabled in @BotFather, raise the last one to 1,000 per second at 0.1 Telegram Stars per message over the free amount. A scheduler posting to channels will rarely touch these, but a thread of ten follow-up messages fired in a loop will hit the per-chat limit. Space them a second apart.

## Follow-ups, edits and analytics

- **Follow-up in the same thread of thought:** send a new message with `reply_parameters: {"message_id": 418}`. It shows as a reply in the channel.
- **Fix a typo:** `editMessageText` (or `editMessageCaption` for media) with the `message_id`. Subscribers see an edited label.
- **Pin:** `pinChatMessage` in a channel needs the bot to have the Edit Messages admin right.
- **Subscribers:** `getChatMemberCount` returns the channel's subscriber count.
- **Views per post:** not available through the Bot API. View counts need the MTProto client API, which is a different integration.

For channel strategy rather than code, read our [Telegram channel marketing guide](https://tesselith.com/blog/telegram-channel-marketing) and [how to schedule Telegram posts](https://tesselith.com/blog/how-to-schedule-telegram-posts).

## When to use a scheduling API instead of building it yourself

The Bot API is the easiest publishing API of any network here: no OAuth, no review, no fees. A cron job and `sendMessage` is a fine way to post to your own channel. A scheduler earns its keep when Telegram is one of several channels, when non-developers write the posts, or when you need a calendar, approvals and failure alerts around the sends.

Tesselith [posts to Telegram channels](https://tesselith.com/schedule/telegram) today, with albums, silent posts and follow-up replies, from the app or the [REST API](https://tesselith.com/product/api). For the bigger picture, see our [scheduling API checklist](https://tesselith.com/blog/social-media-scheduling-api), the [automation walkthrough](https://tesselith.com/blog/automate-social-media-posting-api), and the [docs](https://tesselith.com/docs).

## Questions people ask

### How do I send a message to a Telegram channel with a bot?

Add the bot to the channel as an administrator with Post Messages, then call sendMessage with chat_id set to the channel's @username or numeric -100 id and your text.

### What chat_id do I use for a private Telegram channel?

The numeric id, which starts with -100. Get it from getChat while the channel is public, or from an update the bot receives from the channel.

### How many photos can a Telegram media group have?

Between 2 and 10 items per sendMediaGroup call. Only the first item's caption is shown as the album caption.

### What is the Telegram caption limit?

1,024 characters for media captions, versus 4,096 for a text message.

### Why does my Telegram bot get 403 Forbidden on a channel?

The bot isn't an administrator of the channel, lacks the Post Messages right, or was removed. Re-add it as an admin.

---
Tesselith · https://tesselith.com · Full site index: https://tesselith.com/llms.txt
