GetOTP Documentation

Telegram OTP

The Telegram OTP allows you to perform OTP via Telegram.

Request for Telegram OTP API

To request for Telegram OTP, make a POST request to our OTP endpoint.

https://api.otp.dev/v1/verifications

With the following Basic HTTP verification method:

DescriptionRequiredData TypeExample
Your API KeyYesStringmtbi2w4hlendfpxa1igthcu5p6mzxf7k

Note

With the following parameters:

NameDescriptionRequiredData TypeExample
channelThe channel of verification message 'telegram'YesStringtelegram
phonePhone number as digits without spaces or special characters, beginning with the country dialing codeYesString60123456789
code_lengthThe length of the code, which falls within the range of 4 to 8 characters.At least one of the following is required: 'code_length' or 'code'.String4
codeThe 'code' field accepts only digits and must be between 4 to 8 characters in length.At least one of the following is required: 'code_length' or 'code'.String1234
ttl_in_secondsFor 'TELEGRAM' channel ttl(time to live) must be between 60 to 86400 seconds, default is 60 secondsNoNumber70
number_formattingDefaults to true. If provided, leading 0 after the country code and before the network code will be removed.NoBooleanTrue
payloadThe value provided with this parameter will be sent back to the client through the Webhook URL. Length ≤ 500NoStringTelegram Payload

Note

Notes on the phone parameter:

  • You must provide a phone number as digits without spaces or special characters, beginning with the country dialing code.
  • Examples

    Below is an example request using cURL:

    curl --request POST \
         --url https://api.otp.dev/v1/verifications \
         --header 'X-OTP-Key: {YOUR_API_KEY}' \
         --header 'accept: application/json' \
         --header 'content-type: application/json' \
         --data '
    {
        "data": {
            "channel": "telegram",
            "phone": "60123456789",
            "code_length": 5
        }
    }
    '

    The response would be a JSON structure, returned with HTTP 200 Codestatus code:

    {
      "account_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "phone": "60123456789",
      "create_date": "2025-09-11 05:43:58",
      "expire_date": "2025-09-11 07:43:58"
    }

    Response data details:

    NameDescriptionData TypeExample
    account_idThe unique identifier of the accountString731873df-a1c7-4be6-8ad8-e530abd717d4
    message_idThe unique identifier of the messageString34d18fb8-31e8-4f42-97ff-a8009f232280
    phoneRecipient's phone numberString60123456789
    create_dateCreation date of the verification in UTC, formatted as yyyy-mm-dd hh:mm:ssString2025-09-11 05:43:58
    expire_dateExpiration date of the verification in UTC, formatted as yyyy-mm-dd hh:mm:ssString2025-09-11 07:43:58

    If there is an error with the API call, you will receive a JSON response with 400+ status code, error code and message.

    {
      "errors": [{
        "timestamp": "2025-09-11 05:49:48",
        "path": "/v1/verifications",
        "method": "POST",
        "status": 400,
        "message": "Invalid code length",
        "code": "1623"
      }]
    }

    Please refer to this table for details:

    Error CodeDescriptionHTTP Code
    1523Invalid recipient number(s)400
    1621'phone' is missing400
    1623Invalid code length.The code length should be minimum 4 and maximum 8.400
    1629Provide either 'data.code' or 'data.code_length' but not both400
    1631When 'data.channel' is not VOICE 'data.code' must be valid and 4 to 8 characters long400
    1632'data.code' should be numeric if provided400
    1640data.ttl_in_seconds' must be numeric400
    1648'data.phone' must be E164 format for the telegram channel400
    1649'data.ttl_in_seconds' must be between 60 and 86400 seconds for Telegram400
    1705Invalid payload400