Tokens and signatures
How a request proves it is your bot, and how a Mini App proves who opened it.
The token
Every Bot API request carries the token in its path: /api/v1/bot<token>/<method>. There is no other header to send. Tokens are masked in our logs, and only a hash is stored.
Older tokens beginning with cdb_ are still accepted.
Webhook secret
If you set secret_token in setWebhook, every delivery carries it in X-Telegram-Bot-Api-Secret-Token (and X-Cordice-Bot-Api-Secret-Token). Reject requests without it.
Mini App initData
A Mini App receives initData signed with Telegram’s algorithm, so the checks you already have work as they are:
secret_key = HMAC_SHA256(key="WebAppData", data=bot_token)
hash = hex(HMAC_SHA256(key=secret_key, data=data_check_string))
Ready-made: aiogram.utils.web_app.safe_parse_webapp_init_data, @telegram-apps/init-data-node. See Mini Apps for the fields.