Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ragnarok22/telegram-bot-api-docker/llms.txt
Use this file to discover all available pages before exploring further.
Why Migrate to Self-Hosted?
Migrating fromapi.telegram.org to a self-hosted Telegram Bot API server gives you:
- Direct file access: Download and serve files without size limits when using local mode
- Better performance: Reduced latency by hosting the API server closer to your application
- Custom configuration: Control webhook connections, log verbosity, and other server parameters
- Network isolation: Keep bot traffic within your infrastructure for enhanced security
Prerequisites
Before starting the migration, ensure you have:- A running instance of the self-hosted Telegram Bot API server
- Your bot token ready
- Access to modify your bot client configuration
- Network connectivity from your bot application to the self-hosted server
Migration Steps
Call logOut on the official API
Before switching to your local server, deregister your bot from This ensures Telegram’s servers stop routing updates to the official API endpoint and prepares your bot for the new server.
api.telegram.org by calling the logOut method:Wait for a successful response before proceeding to the next step. The response should indicate that the bot was successfully logged out.
Update your bot client configuration
Modify your bot application to point to your self-hosted server instead of With:Example configuration changes:
api.telegram.org.Replace:Handle local mode file paths
If your server is running with With local mode:
TELEGRAM_LOCAL=true, the getFile response will contain absolute file paths instead of relative paths.Example response difference:Without local mode:Local mode should only be enabled in trusted environments with proper network isolation. See the Configuration documentation for security considerations.
Rollback Procedure
If you need to revert toapi.telegram.org, follow these steps:
Common Issues
- Updates not arriving: Ensure you called
logOuton the previous server before switching - Connection refused: Verify firewall rules and that the self-hosted server is accessible from your bot application
- File download errors: Check if your application properly handles the file path format based on whether local mode is enabled
- Certificate errors: If using HTTPS, ensure SSL/TLS certificates are properly configured
Next Steps
- Learn about moving between self-hosted servers
- Review environment variables for server configuration
- Configure port mappings for your deployment