Skip to content
TGWAY
Channels & Bots STEP 93 / 99

Telegram Gateway API: Send Verification Codes via Telegram

Send sign-up and login codes as Telegram messages with the Gateway API: checkSendAbility, sendVerificationMessage, status values and an SMS fallback.

  • Applies toDevelopers
  • LevelL4
  • Reading time4 min
  • Verified

The short answer

  1. 1The Gateway API delivers your verification codes in Telegram instead of SMS; recipients must use Telegram.
  2. 2Keep the token on your server; send with sendVerificationMessage and check status.
  3. 3Design Telegram-first with an SMS fallback.
In this article
  1. What the Gateway API is
  2. The basic flow
  3. Reading the status
  4. It cannot fully replace SMS
  5. FAQ
  6. At a glance

What the Gateway API is

The Gateway API is a paid Telegram service that delivers the verification codes your service sends at sign-up or login as a Telegram message instead of an SMS. The recipient sees the code in the Telegram app as a verification-code notification. It is not a tool for building chat apps; it is a way to confirm identity for your own service. See the four Telegram APIs.

ItemDetail (official information)
Who can receiveOnly someone who uses Telegram with that phone number
PriceListed as $0.01 per delivered code; it can change, so check the official page
Not deliveredCodes not delivered within a set time are refunded automatically
TestingSending to your own number is free
PaymentDeducted from a balance you top up in advance

The basic flow

  1. Create a Gateway account at gateway.telegram.org and get an API token. Keep the token on your server only.
  2. (Optional) Call checkSendAbility to see whether a number can receive codes. A "cannot send" result is not charged.
  3. Send the code with sendVerificationMessage. Either pass a code you generated, or set only the length (4 to 8 digits) and let Telegram generate it. Also set how long it stays valid (30 to 3600 seconds).
  4. When the user types the code into your screen, and Telegram generated it, confirm it with checkVerificationStatus.
  5. To withdraw a code that has not been delivered yet, call revokeVerificationMessage.

Requests go over HTTPS to gatewayapi.telegram.org, with the token in the Authorization header as a Bearer token. Phone numbers use the international E.164 format, such as +15550100199 (an example).

Reading the status

StatusValues (examples)Meaning
Deliverysent, delivered, read, expired, revokedSent, received, read, expired, withdrawn
Verificationcode_valid, code_invalid, code_max_attempts_exceeded, expiredCorrect, wrong, too many attempts, expired

To receive delivery reports on your server, pass a callback_url when sending. Check that a report really came from Telegram by verifying the signature in its X-Request-Signature header the way the official documentation describes. It is the same idea as checking a mini app's signature; see verifying mini app users.

It cannot fully replace SMS

You cannot reach people who do not use Telegram. Design it in two stages: try Telegram first, and fall back to SMS if the number cannot receive or the code expires.

There is also a way to drop passwords and verification codes entirely: Log in with Telegram on your website.

FAQ

What is the Telegram Gateway API?

A paid service that sends your app's verification codes as Telegram messages instead of SMS.

Can I send codes to people who don't use Telegram?

No. Check with checkSendAbility and fall back to SMS when Telegram can't deliver.

How do I verify a Gateway delivery report?

Check the X-Request-Signature header as described in the official documentation.

Sources

Summary

At a glance

Telegram Gateway API: Send Verification Codes via Telegram — at a glance illustration
  1. 1Service

    Paid per code, refunded if undelivered, free to your own number.

  2. 2Flow

    checkSendAbility, sendVerificationMessage, checkVerificationStatus.

  3. 3Limits

    Only Telegram users; verification only, no marketing.

Share this guide

Send it to a friend who has the same question.

Telegram WhatsApp
More

Open on your phonePoint your phone camera here to open this guide.

Updated

Related articles

View all ›