Guide

Telegram bot webhook: how to set, check and delete it

setWebhook, getWebhookInfo and deleteWebhook step by step: HTTPS and port rules, the secret token, Telegram's IP ranges, errors, and webhook vs getUpdates.

AdminHub

Launching a channel? Start with a bot

Connect a bot

TL;DR. A webhook is an HTTPS address where Telegram sends your bot’s updates. Set it: setWebhook with url — HTTPS only, ports 443, 80, 88 or 8443. Protect it: add secret_token and check the X-Telegram-Bot-Api-Secret-Token header. Check it: getWebhookInfo shows the address, the waiting updates and the last error. Delete it: deleteWebhook. While a webhook is set, getUpdates does not work — a bot uses one method or the other.

With AdminHub: a bot connected to AdminHub runs on AdminHub’s webhook, so you need no server of your own — details at the end.

A Telegram bot gets updates — new messages, button presses, new members — in one of two ways. With getUpdates your program asks Telegram for new updates again and again. With a webhook Telegram sends each update to your address as soon as it happens. This guide covers the webhook: the requirements, the three methods, security and the usual errors.

getUpdates or webhook

getUpdates (long polling)Webhook
Who starts the requestyour program asks TelegramTelegram calls your address
What you needa program that keeps runninga public HTTPS address
Good fora computer or server that runs all the timea server or a serverless platform with an HTTPS address
Updates not receivedwait on Telegram’s sideTelegram tries to deliver them again

The two methods cannot be used together. In both cases Telegram keeps the updates the bot has not received, but not longer than 24 hours.

What the address must be

Telegram’s requirements for a webhook:

  • HTTPS only. A plain HTTP webhook is not possible. The server must support TLS 1.2 or newer.
  • Ports 443, 80, 88 or 8443. Other ports do not work. If you use a port other than 443, put it in the address: https://example.com:8443/your-path.
  • IPv4. Webhooks do not support IPv6.
  • A valid certificate. Its name (CN or SAN) must match your domain. Wildcard certificates may not be supported, and redirects are not supported.
  • A self-signed certificate also works if you upload it in the certificate parameter of setWebhook.

Most hosting platforms already give your app an HTTPS address with a valid certificate, so the last two points matter only for your own server. The free hosting guide compares platforms where a webhook bot can run.

Set a webhook: setWebhook

Every Bot API request has the same form: https://api.telegram.org/bot<token>/METHOD. The simplest way is to open this in a browser, with your token and your address:

https://api.telegram.org/bot<token>/setWebhook?url=https://example.com/your-path

Or with curl, with a secret token:

curl -F "url=https://example.com/your-path" \
     -F "secret_token=your_secret_123" \
     https://api.telegram.org/bot<token>/setWebhook

The parameters of setWebhook:

ParameterWhat it does
urlyour HTTPS address; an empty value removes the webhook
secret_token1–256 characters: A-Z, a-z, 0-9, _ and -; Telegram sends it in a header with every request
max_connectionshow many requests Telegram may send at the same time, 1–100, 40 by default
allowed_updatesthe update types you want, for example ["message", "callback_query"]
drop_pending_updatestrue throws away the updates that are waiting
ip_addressa fixed IP address to use instead of the one from DNS
certificateyour public certificate, if it is self-signed

By default allowed_updates includes every update type except chat_member, message_reaction and message_reaction_count. If you need those, list them explicitly. If you leave allowed_updates out, the previous setting stays.

What your server receives

For each update Telegram sends an HTTPS POST request with the update as JSON. Your server must answer with an HTTP status 2XX. If the answer is anything else, Telegram repeats the request, and after what the documentation calls a reasonable amount of attempts, it gives up.

A useful detail: in the answer to the webhook request, your server can call one Bot API method — put the method name in the method field and its parameters next to it. This saves one request, but you cannot know whether the call worked or get its result. For anything important, make a normal request.

Make sure the request comes from Telegram

Anyone who knows your webhook address can send requests to it. Two ways to check:

  1. The secret token. Set secret_token in setWebhook. Telegram puts it in the X-Telegram-Bot-Api-Secret-Token header of every request. Reject every request where the header is missing or different. This is the simplest and most reliable check.
  2. The IP ranges. Telegram sends webhook requests from 149.154.160.0/20 and 91.108.4.0/22. Telegram warns that these ranges might change, so do not rely only on them.

The older advice from Telegram’s bot FAQ also works: use a secret path in the address, for example one that contains a random string.

Check a webhook: getWebhookInfo

https://api.telegram.org/bot<token>/getWebhookInfo

What the answer contains:

FieldMeaning
urlthe current address; empty if no webhook is set
pending_update_counthow many updates are waiting for delivery
last_error_date, last_error_messagewhen the last delivery failed and why
last_synchronization_error_datethe last error of synchronization with Telegram’s data centers
ip_addressthe IP address Telegram currently sends to
max_connections, allowed_updatesthe settings from setWebhook
has_custom_certificatewhether you uploaded your own certificate

If pending_update_count keeps growing and last_error_message is not empty, Telegram cannot deliver updates to your address. last_error_message describes the most recent delivery error in plain words.

Delete a webhook: deleteWebhook

https://api.telegram.org/bot<token>/deleteWebhook?drop_pending_updates=true

Without drop_pending_updates the waiting updates stay, and your program gets them through getUpdates. setWebhook with an empty url also removes the webhook.

Delete the webhook when you move a bot to getUpdates — for example, to test it on your own computer. While a webhook is set, getUpdates does not work. This also applies to tools that read your bot’s updates: the bot token and chat ID tool reads them with getUpdates, so it cannot list chats for a bot that has a webhook.

Why the bot does not answer

What you seeCheck
pending_update_count grows, last_error_message is setthe address, the certificate, the port; your server must answer 2XX
no errors, but no updates of some typeallowed_updates: chat_member, message_reaction and message_reaction_count are not sent by default
getUpdates does not worka webhook is set; delete it first
old updates arrive after a restartthey waited on Telegram’s side; use drop_pending_updates to throw them away
the webhook address changes by itselfanother program set its own webhook for the same bot

One bot, one webhook

A bot can have only one webhook at a time. Whoever calls setWebhook last receives all its updates. That is why two services cannot both receive updates for the same bot, and why a bot sometimes stops answering after it was connected to a new service.

In AdminHub this works as follows:

  • When you connect a bot, AdminHub sets its own webhook for it and throws away the waiting updates. If the bot’s webhook points to another address, AdminHub first shows that address and asks whether to move the updates here; your webhook is replaced only after you agree. AdminHub runs the bot from its own servers, so you need no server and no hosting.
  • If the webhook later points to another service, AdminHub does not take it back by itself. The bot’s screen says that updates go to another service, with a button to bring the bot back to AdminHub.
  • If the webhook is removed, AdminHub sets it again automatically.
  • When you disconnect the bot, AdminHub deletes its webhook and the updates that are waiting, and the bot is free for your own code.

If you have no bot yet, AdminHub can create one for you without a token — see how to create a Telegram bot.


Sources, checked November 2026: Telegram Bot API — Getting updates, getUpdates, setWebhook, deleteWebhook, getWebhookInfo, WebhookInfo, making requests when getting updates; Marvin’s Marvellous Guide to All Things Webhook — ports, TLS, IPv4, IP ranges, certificates; Bots FAQ — webhook checklist, secret path.

What people usually ask

How do I set a webhook for a Telegram bot?
Call the Bot API method setWebhook with your HTTPS address: https://api.telegram.org/bot<token>/setWebhook?url=https://example.com/your-path. From then on Telegram sends every update to that address as an HTTPS POST request with JSON. The address must use HTTPS and one of the ports 443, 80, 88 or 8443.
How do I check my bot's webhook?
Open https://api.telegram.org/bot<token>/getWebhookInfo. It shows the current address, how many updates are waiting, and the date and text of the last delivery error. An empty url field means no webhook is set and the bot gets updates through getUpdates.
How do I delete a Telegram webhook?
Call deleteWebhook, or call setWebhook with an empty url. Add drop_pending_updates=true if you also want to throw away the updates that are waiting. After that the bot can get updates through getUpdates again.
Can I use getUpdates and a webhook at the same time?
No. Telegram calls them two mutually exclusive ways to receive updates. While a webhook is set, getUpdates does not work. To switch back to getUpdates, delete the webhook first.
How do I know that a webhook request really comes from Telegram?
Set a secret_token when you call setWebhook. Telegram then sends it in the X-Telegram-Bot-Api-Secret-Token header of every request, and your server rejects requests without it. Telegram also publishes the IP ranges it sends webhooks from: 149.154.160.0/20 and 91.108.4.0/22, but warns that they might change.
What happens to updates if my server is down?
Telegram keeps them and tries to deliver them again. If a request fails, Telegram repeats it and gives up after what its documentation calls a reasonable amount of attempts. Undelivered updates are not kept longer than 24 hours.