// start.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: 'WA_MESSAGE', applicationName: 'Acme' }),
signal: AbortSignal.timeout(10000),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.code);
const { token, deepLink } = body.data;
// save token with this user (step 3 sends it back), then send them to deepLink
console.log(token, deepLink);
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": "WA_MESSAGE", "applicationName": "Acme"},
timeout=10,
)
body = res.json()
if not res.ok:
raise SystemExit(body["error"]["code"])
token, deep_link = body["data"]["token"], body["data"]["deepLink"]
# save token with this user (step 3 sends it back), then send them to deep_link
print(token, deep_link)
<?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' => 'WA_MESSAGE', 'applicationName' => 'Acme']),
]);
$body = json_decode(curl_exec($ch), true);
if (empty($body['success'])) exit(($body['error']['code'] ?? 'request failed') . PHP_EOL);
$token = $body['data']['token'];
$deepLink = $body['data']['deepLink'];
// save $token with this user (step 3 sends it back), then send them to $deepLink
echo $token, ' ', $deepLink, PHP_EOL;
WhatsApp opens with the message ready. They tap Send.
<!-- Start the check when the user taps (your server does it: Node.js, Python or PHP tab),
not when the page loads -->
<a href="/verify-phone">Verify with WhatsApp</a>
// verify.mjs (Node 18+): your "Verify with WhatsApp" button opens this URL
import { createServer } from 'node:http';
createServer(async (req, res) => {
try {
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: 'WA_MESSAGE', applicationName: 'Acme' }),
signal: AbortSignal.timeout(10000),
});
const body = await response.json();
if (!response.ok) return res.writeHead(502).end(body.error.code);
// save body.data.token with the signed-in user: step 3 sends it back
res.writeHead(303, { Location: body.data.deepLink }).end();
} catch {
res.writeHead(502).end();
}
}).listen(3000);
# verify.py: your "Verify with WhatsApp" button opens this URL
import os
import requests
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
class Verify(BaseHTTPRequestHandler):
def do_GET(self):
try:
res = requests.post(
"https://api.auther.net/v1/verification/sessions",
headers={"X-API-Key": os.environ["AUTHER_API_KEY"]},
json={"method": "WA_MESSAGE", "applicationName": "Acme"},
timeout=10,
)
body = res.json()
except (requests.RequestException, ValueError):
self.send_error(502)
return
if not res.ok:
self.send_error(502, body["error"]["code"])
return
# save body["data"]["token"] with the signed-in user: step 3 sends it back
self.send_response(303)
self.send_header("Location", body["data"]["deepLink"])
self.end_headers()
ThreadingHTTPServer(("", 3000), Verify).serve_forever()
<?php // verify.php: your "Verify with WhatsApp" button opens this URL
$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' => 'WA_MESSAGE', 'applicationName' => 'Acme']),
]);
$body = json_decode(curl_exec($ch), true);
if (empty($body['success'])) {
http_response_code(502);
exit($body['error']['code'] ?? 'error');
}
// save $body['data']['token'] with the signed-in user: step 3 sends it back
header('Location: ' . $body['data']['deepLink'], true, 303);
3
Step 3: Get the verified number
We send it to your webhook, signed. Check the signature.
# body.json is the raw webhook body; t and v1 come from its Auther-Signature header
: "${AUTHER_WEBHOOK_SECRET:?set it first}"
t=1795428041
v1=9f2c6b…
expected=$(printf '%s.%s' "$t" "$(cat body.json)" \
| openssl dgst -sha256 -hmac "$AUTHER_WEBHOOK_SECRET" | awk '{print $NF}')
if [ "$expected" = "$v1" ]; then echo "From Auther"; else echo "Not from Auther"; fi
// webhook.mjs (Node 18+): run it at a public https:// address, save that address in your// dashboard (Webhook page), and its signing secret as AUTHER_WEBHOOK_SECRET
import { createServer } from 'node:http';
import { createHmac, timingSafeEqual } from 'node:crypto';
const secret = process.env.AUTHER_WEBHOOK_SECRET;
if (!secret) throw new Error('Set AUTHER_WEBHOOK_SECRET first');
createServer(async (req, res) => {
try {
const chunks = [];
for await (const chunk of req) chunks.push(chunk);
const raw = Buffer.concat(chunks).toString();
const sig = Object.fromEntries(
String(req.headers['auther-signature']).split(',').map((part) => part.split('=')),
);
const expected = Buffer.from(
createHmac('sha256', secret).update(`${sig.t}.${raw}`).digest('hex'),
);
const given = Buffer.from(String(sig.v1));
const fresh = Math.abs(Date.now() / 1000 - Number(sig.t)) < 300;
if (!fresh || given.length !== expected.length || !timingSafeEqual(given, expected)) {
res.writeHead(401).end();
return;
}
const event = JSON.parse(raw);
// event.token is the token you saved in step 1: find that user (skip tokens already done)
console.log(event.token, event.phoneNumber);
res.writeHead(200).end();
} catch {
res.writeHead(400).end();
}
}).listen(3000);
# webhook.py: run it at a public https:// address, save that address in your# dashboard (Webhook page), and its signing secret as AUTHER_WEBHOOK_SECRET
import hashlib, hmac, json, os, time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
SECRET = os.environ.get("AUTHER_WEBHOOK_SECRET", "").encode()
if not SECRET:
raise SystemExit("Set AUTHER_WEBHOOK_SECRET first")
class Webhook(BaseHTTPRequestHandler):
def do_POST(self):
try:
raw = self.rfile.read(int(self.headers.get("Content-Length", 0)))
header = self.headers.get("Auther-Signature", "")
sig = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
t = sig.get("t", "")
expected = hmac.new(SECRET, f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
fresh = t.isdecimal() and abs(time.time() - int(t)) < 300
if not fresh or not hmac.compare_digest(expected.encode(), sig.get("v1", "").encode()):
return self.answer(401)
event = json.loads(raw)
except ValueError:
return self.answer(400)
# event["token"] is the token you saved in step 1: find that user (skip tokens already done)
print(event["token"], event["phoneNumber"])
self.answer(200)
def answer(self, status):
self.send_response(status)
self.end_headers()
ThreadingHTTPServer(("", 3000), Webhook).serve_forever()
<?php // webhook.php: run it at a public https:// address, save that address in your// dashboard (Webhook page), and its signing secret as AUTHER_WEBHOOK_SECRET
$secret = getenv('AUTHER_WEBHOOK_SECRET');
if ($secret === false || $secret === '') {
http_response_code(500);
exit;
}
$raw = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_AUTHER_SIGNATURE'] ?? ''), $sig);
$t = $sig['t'] ?? '';
$expected = hash_hmac('sha256', $t . '.' . $raw, $secret);
if (!ctype_digit($t) || abs(time() - (int) $t) > 300 || !hash_equals($expected, $sig['v1'] ?? '')) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
// $event['token'] is the token you saved in step 1: find that user (skip tokens already done)
error_log($event['token'] . ' ' . $event['phoneNumber']);
http_response_code(200);
// start.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: 'TG_MESSAGE', applicationName: 'Acme' }),
signal: AbortSignal.timeout(10000),
});
const body = await response.json();
if (!response.ok) throw new Error(body.error.code);
const { token, telegramDeepLink } = body.data;
// save token with this user (step 3 sends it back), then send them to telegramDeepLink
console.log(token, telegramDeepLink);
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": "TG_MESSAGE", "applicationName": "Acme"},
timeout=10,
)
body = res.json()
if not res.ok:
raise SystemExit(body["error"]["code"])
token, telegram_deep_link = body["data"]["token"], body["data"]["telegramDeepLink"]
# save token with this user (step 3 sends it back), then send them to telegram_deep_link
print(token, telegram_deep_link)
<?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' => 'TG_MESSAGE', 'applicationName' => 'Acme']),
]);
$body = json_decode(curl_exec($ch), true);
if (empty($body['success'])) exit(($body['error']['code'] ?? 'request failed') . PHP_EOL);
$token = $body['data']['token'];
$telegramDeepLink = $body['data']['telegramDeepLink'];
// save $token with this user (step 3 sends it back), then send them to $telegramDeepLink
echo $token, ' ', $telegramDeepLink, PHP_EOL;
Telegram opens our bot. They tap Start, then Share my phone number.
<!-- Start the check when the user taps (your server does it: Node.js, Python or PHP tab),
not when the page loads -->
<a href="/verify-phone">Verify with Telegram</a>
// verify.mjs (Node 18+): your "Verify with Telegram" button opens this URL
import { createServer } from 'node:http';
createServer(async (req, res) => {
try {
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: 'TG_MESSAGE', applicationName: 'Acme' }),
signal: AbortSignal.timeout(10000),
});
const body = await response.json();
if (!response.ok) return res.writeHead(502).end(body.error.code);
// save body.data.token with the signed-in user: step 3 sends it back
res.writeHead(303, { Location: body.data.telegramDeepLink }).end();
} catch {
res.writeHead(502).end();
}
}).listen(3000);
# verify.py: your "Verify with Telegram" button opens this URL
import os
import requests
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
class Verify(BaseHTTPRequestHandler):
def do_GET(self):
try:
res = requests.post(
"https://api.auther.net/v1/verification/sessions",
headers={"X-API-Key": os.environ["AUTHER_API_KEY"]},
json={"method": "TG_MESSAGE", "applicationName": "Acme"},
timeout=10,
)
body = res.json()
except (requests.RequestException, ValueError):
self.send_error(502)
return
if not res.ok:
self.send_error(502, body["error"]["code"])
return
# save body["data"]["token"] with the signed-in user: step 3 sends it back
self.send_response(303)
self.send_header("Location", body["data"]["telegramDeepLink"])
self.end_headers()
ThreadingHTTPServer(("", 3000), Verify).serve_forever()
<?php // verify.php: your "Verify with Telegram" button opens this URL
$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' => 'TG_MESSAGE', 'applicationName' => 'Acme']),
]);
$body = json_decode(curl_exec($ch), true);
if (empty($body['success'])) {
http_response_code(502);
exit($body['error']['code'] ?? 'error');
}
// save $body['data']['token'] with the signed-in user: step 3 sends it back
header('Location: ' . $body['data']['telegramDeepLink'], true, 303);
3
Step 3: Get the verified number
We send it to your webhook, signed. Check the signature.
# body.json is the raw webhook body; t and v1 come from its Auther-Signature header
: "${AUTHER_WEBHOOK_SECRET:?set it first}"
t=1795428041
v1=9f2c6b…
expected=$(printf '%s.%s' "$t" "$(cat body.json)" \
| openssl dgst -sha256 -hmac "$AUTHER_WEBHOOK_SECRET" | awk '{print $NF}')
if [ "$expected" = "$v1" ]; then echo "From Auther"; else echo "Not from Auther"; fi
// webhook.mjs (Node 18+): run it at a public https:// address, save that address in your// dashboard (Webhook page), and its signing secret as AUTHER_WEBHOOK_SECRET
import { createServer } from 'node:http';
import { createHmac, timingSafeEqual } from 'node:crypto';
const secret = process.env.AUTHER_WEBHOOK_SECRET;
if (!secret) throw new Error('Set AUTHER_WEBHOOK_SECRET first');
createServer(async (req, res) => {
try {
const chunks = [];
for await (const chunk of req) chunks.push(chunk);
const raw = Buffer.concat(chunks).toString();
const sig = Object.fromEntries(
String(req.headers['auther-signature']).split(',').map((part) => part.split('=')),
);
const expected = Buffer.from(
createHmac('sha256', secret).update(`${sig.t}.${raw}`).digest('hex'),
);
const given = Buffer.from(String(sig.v1));
const fresh = Math.abs(Date.now() / 1000 - Number(sig.t)) < 300;
if (!fresh || given.length !== expected.length || !timingSafeEqual(given, expected)) {
res.writeHead(401).end();
return;
}
const event = JSON.parse(raw);
// event.token is the token you saved in step 1: find that user (skip tokens already done)
console.log(event.token, event.phoneNumber);
res.writeHead(200).end();
} catch {
res.writeHead(400).end();
}
}).listen(3000);
# webhook.py: run it at a public https:// address, save that address in your# dashboard (Webhook page), and its signing secret as AUTHER_WEBHOOK_SECRET
import hashlib, hmac, json, os, time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
SECRET = os.environ.get("AUTHER_WEBHOOK_SECRET", "").encode()
if not SECRET:
raise SystemExit("Set AUTHER_WEBHOOK_SECRET first")
class Webhook(BaseHTTPRequestHandler):
def do_POST(self):
try:
raw = self.rfile.read(int(self.headers.get("Content-Length", 0)))
header = self.headers.get("Auther-Signature", "")
sig = dict(part.split("=", 1) for part in header.split(",") if "=" in part)
t = sig.get("t", "")
expected = hmac.new(SECRET, f"{t}.".encode() + raw, hashlib.sha256).hexdigest()
fresh = t.isdecimal() and abs(time.time() - int(t)) < 300
if not fresh or not hmac.compare_digest(expected.encode(), sig.get("v1", "").encode()):
return self.answer(401)
event = json.loads(raw)
except ValueError:
return self.answer(400)
# event["token"] is the token you saved in step 1: find that user (skip tokens already done)
print(event["token"], event["phoneNumber"])
self.answer(200)
def answer(self, status):
self.send_response(status)
self.end_headers()
ThreadingHTTPServer(("", 3000), Webhook).serve_forever()
<?php // webhook.php: run it at a public https:// address, save that address in your// dashboard (Webhook page), and its signing secret as AUTHER_WEBHOOK_SECRET
$secret = getenv('AUTHER_WEBHOOK_SECRET');
if ($secret === false || $secret === '') {
http_response_code(500);
exit;
}
$raw = file_get_contents('php://input');
parse_str(str_replace(',', '&', $_SERVER['HTTP_AUTHER_SIGNATURE'] ?? ''), $sig);
$t = $sig['t'] ?? '';
$expected = hash_hmac('sha256', $t . '.' . $raw, $secret);
if (!ctype_digit($t) || abs(time() - (int) $t) > 300 || !hash_equals($expected, $sig['v1'] ?? '')) {
http_response_code(401);
exit;
}
$event = json_decode($raw, true);
// $event['token'] is the token you saved in step 1: find that user (skip tokens already done)
error_log($event['token'] . ' ' . $event['phoneNumber']);
http_response_code(200);