Skip to content

getWebhookInfo

Use this method to get current webhook status. Requires no parameters. On success, returns a WebhookInfo object. If the bot is using getUpdates, will return an object with the url field empty.

Returns

On success, the WebhookInfo object is returned.

GramIO Usage

Check whether a webhook is configured and inspect its current status:

ts
const 
info
= await
bot
.
api
.
getWebhookInfo
();
if (!
info
.
url
) {
console
.
log
("No webhook set — bot is using long polling");
} else {
console
.
log
("Webhook URL:",
info
.
url
);
console
.
log
("Pending updates:",
info
.
pending_update_count
);
}

Monitor webhook health by checking for recent delivery errors:

ts
const 
info
= await
bot
.
api
.
getWebhookInfo
();
if (
info
.
last_error_date
) {
const
errorTime
= new
Date
(
info
.
last_error_date
* 1000);
console
.
error
(`Webhook error at ${
errorTime
.
toISOString
()}: ${
info
.
last_error_message
}`);
}

Inspect allowed_updates and connection settings for debugging:

ts
const 
info
= await
bot
.
api
.
getWebhookInfo
();
console
.
log
("Max connections:",
info
.
max_connections
);
console
.
log
("Allowed updates:",
info
.
allowed_updates
?? "all types");
console
.
log
("IP address:",
info
.
ip_address
?? "not set");

Errors

This method requires no parameters and is read-only, so errors are rare:

CodeErrorCause
401UnauthorizedInvalid bot token — verify BOT_TOKEN is correct
429Too Many Requests: retry after NRate limit hit — check retry_after, use auto-retry plugin

Tips & Gotchas

  • url is empty when using long polling. If getUpdates is active, the returned object has url: "". This is normal — not an error.
  • pending_update_count reveals backlog. A high value means your webhook endpoint is slow or unreachable. Always check last_error_message alongside it to diagnose the cause.
  • last_error_date is a Unix timestamp. Multiply by 1000 for JavaScript Date: new Date(info.last_error_date * 1000).
  • Use this for health checks. Poll getWebhookInfo from your monitoring system to detect webhook delivery failures before users notice.
  • allowed_updates omitted means all updates. If the field is absent in the response, Telegram delivers every update type to your webhook.

See Also