Telegram Bot API tokens are issued by @BotFather when you create a bot with /newbot. A token has two parts, a numeric bot ID and a secret string, separated by a colon, and is used in the request URL as https://api.telegram.org/bot<token>/METHOD_NAME.
Telegram key types
| Type | Prefix | Secret? | Scope | Expiry |
|---|---|---|---|---|
| Bot API token Format is a numeric bot ID, a colon, then a string of letters, digits and hyphens. | — | Yes | Full control of that one bot through the Bot API | Does not expire; replaced via @BotFather |
How to create a Telegram key
- Open a chat with @BotFather in Telegram.
- Send
/newbotand follow the prompts for a name and username. - BotFather replies with the bot's authentication token. Store it securely.
Limiting what the key can do
Telegram bot tokens have no scopes: the token grants full control of that bot. Limit risk by using one bot per integration and by never putting the token in client-side code.
How to rotate a Telegram key
- Message @BotFather and use
/tokento generate a new token for the bot. - Update the new token wherever the old one was used.
The BotFather documentation says /token generates a new token if yours is compromised or lost; the exact menu path for revoking in /mybots is not documented in the pages researched.
How to revoke a Telegram key
- Revoke or replace the token through @BotFather; the bot tutorial says a token can be revoked at any time this way.
If your Telegram key leaked
- Replace the token through @BotFather with
/token. - Update every deployment with the new token.
- Review what the bot sent or received, since the old token could do anything the bot can.
Things that catch people out
- The token is embedded in every request URL, so it can end up in logs, proxies and referrers; keep it out of them.
- Telegram says to treat the token like a password and not hardcode it in source code.
- The token has no scopes; anyone holding it can act as the bot.
Recent incidents that put Telegram keys at risk
If you were affected by one of these, rotate your Telegram keys using the rotation steps above.
- GhostAction returns: fake security workflows pushed to 30,000+ repos to steal Actions secrets 2026-10-07
Using your Telegram key with AI agents
A coding agent that can read your .env file or your shell history can read the key, and anything in its context can end up in logs, transcripts or a prompt-injected request. The safer pattern is to keep the key in a credential broker that performs the authenticated step for the agent and hands back only the result.
BotPassword works this way. For a Telegram key, these intents fit:
| Intent | What BotPassword does |
|---|---|
run_with | Runs a command with the key injected as an environment variable or a 0600 temporary file, never on the command line, and redacts the key from the output. |
http_request | Makes an authenticated API call after checking the destination against the hosts this key may be sent to. The response comes back with credential-shaped values redacted, and one that holds the key itself is refused. |
rotate | Partly built: creates a new key, stores it as pending, verifies it, promotes it, then revokes the old key after a grace period. Today it works for Cloudflare tokens and AWS IAM keys you have set up, and an agent can start it only under a grant with autopilot; other providers cannot be rotated through their API yet. |
store_secret | Saves a value the agent already holds as a new vault item. |
capture_secret | Planned, not built yet: will read a newly created key straight from the page or command output into the vault. |
Set it up in your agent: Aider · Amp · Claude Code · Claude Desktop · Cline · OpenAI Codex CLI · all agents
Frequently asked questions
How do I get a Telegram bot token?
Message @BotFather, send /newbot, and follow the prompts. BotFather returns the token.
What does a Telegram bot token look like?
A numeric bot ID, a colon, then a string of letters, digits and hyphens.
How do I regenerate a Telegram bot token?
Use /token in a chat with @BotFather to generate a new one.
Can an AI agent use my Telegram key without seeing it?
Yes, if the key never enters the agent's context. Instead of pasting the key into a chat or leaving it in a .env file the agent can read, keep it in a credential broker that injects it into the command or request on the agent's behalf. BotPassword does this with run_with, http_request, store_secret, so the agent gets the result and never the value.