Telegram delivers bot updates by calling a webhook URL of your choice over HTTPS every time a user sends a message or taps a button. ApiSquare exposesDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/shadownrx/apisquare/llms.txt
Use this file to discover all available pages before exploring further.
POST /api/webhook for this purpose — you need to register that URL with Telegram once after each deployment so Telegram knows where to forward incoming updates.
Prerequisites
Before registering the webhook, make sure you have:- A deployed ApiSquare instance with a public HTTPS URL (e.g. on Vercel).
- The
TELEGRAM_TOKENenvironment variable set in your deployment (obtainable from @BotFather on Telegram). - For local development only: a tunnel tool such as
ngrokto expose a public HTTPS URL.
Method 1 — setup-webhook.js Script (Recommended)
The repository includessetup-webhook.js, a small Node.js script that reads TELEGRAM_TOKEN from your .env file and registers the webhook URL you pass as a CLI argument. It performs a POST to https://api.telegram.org/bot{token}/setWebhook using Axios and prints the result.
Run it with your deployed app URL:
TELEGRAM_TOKEN is missing from the environment the script exits with an error before making any network call. If the URL argument is omitted entirely, the script also exits early with usage instructions:
Method 2 — configurar-webhook-facil.js Script
The repository also includesconfigurar-webhook-facil.js, which hard-codes the production URL https://apisquare.vercel.app/api/webhook so you do not need to pass a CLI argument. It reads TELEGRAM_TOKEN from .env and prints progress to the console:
Method 3 — Direct Telegram API Call
You can register the webhook without any scripts by calling the Telegram Bot API directly withcurl:
<YOUR_TOKEN> with your actual bot token from BotFather.
Verifying the Webhook
After registration, confirm that Telegram is pointing at the correct URL. You can useverificar-webhook.js:
url— should match your deployed webhook URL exactly.pending_update_count— should be0if the bot is processing updates normally. A growing count indicates the endpoint is unreachable or returning errors.has_custom_certificate—falsefor standard Vercel deployments (which use a Telegram-trusted CA).
Removing the Webhook
If you want to switch to long-polling for local development (e.g. usingbot.js with node-telegram-bot-api), you must delete the webhook first so Telegram stops POSTing to your server:
The webhook route also handles
GET /api/webhook requests and returns {"status":"ok"}. This satisfies any liveness or challenge verification checks that may be performed against the endpoint.