BlogEngineering

Telegram Bot Token: How to Get, Find, and Replace It

Make a Telegram bot token with /newbot, find it again with /mybots, and replace a leaked one with /token.

Rithul PalazhiRithul Palazhi6 min read

Summarize with AI

Telegram Bot Token: How to Get, Find, and Replace It
On this page

A Telegram bot token is the secret string that @BotFather gives you when you create a bot. Your code sends the token with every Bot API request to prove it controls that bot. Get a token with /newbot, find an existing one with /mybots, and replace a leaked one with /token (Telegram Bot API docs, 2026).

Key Takeaways

  • A Telegram bot token authenticates one bot. It does not give access to your personal Telegram account.
  • /newbot in @BotFather creates a bot and returns its token. /mybots, then API Token, shows the token again.
  • Test a token with the getMe method before you build anything on it.
  • Keep the token in an environment variable or a secrets manager. Replace it with /token if it leaks.

What is a Telegram bot token?

A Telegram bot token is a secret string, issued by @BotFather, that authenticates one bot to the Telegram Bot API. A token has a numeric bot ID, a colon, and a secret part. The token identifies the bot, not your personal Telegram account (Telegram Bot API docs, 2026).

PartExampleMeaning
Bot ID123456Numeric ID of the bot
Separator:Divides the ID from the secret
SecretABC-DEF1234ghIkl-zyx57W2v1u123ew11The part that proves ownership

The example token in the table is the one printed in the Telegram Bot API documentation (Telegram Bot API docs, 2026). The documentation gives no fixed length, so do not check a token by counting characters. Treat the whole string as one opaque value.

How do you get a Telegram bot token from BotFather?

To get a Telegram bot token from BotFather, open a chat with @BotFather, send /newbot, choose a display name, then choose a username that ends in bot. BotFather replies in the same chat with the token for the new bot. Copy the token into a secret store at once (Telegram Bot API tutorial, 2026).

  1. Open @BotFather in Telegram and send /newbot.
  2. Send a display name, for example "Alerts Bot".
  3. Send a username that ends in bot, for example my_alerts_bot.
  4. Copy the token from BotFather's reply.

Each bot has its own token. A second bot needs a second run of /newbot.

How do you find the token of an existing Telegram bot?

To find the token of an existing Telegram bot, send /mybots to @BotFather, pick the bot from the list, and choose API Token. BotFather shows the token again in the chat. The list holds only bots owned by your account, so you can recover a lost token without making a new bot (Telegram Bot API docs, 2026).

How do you test a Telegram bot token?

To test a Telegram bot token, call the getMe method at the address https://api.telegram.org/bot<token>/getMe. A valid token returns a JSON object with ok set to true and the bot's ID and username. A wrong token returns an error, so one request shows whether the token works (Telegram Bot API docs, 2026).

export TELEGRAM_BOT_TOKEN="paste-token-here"
curl "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/getMe"

The same bot<token> prefix works for every other method, such as sendMessage.

How do you get the chat ID for a Telegram bot?

To get the chat ID for a Telegram bot, send the bot a message, call getUpdates, and read message.chat.id in the returned update. Use that number as chat_id in sendMessage. A webhook blocks getUpdates, so remove the webhook first if you set one (Telegram Bot API docs, 2026).

How should you store a Telegram bot token?

Store a Telegram bot token in an environment variable or a secrets manager, never in source code. The Telegram tutorial tells developers to treat the token like a password (Telegram Bot API tutorial, 2026). Anyone who holds the token can call the Bot API as your bot.

Three habits cover most leaks:

  • Put the token in an environment variable such as TELEGRAM_BOT_TOKEN, and keep the .env file out of version control.
  • Give each bot its own variable, for example TELEGRAM_TOKEN_ALERTS and TELEGRAM_TOKEN_SUPPORT.
  • Do not paste the token into chats, tickets or screenshots.

When a tool asks for the token, paste it once into that tool's secret or credential field. The article on API authentication methods explains why a token in a header or secret field is safer than a token in a URL you share.

How do you replace a leaked Telegram bot token?

To replace a leaked Telegram bot token, send /token to @BotFather and choose the affected bot. Telegram's tutorial says a token can be revoked at any time through @BotFather (Telegram Bot API tutorial, 2026). After the change, update every deployment that still uses the old token.

Check the old token afterwards with getMe. A request that now fails confirms that the leaked token no longer works.

How do you use a Telegram bot token to receive messages?

A Telegram bot token receives messages in one of two ways: long polling with getUpdates, or a webhook set with setWebhook. The two methods are mutually exclusive, and Telegram says there is nothing wrong with using getUpdates (Telegram Bot API docs, 2026).

Long polling (getUpdates)Webhook (setWebhook)
How updates arriveYour code asks Telegram for themTelegram sends them to your URL
Public URL neededNoYes, with HTTPS
Allowed portsNot applicable443, 80, 88 and 8443
Extra checkNonesecret_token of 1 to 256 characters

For a webhook, Telegram sends the secret_token in the X-Telegram-Bot-Api-Secret-Token header, so your server can reject requests that do not come from Telegram (Telegram Bot API docs, 2026). The article on webhooks and APIs covers the difference in more detail.

What can you build with a Telegram bot token on CodeWords?

On CodeWords, you describe the workflow you want, and Cody builds and connects it. The workflow runs on a schedule, a trigger or a request, and it can use the 3,000+ integrations listed by CodeWords (CodeWords, 2026). A Telegram bot is one more tool that a workflow can talk to.

For example, you can ask for a daily summary sent to your Telegram bot, or an alert that reaches a Telegram chat when a monitored value changes. Browse the workflow templates for starting points. For deeper Telegram guides, read three ways to automate Telegram and how to build a Telegram AI chatbot.

Try CodeWords and describe your first Telegram workflow.

FAQs: Telegram Bot Token

How to login to Telegram with bot token?

A bot token cannot log in to a personal Telegram account. The token only authenticates a bot, which uses it to call the Bot API or to sign in over the MTProto protocol with an api_id and api_hash. To log in as a person, use your phone number and the login code Telegram sends (Telegram API docs, 2026).

Is there a Telegram API for developers?

Yes, Telegram has two developer APIs. The Bot API is an HTTP interface for bots, and it uses a bot token. The Telegram API and TDLib let you build custom Telegram clients that sign in as users or as bots. Most automations need only the Bot API (Telegram Bot API docs, 2026).

How to use a bot token?

Put the token in the request address after the word bot, as in bot<token>/METHOD_NAME, then call a method such as getMe or sendMessage. Most libraries and no-code tools instead ask you to paste the token once into a setting and then build the address for you (Telegram Bot API docs, 2026).

Get started today

Your first workflow is free to build.

Describe what you need. Cody handles the build, the connections, and the deployment.