Skip to main content

POST Telegram OTP

This endpoint sends a one-time password to the specified phone number via Telegram. You can either provide your own verification code or let the system generate one. The response returns a unique message identifier and a request_id from the Telegram Gateway, which you use to check verification status or revoke the code later.

Configure the API Endpoint

https://api.betatel.com/api/v1/connect-hub/telegram
  • Method: POST

Set Up the Headers

ParamValueDescription
Content-typeapplication/jsonSpecifies the payload format.
x-api-key{{x-api-key}}API key for authorization.
x-account-id{{x-account-id}}User identifier for added security and tracking.

Craft the Request Body

Example of body
{
"to": "+38761444555",
"code": "482910",
"ttl": 300,
"callback_url": "https://yourapp.com/telegram/callback"
}
FieldTypeRequiredDescription
tostringYesRecipient's phone number in E.164 format (e.g., +38761444555).
codestringYesVerification code to send (4–8 digits).
ttlintegerNoTime in seconds before the code expires (30–3600, default: 300).
sender_usernamestringNoVerified Telegram channel username to send from.
callback_urlstringNoURL to receive Telegram Gateway delivery callbacks (max 256 characters).
tip

Phone Number Formatting:

Phone numbers must be in full E.164 format including the + prefix (e.g., +38761444555).

Code Snippets

Example - cURL
curl --location 'https://api.betatel.com/api/v1/connect-hub/telegram' \
--header 'Content-Type: application/json' \
--header 'x-api-key: YOUR_API_KEY' \
--header 'x-account-id: YOUR_ACCOUNT_ID' \
--data '{
"to": "+38761444555",
"code": "482910",
"ttl": 300,
"callback_url": "https://yourapp.com/telegram/callback"
}'

Understanding the Response

{
"uuid": "01JV5V54KPYK9GB29265EQRZ2P",
"request_id": "tgr_01JV5V54KPYK9GB29265EQRZ2P",
"to": "+38761444555",
"status": "SENT",
"request_cost": 0.01,
"is_refunded": false,
"remaining_balance": 9.99
}
FieldTypeDescription
uuidstringUnique identifier for this message in our system. Use this to retrieve the TDR.
request_idstringTelegram Gateway request ID. Use this for status checks and revocation.
tostringThe recipient's phone number as provided in the request.
statusstringInitial delivery status.
request_costnumberCharge incurred for this request (optional).
is_refundedbooleanWhether the fee was refunded (optional).
remaining_balancenumberAccount balance after this request (optional).
tip

After sending, use Check Verification Status to confirm the code was entered correctly, or Get TDR by UUID to poll the delivery status.

Message Status Lifecycle

StatusDescription
PENDINGMessage accepted and queued.
SENTMessage dispatched to the Telegram Gateway.
DELIVEREDMessage delivered to the recipient's device.
READRecipient has opened the message.
EXPIREDMessage expired before delivery was confirmed.
REVOKEDVerification was explicitly revoked.
FAILEDMessage could not be delivered.

Error Handling

  • 400 - Bad Request: Invalid parameters or malformed request
  • 401 - Unauthorized: Authentication failed
  • 402 - Payment Required: Insufficient account balance
  • 429 - Too Many Requests: Telegram Gateway rate limit reached
  • 500 - Internal Server Error: An unexpected error occurred on the server