Fix OpenClaw Telegram 401 Unauthorized Error
Fix the OpenClaw Telegram 401 unauthorized error by regenerating your bot token in BotFather and updating your gateway config.
Key takeaways
- A 401 unauthorized error means Telegram rejected your bot token. The token is wrong or was revoked in BotFather.
- Copy your token from BotFather's
/mybotsmenu, not from old notes or config files. Trailing spaces and partial copies are the most common cause. - If your bot was working and suddenly shows 401, someone revoked the token. Generate a new one in BotFather. The old token is permanently dead.
- After updating the token, restart the gateway with
openclaw gateway restartand watch the logs for "Telegram channel started."
Your OpenClaw Telegram bot logs 401 Unauthorized and won't connect. Telegram rejected your bot token because it's wrong or was revoked in BotFather. This is the most common Telegram startup error. The fix is quick: get the correct token from BotFather, paste it into your OpenClaw config, and restart the gateway.
Fixes when it breaks. Workflows when it doesn't.
OpenClaw guides, configs, and troubleshooting notes. Every two weeks.
What causes the 401 unauthorized error
The 401 error appears in your gateway logs when the bot token sent to Telegram's API doesn't match any active bot. Three things cause this:
- Token typo. Extra space, missing character, or pasted into the wrong field. I wasted way too long on this once because I copied the token with a trailing space from my terminal.
- Token revoked. You regenerated the token in BotFather but forgot to update your OpenClaw config. Or you clicked "Revoke current token" by accident while troubleshooting something else.
- Wrong bot. You have multiple bots registered with BotFather and grabbed the token for the wrong one.
The logs look something like this:
Telegram channel error: 401 Unauthorized
No additional context. Just a flat rejection from Telegram's API.
How to fix the 401 error
Stop the gateway first:
openclaw gateway stopGo to @BotFather in Telegram and send /mybots. Select your bot, then click "API Token." Copy the full token shown. Don't retype it manually.
Now update your config. If you use environment variables:
export TELEGRAM_BOT_TOKEN="7234567890:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"Or edit your config file directly at ~/.openclaw/config/config.json. If you run OpenClaw in Docker, see the Docker setup guide for the container config path.
{
"channels": {
"telegram": {
"enabled": true,
"accounts": {
"default": {
"token": "7234567890:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw"
}
}
}
}
}Restart the gateway:
openclaw gateway restartCheck the logs:
openclaw logs --followLook for Telegram channel started or Connected as @YourBotName. That confirms the token is valid and the bot is online.
When a previously working token stops working
If your bot was running fine and suddenly throws 401, the token was revoked. This happens when:
- You clicked "Revoke current token" in BotFather while troubleshooting another issue
- Someone with access to your BotFather account regenerated the token
- You ran
/tokenin BotFather, which generates a new token and kills the old one
The old token is permanently dead. There's no way to reactivate it.
Go to BotFather, select your bot, and generate a new token. Copy it into your config and restart the gateway. Every time you regenerate a token, the previous one stops working immediately.
How to verify the fix
After updating the token and restarting, run:
openclaw logs --followSend a test message to your bot on Telegram. You should see:
Received message from user 123456789 (@yourname)
If you still see 401:
- Open BotFather, go to
/mybots, select your bot, click "API Token" - Compare the token character by character with what is in your config
- Check for invisible characters or line breaks (paste the token into a plain text editor first)
- Make sure you're editing the right config file (check
openclaw gateway statusto confirm which config directory the gateway uses)
FAQ
Can I recover a revoked bot token?
No. Once a token is revoked in BotFather, it's gone permanently. Generate a new one and update your config.
Does changing the bot token affect my existing pairings?
No. Pairings are tied to the bot's username and chat IDs, not the token. Your approved groups and DMs keep working with the new token.
I have multiple bots. How do I know which token goes where?
In BotFather, /mybots shows each bot by username. Click the bot you use with OpenClaw and copy that specific token. If you're not sure which bot OpenClaw uses, check the @BotUsername shown in your gateway logs at startup.
The token looks correct but I still get 401. What else could it be?
This is rare, but possible: another OpenClaw instance (or any Telegram bot framework) is connected to Telegram using the same bot token. When that happens, Telegram usually returns a 409 Conflict error for long polling, not a 401. If you are seeing 401, it still means the token is invalid, but it's worth stopping any other processes using this bot token and then re-copying the token from BotFather.
Changelog
- 2026-03-06: Created (split from fix-openclaw-telegram-errors)
Fixes when it breaks. Workflows when it doesn't.
OpenClaw guides, configs, and troubleshooting notes. Every two weeks.
