Ready-to-run Send OTP/PIN by SMS calls. Replace YOUR_API_KEY with the key from your dashboard.
Send OTP/PIN by SMS — Code Samples
cURL
PHP
Fetch
jQuery
Axios
Python
curl -X POST https://app.way2api.com/api/v1/aws/send_otp-pin \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"value":"5289","number":"919876543210","content":"OTP","purpose":"login","share_with":"no_one"}'
$ch = curl_init('https://app.way2api.com/api/v1/aws/send_otp-pin');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => [
'Authorization: Bearer YOUR_API_KEY',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['value' => 5289, 'number' => 919876543210, 'content' => 'OTP', 'purpose' => 'login', 'share_with' => 'no_one']),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const res = await fetch('https://app.way2api.com/api/v1/aws/send_otp-pin', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({"value":"5289","number":"919876543210","content":"OTP","purpose":"login","share_with":"no_one"}),
});
const data = await res.json();
console.log(data);
$.ajax({
url: 'https://app.way2api.com/api/v1/aws/send_otp-pin',
method: 'POST',
headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
contentType: 'application/json',
data: JSON.stringify({"value":"5289","number":"919876543210","content":"OTP","purpose":"login","share_with":"no_one"}),
success: function(data) { console.log(data); },
error: function(xhr) { console.error(xhr.responseJSON); },
});
const { data } = await axios.post('https://app.way2api.com/api/v1/aws/send_otp-pin', {"value":"5289","number":"919876543210","content":"OTP","purpose":"login","share_with":"no_one"}, {
headers: { 'Authorization': 'Bearer YOUR_API_KEY' },
});
console.log(data);
import requests
url = 'https://app.way2api.com/api/v1/aws/send_otp-pin'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
}
payload = {
'value': '5289',
'number': '919876543210',
'content': 'OTP',
'purpose': 'login',
'share_with': 'no_one'
}
response = requests.post(url, json=payload, headers=headers)
data = response.json()
print(data)
Expected Response — 200
{
"status": "SUCCESS",
"status_code": 200,
"charged": true,
"success": true,
"message": "",
"message_code": "OK",
"order_id": "W2A1739512345abcdef01",
"data": {
"order_id": "W2A1739512345abcdef01",
"result": {
"phone": "+919876543210",
"content_type": "OTP",
"purpose": "login",
"share_with": "no_one",
"sms_status": "sent"
}
}
}