WhatsApp and Telegram OTP API
Examples:
WhatsApp OTP API using Curl
Supported Languages: en, ar, ru, de, pt_BR (Contact us for More languages)
curl -X POST https://api.verifyway.com/api/v1/ \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"recipient":"+31612345678",
"type":"otp",
"channel":"whatsapp",
"fallback":"no",
"code":"123456",
"lang":"en"
}'Set fallback to yes to enable Auto Fallback!
Telegram OTP API using Curl
curl -X POST https://api.verifyway.com/api/v1/ \
-H 'Authorization: Bearer API_KEY' \
-H 'Content-Type: application/json' \
-H 'Accept: application/json' \
-d '{
"recipient":"+31612345678",
"type":"otp",
"code":"123456",
"channel":"telegram",
"fallback":"no",
"lang":"en"
}'Languages: (Default English)
Changing template language supported, please contact us to enable other language.
PHP Example using Curl:
$api_url = 'https://api.verifyway.com/api/v1/';
$api_key = 'API_KEY'; // Replace with your actual API key
$data = array(
'recipient' => '+31612345678',
'type' => 'otp',
'code' => '123456',
'channel' => 'whatsapp', //or 'telegram'
'lang' => 'en',
);
$headers = array(
'Authorization: Bearer ' . $api_key,
'Content-Type: application/json',
'Accept: application/json'
);
$ch = curl_init($api_url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
if ($response === false) {
echo 'cURL Error: ' . curl_error($ch);
} else {
echo 'Response: ' . $response;
}
curl_close($ch);
?>
PHP Example using Guzzle:
require 'vendor/autoload.php'; // Make sure to include the Guzzle library
use GuzzleHttp\Client;
$api_url = 'https://api.verifyway.com/api/v1/';
$api_key = 'API_KEY'; // Replace with your actual API key
$data = array(
'recipient' => '+31612345678',
'type' => 'otp',
'code' => '123456',
'channel' => 'whatsapp', //or 'telegram'
'lang' => 'en',
);
$headers = array(
'Authorization' => 'Bearer ' . $api_key,
'Content-Type' => 'application/json',
'Accept' => 'application/json'
);
$client = new Client();
$response = $client->post($api_url, [
'headers' => $headers,
'json' => $data
]);
$body = $response->getBody();
echo $body;
?>Responses:
Success
{
"status": "success",
"message_id": "RANDOM_ID",
"recipient": "+31612345678",
"code": "123456"
}Failure
{ "error": "detail of the error" }
VerifyWay – Message Status Webhook Guide
How it works
When you send a message using our API, you will receive an immediate response like this:
{
"status": "success",
"message_id": "c4ecdcda43057ea7cec985b34264499a160c",
"recipient": "+447598078178",
"code": "123456"
}You must save the message_id in your system.
Important
message_idis the unique ID of your message- You will use this ID to track future status updates
What happens next
After sending the message, you should save:
message_idrecipientcodeif needed
Then wait for a webhook from our system.
Webhook from VerifyWay
We will send a POST request to your webhook URL with the message status:
{
"message_id": "c4ecdcda43057ea7cec985b34264499a160c",
"status": "delivered"
}What you need to do
- Read the following fields:
message_idstatus
- Find the related message in your database using
message_id - Update the status of that message
Example flow
- You send a message and receive:
{
"status": "success",
"message_id": "abc123",
"recipient": "+447598078178",
"code": "123456"
}- You save
message_id = abc123in your database - Later, you receive this webhook:
{
"message_id": "abc123",
"status": "read"
}- You update message
abc123in your database and set its status toread
Status values
expireddeliveredreadfailed
Summary
- Save
message_idwhen sending the message - Wait for the webhook from VerifyWay
- Match the incoming
message_idwith your saved record - Update the message status in your system
PHP Example for Your Webhook
// webhook.php
// Set response type
header('Content-Type: application/json');
// Read raw POST body
$input = file_get_contents('php://input');
// Convert JSON to array
$data = json_decode($input, true);
// Validate JSON
if (!$data) {
http_response_code(400);
echo json_encode([
"status" => "error",
"message" => "Invalid JSON"
]);
exit;
}
// Extract values
$message_id = $data['message_id'] ?? null;
$status = $data['status'] ?? null;
// Validate required fields
if (!$message_id || !$status) {
http_response_code(400);
echo json_encode([
"status" => "error",
"message" => "Missing message_id or status"
]);
exit;
}
// ====== Log webhook to file ======
$logData = [
"time" => date("Y-m-d H:i:s"),
"message_id" => $message_id,
"status" => $status,
"raw" => $data
];
// Save as JSON line (good for later processing)
file_put_contents(
__DIR__ . "/webhook.log",
json_encode($logData) . PHP_EOL,
FILE_APPEND
);
// ====== Optional: Save latest status per message ======
$statusFile = __DIR__ . "/statuses.json";
// Load existing data
$statuses = [];
if (file_exists($statusFile)) {
$statuses = json_decode(file_get_contents($statusFile), true) ?? [];
}
// Update status
$statuses[$message_id] = [
"status" => $status,
"updated_at" => date("Y-m-d H:i:s")
];
// Save back
file_put_contents($statusFile, json_encode($statuses, JSON_PRETTY_PRINT));
// Respond OK (VERY IMPORTANT)
http_response_code(200);
echo json_encode([
"status" => "success"
]);