GetOTP Documentation

Viber OTP

The Viber OTP allows you to perform OTP via SMS.

Request for Viber OTP API

To request for Viber OTP, make a POST request to our OTP endpoint. Take note that our OTP endpoint ends with a trailing slash:

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

With the following Basic HTTP verification method:

Description Required Data Type Example
Your API Key Yes String mtbi2w4hlendfpxa1igthcu5p6mzxf7k

Note

With the following parameters:

Name Description Required Data Type Example
channel The channel of verification message Yes String viber
sender Name (unique identifier) of the sender Yes String GetOTP
phone Phone number as digits without spaces or special characters, beginning with the country dialing code Yes String 60123456789
template The unique identifier of the template, which should always contain the {code} attribute Yes UUID 6d16aa9d-bf19-4141-8169-48b46d972fc6
code_length The 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'. Number 4
code The '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'. String 1234
number_formatting Defaults to true. If provided, leading 0 after the country code and before the network code will be removed. No Boolean true
payload The value provided with this parameter will be sent back to the client through the Webhook URL. No String
For JSON object, convert into JSON string.
{\"order_id\":\"xfdu48sfdjsdf\", \"agent_id\":2258}

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": "viber",
        "sender": "GetOTP",
        "phone": "60123456789",
        "template": "550e8400-e29b-41d4-a716-446655440000"
      }
    }
    '

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

    {
      "account_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "message_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
      "phone": "60123456789",
      "create_date": "2025-08-18T06:28:58.962Z",
      "expire_date": "2025-08-18T06:28:58.962Z"
    }

    Response data details:

    Name Description Data Type Example
    account_id The unique identifier of the account String 3fa85f64-5717-4562-b3fc-2c963f66afa6
    message_id The unique identifier of the message String 3fa85f64-5717-4562-b3fc-2c963f66afa6
    phone Recipient's phone number String 60123456789
    create_date Creation date of the verification in UTC, formatted as yyyy-mm-dd hh:mm:ss String 2025-08-18 00:00:00
    expire_date Expiration date of the verification in UTC, formatted as yyyy-mm-dd hh:mm:ss String 2025-08-18 02:00:00

    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 11:36:42",
          "path": "/v1/verifications",
          "method": "POST",
          "status": 400,
          "message": "Invalid code length",
          "code": "1623"
        },
        {
          "timestamp": "2025-09-11 11:36:42",
          "path": "/v1/verifications",
          "method": "POST",
          "status": 400,
          "message": "Provide either 'data.code' or 'data.code_length' but not both",
          "code": "1629"
        }
      ]
    }

    Please refer to this table for details:

    Error Code Description HTTP Code
    1512 Invalid template id 400
    1513 Template is not found 404
    1515 Invalid channel 400
    1523 Invalid recipient number(s) 400
    1620 'sender' is missing 400
    1621 'phone' is missing 400
    1622 'template' is missing 400
    1623 Invalid code length 400
    1624 Template does not contain keyword {code} 400
    1625 'data.from' is blocked 400
    1628 Incompatible template was provided 400
    1629 Provide either 'data.code' or 'data.code_length' but not both 400
    1631 When 'data.channel' is not VOICE 'data.code' must be valid and 4 to 8 characters long 400
    1632 'data.code' should be numeric if provided 400
    1705 Invalid payload 400