// DOCUMENTATION

HELP CENTER

Complete guide to generating and using Telegram string sessions

01
Get API Credentials

Go to my.telegram.org and log in with your phone number. Navigate to "API Development Tools" and create a new application. Note your API ID (a number) and API Hash (a 32-char hex string).

02
Select Your Library

Choose between Pyrogram or Telethon, and select either User or Bot session type. User sessions use your personal account. Bot sessions require a bot token from @BotFather on Telegram.

03
Enter Credentials

Input your API ID, API Hash, and your phone number (with country code, e.g. +91XXXXXXXXXX) or bot token. Click "Send OTP" for user sessions or "Generate Session" for bot sessions.

04
Verify OTP

Telegram will send a verification code to your Telegram app (not SMS). Open Telegram and find the code from "Telegram" in your chats. Enter it in the field — it auto-submits when all 5 digits are entered.

05
Handle 2FA (if applicable)

If your account has Two-Step Verification enabled, you will be prompted for your cloud password after the OTP step. Enter it to proceed.

06
Copy & Secure Your Session

Your string session will be displayed. Copy it immediately and store it securely as an environment variable. Never share it with anyone — it is equivalent to your account password.

PYROGRAM USER
from pyrogram import Client

client = Client(
    name="my_account",
    api_id=API_ID,
    api_hash=API_HASH,
    session_string=STRING_SESSION
)

async def main():
    async with client:
        me = await client.get_me()
        print(f"Logged in as {me.first_name}")
TELETHON USER
from telethon import TelegramClient
from telethon.sessions import StringSession

client = TelegramClient(
    StringSession(STRING_SESSION),
    API_ID,
    API_HASH
)

async def main():
    async with client:
        me = await client.get_me()
        print(f"Logged in as {me.first_name}")
A string session is an encoded authentication token that allows a Telegram client library (Pyrogram or Telethon) to connect to Telegram on your behalf without needing to re-authenticate every time. It stores your session data as a base64 string that you can use in your bot or script.
Yes. The authentication happens directly between your browser and Telegram servers via the MTProto protocol. We never store your API ID, API Hash, phone number, OTP, or the generated session string. Once you leave the page, everything is cleared from memory.
These are credentials issued by Telegram that identify your application. You can get them for free by logging into my.telegram.org, navigating to "API Development Tools", and creating a new app. Every Telegram client library requires these to connect.
Both are Python libraries for the Telegram MTProto API. Pyrogram is newer and uses a more Pythonic async-first design. Telethon is older, widely used, and has extensive documentation. Both support user and bot sessions. Your choice depends on your project's existing dependencies.
A User session authenticates as your personal Telegram account — it can do everything a regular user can do. A Bot session authenticates as a Telegram bot using a bot token from @BotFather. Bots have limited capabilities (e.g., cannot initiate conversations) but are safer for automation.
The OTP Telegram sends expires in about 2 minutes. Make sure you enter the code quickly after receiving it. If it expires, simply click "Cancel & Restart" and start the process again — a new OTP will be sent.
Double-check your API ID and API Hash from my.telegram.org. Make sure there are no spaces or extra characters. If you recently created the app, wait a few minutes and try again as Telegram sometimes takes time to activate new credentials.
Yes. If your Telegram account has Two-Step Verification enabled, after entering the OTP you will be prompted for your cloud password. Enter it to complete authentication and generate your session.
Store it as an environment variable in your hosting platform (e.g., Heroku, Railway, VPS). Never hardcode it in your source code or commit it to GitHub. Treat it like a password — it provides full access to your Telegram account.
Yes. Click "Generate Another" after completing one session to go back to the start and generate a new session for a different account or library.
Pass the session string to the Pyrogram Client: `Client("session_name", api_id=API_ID, api_hash=API_HASH, session_string="YOUR_STRING_HERE")`. For in-memory: `Client(name="user", api_id=API_ID, api_hash=API_HASH, session_string=STRING_SESSION, in_memory=True)`.
Use `StringSession`: `from telethon.sessions import StringSession` then `TelegramClient(StringSession("YOUR_STRING_HERE"), API_ID, API_HASH)`. The client will authenticate using the stored session without requiring a new login.
NEED MORE HELP?

Join our Telegram channel for support, updates, and more tools.

JOIN @META_SERVER