Telegram Bot API · error code

Telegram error 400: Bad Request: bad webhook: HTTPS url must be provided for webhook

ConfigurationHTTP 400400 Bad Request: webhook registration

Last verified against Telegram Bot API reference

What Telegram returns
Bad Request: bad webhook: HTTPS url must be provided for webhook

What error 400 means

setWebhook was called with a URL that does not start with https://. The hosted Bot API refuses plain HTTP webhooks outright; this is documented under setWebhook and in the FAQ. The only way to use an HTTP webhook is to run your own local Bot API server, which explicitly allows it.

All bad webhook: descriptions share the same shape: the prefix identifies the setWebhook validation stage, and the remainder names the rule that failed. Sibling messages include port restrictions and host resolution failures, covered in their own entries.

Because the webhook was not set, your bot will continue in whatever mode it was in before (polling, or the previous webhook). A common follow-on symptom is a bot that 'works locally with polling but not in production' because the production setWebhook call silently failed in a startup script.

What it looks like

{"ok":false,"error_code":400,"description":"Bad Request: bad webhook: HTTPS url must be provided for webhook"}

Why it happens

  • Development tunnel or local address passed as http://.
  • A config value with the scheme omitted entirely (example.com/webhook).
  • A reverse proxy terminating TLS but the app advertising its internal HTTP address.

How to fix Telegram error 400

  1. 1Use an https:// URL with a valid certificate chain; for local development, use a tunnelling service that provides HTTPS.
  2. 2If your app builds the URL from environment variables, assert the scheme at startup.
  3. 3After calling setWebhook, call getWebhookInfo and verify the url field is what you expect.
  4. 4If you genuinely need HTTP (internal network), run a local Bot API server.

How to stop it recurring

Fail deployment when the webhook URL is not HTTPS, and log the setWebhook response body instead of discarding it. Treat getWebhookInfo as a health check that runs after every deploy. See Telegram bot not responding for the full webhook diagnostic.

The scheme rule sits alongside the four-port rule (443, 80, 88, 8443) and the certificate requirements, all tabulated under webhook limits. Once registration succeeds but deliveries fail, the diagnosis moves to your endpoint; that side is covered in the webhook debugging guide.

Official reference: Telegram Bot API reference. See all Telegram error codes or the Telegram limits and quotas.

Related codes

Error 400 - quick answers

What does Telegram error 400 mean?

setWebhook was called with a URL that does not start with https:// . The hosted Bot API refuses plain HTTP webhooks outright; this is documented under setWebhook and in the FAQ. The only way to use an HTTP webhook is to run your own local Bot API server, which explicitly allows it.

How do I fix Telegram error 400?

1. Use an https:// URL with a valid certificate chain; for local development, use a tunnelling service that provides HTTPS. 2. If your app builds the URL from environment variables, assert the scheme at startup. 3. After calling setWebhook, call getWebhookInfo and verify the url field is what you expect. 4. If you genuinely need HTTP (internal network), run a local Bot API server.

Stop debugging Telegram by hand

Connect the channel through Conferbot: tokens, webhooks and retries are handled, failures show as readable status.