Skip to main content
Use a webhook when you want Telegram to push updates to your server. The endpoint must be publicly reachable over HTTPS.
The certificate is optional and is only needed for a self-signed certificate. It accepts a path, bytes, or an open file object. When uploading from memory, use certificate_file_name to choose the name.

Inspect and remove the webhook

Webhooks and polling are exclusive

A webhook and poll_updates() cannot be used at the same time. Call delete_webhook() before switching back to polling.
Keep the secret_token private and verify Telegram’s X-Telegram-Bot-Api-Secret-Token header in your webhook handler. Anyone who knows the endpoint URL can send requests to it.