curl -X POST https://api.auther.net/v1/verification/sessions \
--max-time 10 \
-H "X-API-Key: $AUTHER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"method":"SMS_OTP","phone":"964770*******"}'
// send-code.mjs (Node 18+)
const response = await fetch('https://api.auther.net/v1/verification/sessions', {
method: 'POST',
headers: {
'X-API-Key': process.env.AUTHER_API_KEY,
'Content-Type': 'application/json',
},
body: JSON.stringify({ method: 'SMS_OTP', phone: '964770*******' }),
signal: AbortSignal.timeout(10000),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.code);
console.log(body.data.token); // keep it for step 2
import os
import requests
res = requests.post(
"https://api.auther.net/v1/verification/sessions",
headers={"X-API-Key": os.environ["AUTHER_API_KEY"]},
json={"method": "SMS_OTP", "phone": "964770*******"},
timeout=10,
)
body = res.json()
if not res.ok:
raise SystemExit(body["error"]["code"])
print(body["data"]["token"]) # keep it for step 2
<?php
$ch = curl_init('https://api.auther.net/v1/verification/sessions');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 10,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('AUTHER_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode(['method' => 'SMS_OTP', 'phone' => '964770*******']),
]);
$body = json_decode(curl_exec($ch), true);
if (empty($body['success'])) exit(($body['error']['code'] ?? 'request failed') . PHP_EOL);
echo $body['data']['token'], PHP_EOL; // keep it for step 2
Response 201
{
"success": true,
"data": {
"token": "VERIFY-K7PM-Q2XR-9HTD",
"method": "SMS_OTP",
"status": "PENDING",
"expiresInSeconds": 300,
"unitCostCents": 5.4,
"currency": "USD",
"phoneNumber": "964770*******",
"otpSent": true
}
}