How to set a Telegram bot webhook

A webhook makes Telegram push every update to your HTTPS endpoint instead of you polling getUpdates. Here is how to set it up correctly and securely.

Do it in a few clicks — no code, no server, right in your browser.

Open the webhook manager

Requirements

Set the webhook online

  1. Open Telegram Bot Manager and paste the bot token from @BotFather.
  2. On the Webhook tab enter the URL of your handler.
  3. Press Generate to create a secret token and save it in your server config.
  4. Choose allowed_updates if you need only some update types (or chat_member / reactions, which are off by default).
  5. Press Set webhook. The status block shows the result immediately.

Parameters

ParameterWhat it does
urlHTTPS endpoint that receives updates as JSON POST requests.
secret_token1–256 chars A-Z a-z 0-9 _ -, sent in the X-Telegram-Bot-Api-Secret-Token header of every request.
allowed_updatesUpdate types to receive. Empty list = everything except chat_member, message_reaction, message_reaction_count.
max_connectionsSimultaneous HTTPS connections, 1–100 (default 40).
ip_addressFixed IP to use instead of DNS resolution.
certificatePublic key of a self-signed certificate.
drop_pending_updatesDiscard updates that are waiting in the queue.

Same with curl

curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/setWebhook" \
  --form-string "url=https://example.com/telegram/webhook" \
  --form-string "secret_token=$WEBHOOK_SECRET" \
  --form-string 'allowed_updates=["message","callback_query"]' \
  --form-string "max_connections=40"

With a self-signed certificate:

curl -X POST "https://api.telegram.org/bot$BOT_TOKEN/setWebhook" \
  --form-string "url=https://203.0.113.10:8443/webhook" \
  -F "certificate=@public.pem"

Verify the secret token on your server

Always compare the header with your secret and reject other requests — the webhook URL alone is not a secret.

// Node.js (Express): reject requests without the right secret
app.post('/telegram/webhook', (req, res) => {
  if (req.get('X-Telegram-Bot-Api-Secret-Token') !== process.env.WEBHOOK_SECRET) {
    return res.sendStatus(401);
  }
  // handle req.body (Update) ...
  res.sendStatus(200);
});

Common errors

Do it in a few clicks — no code, no server, right in your browser.

Open the webhook manager