API Documentation

Integration guide for the Telegram Authentication API. This documentation covers the endpoints available to client applications and their end users.

Authentication

All client requests must include an API key in the request headers. User-facing endpoints on your mini-app should pass this key from your backend โ€” never expose it in client-side code.

Header Scope Description
X-API-Key Client application Issued to your client account. Attach to every request your backend makes to the API.
โš ๏ธ Security Notice
Keep your API key on the server side only. Never embed it in your mini-app frontend, mobile app, or public repository.

Workflow Overview

End-to-end flow for submitting and processing an account:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  CLIENT (your backend / mini-app)                        โ”‚
โ”‚  1. POST /user/register        โ†’ register your end-user  โ”‚
โ”‚  2. GET  /pricing/view         โ†’ show prices to user     โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  USER (end-user submitting an account)                   โ”‚
โ”‚  3. POST /auth/request-otp     โ†’ receive OTP on phone    โ”‚
โ”‚  4. POST /auth/verify-otp      โ†’ submit OTP              โ”‚
โ”‚  5. POST /auth/verify-2fa      โ†’ (if required) password  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  STATUS TRACKING                                         โ”‚
โ”‚  6. GET  /account/status       โ†’ poll by phone           โ”‚
โ”‚  7. GET  /user/balance         โ†’ check credited balance  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                        โ†“
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  WEBHOOK (optional)                                      โ”‚
โ”‚  POST your callback URL on account completion            โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Client Integration For Developers

Endpoints your backend calls to manage users and pricing.

POST /user/register โ€บ
Register a new end-user under your client account. Returns a personal identifier and starting balance.

Request Body

FieldTypeRequiredDescription
endpoint_namestringrequiredYour registered endpoint identifier
telegram_user_idintrequiredThe end-user's Telegram numeric ID
usernamestringoptionalTelegram username (without @)
first_namestringoptional
last_namestringoptional

Example Request

curl -X POST https://tg-server-t88w.onrender.com/user/register \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "endpoint_name": "default",
    "telegram_user_id": 123456789,
    "username": "johndoe"
  }'

Example Response

{
  "success": true,
  "message": "User registered successfully",
  "endpoint_name": "default",
  "user_identifier": "123456789",
  "api_key": "tma_xxxxxxxxxxxxxxxx",
  "balance": 0.0,
  "currency": "USD"
}
โœ“ Save the returned api_key. You can use it as user_identifier in subsequent requests to track this specific user's activity.
GET /pricing/view โ€บ
Retrieve current pricing for your endpoint, optionally filtered by country.

Query Parameters

NameTypeRequiredDescription
endpoint_namestringrequiredYour endpoint identifier
countriesstringoptionalComma-separated: ISO code (BD), name (Bangladesh), or partial match

Examples

# All countries
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://tg-server-t88w.onrender.com/pricing/view?endpoint_name=default"

# Specific countries
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://tg-server-t88w.onrender.com/pricing/view?endpoint_name=default&countries=BD,IN,US"

Example Response

{
  "success": true,
  "message": "Pricing retrieved from cache",
  "data": {
    "endpoint_name": "default",
    "total_countries": 2,
    "pricing": {
      "BD": {
        "fresh_price": 3.50,
        "regular_price": 2.00,
        "spam_price": 0.80,
        "banned_price": 0.00
      },
      "IN": {
        "fresh_price": 4.00,
        "regular_price": 2.50,
        "spam_price": 1.00,
        "banned_price": 0.00
      }
    },
    "not_found": [],
    "currency": "USD",
    "cache_last_loaded": "2026-09-17T12:00:00"
  }
}
POST your-webhook-url โ€บ
If you provide a webhook_url when submitting an account, the API will call it when processing completes.

Headers Sent

HeaderValue
Content-Typeapplication/json
User-AgentTgAuth-Webhook/1.0
X-Webhook-Eventaccount.completed
X-Webhook-SessionSession UUID

Payload

{
  "event": "account.completed",
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "phone_number": "+8801700000000",
  "endpoint_name": "default",
  "user_identifier": "123456789",
  "user_identifier_type": "telegram",
  "status": "completed",
  "account_status_type": "fresh",
  "credited_amount": 3.50,
  "final_price": 3.50,
  "balance_after": 12.80,
  "currency": "USD",
  "completed_at": "2026-09-17T12:15:00Z"
}
Retry Policy: Failed webhooks are retried up to 5 times with exponential backoff. Always respond with a 2xx status to acknowledge receipt.

User โ€” Auth Flow For End-Users

Your mini-app calls these endpoints on behalf of a user who is submitting a Telegram account.

POST /auth/request-otp โ€บ
Send an OTP to the user's phone number to start authentication.

Request Body

FieldTypeRequiredDescription
phone_numberstringrequiredE.164 format (e.g. +8801700000000)
endpoint_namestringrequiredYour endpoint identifier
user_identifierstringoptionalThe Telegram user ID of the submitter
user_identifier_typestringoptionaltelegram ยท email ยท username ยท custom_id
timeout_secondsintoptionalOTP validity window (30โ€“3600, default 300)
country_codestringoptionalISO-2 override (e.g. BD)
use_proxybooloptionalRoute request through proxy (default true)
webhook_urlstringoptionalCallback URL for completion notification

Example Request

curl -X POST https://tg-server-t88w.onrender.com/auth/request-otp \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone_number": "+8801700000000",
    "endpoint_name": "default",
    "user_identifier": "123456789",
    "user_identifier_type": "telegram",
    "use_proxy": true
  }'

Example Response 200 OK

{
  "success": true,
  "message": "OTP sent successfully",
  "data": {
    "session_id": "550e8400-e29b-41d4-a716-446655440000",
    "phone_number": "+8801700000000",
    "endpoint_name": "default",
    "reject_2fa": false,
    "timeout_seconds": 300,
    "country_code": "BD",
    "proxy_used": true,
    "webhook_configured": false,
    "expires_in": 300
  }
}
POST /auth/verify-otp โ€บ
Submit the OTP the user received on their phone.

Request Body

FieldTypeRequiredDescription
session_idUUIDrequiredFrom /auth/request-otp
otp_codestring(5)required5-digit numeric OTP

Example Request

curl -X POST https://tg-server-t88w.onrender.com/auth/verify-otp \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "550e8400-e29b-41d4-a716-446655440000",
    "otp_code": "12345"
  }'

Example Response โ€” Success

{
  "success": true,
  "message": "Authentication successful. Session string saved to database.",
  "data": {
    "session_id": "550e8400-e29b-41d4-a716-446655440000",
    "phone_number": "+8801700000000",
    "endpoint_name": "default",
    "session_string_saved": true,
    "pricing": {
      "fresh_price": 3.50,
      "regular_price": 2.00,
      "spam_price": 0.80,
      "banned_price": 0.00
    },
    "hold_info": {
      "hold_amount": 3.50,
      "expected_time": "6 hours",
      "message": "Your account is under review. Balance will be credited after processing."
    }
  }
}
Response variations:
  • requires_2fa: true โ†’ proceed to /auth/verify-2fa
  • is_rejected: true โ†’ endpoint does not accept 2FA accounts
POST /auth/verify-2fa โ€บ
Submit the 2FA password when the account has two-factor authentication enabled.

Request Body

FieldTypeRequiredDescription
session_idUUIDrequiredSame session
passwordstringrequiredThe Telegram 2FA password

Example Request

curl -X POST https://tg-server-t88w.onrender.com/auth/verify-2fa \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "session_id": "550e8400-e29b-41d4-a716-446655440000",
    "password": "mySecretPassword"
  }'
GET /auth/check-session โ€บ
Get the current state of an in-progress authentication session.

Query Parameters

NameTypeRequired
session_idUUIDrequired
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://tg-server-t88w.onrender.com/auth/check-session?session_id=550e8400-e29b-41d4-a716-446655440000"
POST /auth/logout โ€บ
Terminate the session and clear the stored credentials.
curl -X POST https://tg-server-t88w.onrender.com/auth/logout \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"session_id": "550e8400-e29b-41d4-a716-446655440000"}'

User โ€” Account For End-Users

Track submission status and view balance.

GET /account/status โ€บ
Look up a submitted account's processing status by phone number.

Query Parameters

NameTypeRequiredDescription
endpoint_namestringrequiredYour endpoint identifier
phone_numberstringrequiredE.164 format
user_identifierstringoptionalScope the lookup to this user

Example Request

curl -H "X-API-Key: YOUR_API_KEY" \
  "https://tg-server-t88w.onrender.com/account/status?endpoint_name=default&phone_number=%2B8801700000000"

Example Response โ€” Completed

{
  "success": true,
  "session_id": "550e8400-e29b-41d4-a716-446655440000",
  "endpoint_name": "default",
  "phone_number": "+8801700000000",
  "status": "completed",
  "substatus": null,
  "message": "Account processed and credited",
  "hold_amount": null,
  "credited_amount": 3.50,
  "currency": "USD",
  "spam_status": "spam_free",
  "account_status_type": "fresh",
  "submitted_at": "2026-09-17T12:00:00",
  "completed_at": "2026-09-17T12:15:00"
}
GET /account/status/by-session/{session_id} โ€บ
Look up account status by session UUID.

Path Parameters

NameTypeDescription
session_idUUIDThe session UUID
curl -H "X-API-Key: YOUR_API_KEY" \
  https://tg-server-t88w.onrender.com/account/status/by-session/550e8400-e29b-41d4-a716-446655440000
Status values: pending ยท processing ยท waiting_device_retry ยท completed ยท failed
GET /user/balance โ€บ
Get a user's current balance.

Query Parameters

NameTypeRequired
endpoint_namestringrequired
user_identifierstringrequired
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://tg-server-t88w.onrender.com/user/balance?endpoint_name=default&user_identifier=123456789"

Example Response

{
  "success": true,
  "endpoint_name": "default",
  "user_identifier": "123456789",
  "balance": 12.80,
  "currency": "USD"
}
GET /user/transactions โ€บ
Get a user's transaction history (credits, holds, etc.).

Query Parameters

NameTypeRequiredDescription
endpoint_namestringrequired
user_identifierstringrequired
limitintoptionalMax results (default 50)
curl -H "X-API-Key: YOUR_API_KEY" \
  "https://tg-server-t88w.onrender.com/user/transactions?endpoint_name=default&user_identifier=123456789&limit=20"

Payment Method

We accept payments through Heleket โ€” a fast and secure cryptocurrency payment gateway. Use it to top up your client balance for user payouts.

Heleket Crypto Payments

Instant, low-fee cryptocurrency payments with automatic conversion. Supports BTC, ETH, USDT, TRX, and more.

heleket.com โ†’
How it works: When your client balance is low, initiate a top-up via the Heleket payment link provided in your dashboard. Payments are credited automatically after network confirmation.

Status Codes

CodeMeaning
200Success
400Bad request โ€” validation error, duplicate phone, expired OTP
401Unauthorized โ€” invalid or missing API key
403Forbidden โ€” resource not accessible to this user
404Not found โ€” session or resource does not exist
429Too many requests โ€” rate limit exceeded
500Internal server error