Skip to main content

Send OTP Code (WhatsApp)

An example of a request to send a one-time password (OTP) via WhatsApp.

warning

WhatsApp is not a message type of its own. A request with type: whatsapp is rejected with the error Invalid message type.

WhatsApp exists only as a stage of a pipeline: you send a request of type: pipeline and list whatsapp among its stages. Everything else — the endpoint, the key, the response format — is the same as for any other JSON API method.

URI: https://alphasms.net/api/json.php

All requests to API are sent in JSON format using the POST method.

Header parameters

Requests must contain header Content-Type: application/json, otherwise, the request will be considered invalid even if it has valid JSON.

Request example

{
"auth": "bb56a4369eb19***cfec6d1776bd25",
"data": [
{
"type": "pipeline",
"pipeline": [
"whatsapp"
],
"id": 100500,
"phone": 380971234567,
"whatsapp": {
"signature": "SenderID",
"message": "Your code is 1234"
}
}
]
}

Response examples

HTTP Status Code: 200
Content Type: JSON application/json

{
"success": true,
"data": [
{
"success": true,
"data": {
"msg_id": 123456789
}
}
]
}
note

Fallback to another channel. List the channels in the order you want them tried and add the parameters of each stage. The gateway charges the most expensive stage up front and returns the difference once the message is actually delivered.

{
"type": "pipeline",
"pipeline": ["whatsapp", "sms"],
"id": 100500,
"phone": 380971234567,
"whatsapp": { "signature": "SenderID", "message": "Your code is 1234" },
"sms": { "signature": "SenderID", "message": "Your code is 1234" }
}

The full list of stages and their parameters is on the Multi channel page.

warning

WhatsApp has to be enabled on your route — the gateway and the price are set by your manager. Without them any pipeline containing whatsapp answers with No route.

The whatsapp stage is not validated by the API. If signature or message is missing, the request is still accepted and charged, and the message goes out empty. Check both fields on your side before sending.

The delivery status of a pipeline request goes to the notification address from your API settings — see Delivery report by URL: the gateway does not store hook for this type.