getWebhookInfo
Returns: WebhookInfoOfficial docs ↗
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:
| Code | Error | Cause |
|---|---|---|
| 401 | Unauthorized | Invalid bot token — verify BOT_TOKEN is correct |
| 429 | Too Many Requests: retry after N | Rate limit hit — check retry_after, use auto-retry plugin |
Tips & Gotchas
urlis empty when using long polling. IfgetUpdatesis active, the returned object hasurl: "". This is normal — not an error.pending_update_countreveals backlog. A high value means your webhook endpoint is slow or unreachable. Always checklast_error_messagealongside it to diagnose the cause.last_error_dateis a Unix timestamp. Multiply by 1000 for JavaScriptDate:new Date(info.last_error_date * 1000).- Use this for health checks. Poll
getWebhookInfofrom your monitoring system to detect webhook delivery failures before users notice. allowed_updatesomitted means all updates. If the field is absent in the response, Telegram delivers every update type to your webhook.
See Also
- setWebhook — configure the webhook URL and settings
- deleteWebhook — remove the webhook and switch to long polling
- getUpdates — alternative update delivery via long polling
- WebhookInfo — the returned object type
- Webhook guide — complete GramIO webhook setup guide