API Docs
RouterOTP verifies phone numbers over WhatsApp with a 6-digit code. Every API key works in one of two modes, chosen per key in the dashboard. The endpoints are the same for both.
Inbound Verification
Your user sends one prefilled WhatsApp message to RouterOTP and receives the code as a reply. Because the user starts the chat, WhatsApp itself proves who owns the number. Available on every plan.
Your server calls /otp-session
Pass the phone number the user typed. You receive a session id and a ready-made WhatsApp link.
The user taps Send in WhatsApp
Open whatsapp.link in a new tab. WhatsApp opens with the RouterOTP number and the message already filled in.
RouterOTP replies with a code
We check that the message came from the expected number and reply with a 6-digit code that names your app.
Your server calls /otp-verify
Send the session id and the code the user typed. On success, store the phone from the response as verified.
Outbound Verification
RouterOTP messages your user first with a personalised question and sends the code as soon as they reply YES (English) or BETUL (Indonesian), so your user never has to type a token. Every message is worded differently. Available on paid plans; one number can receive at most 3 requests per hour and 6 per day.
Your server calls /otp-session
Pass the phone number and the user's name; e-mail is optional and shown so the user recognises the account.
RouterOTP asks the user
Within seconds the user gets a personalised WhatsApp message asking them to reply YES (English) or BETUL (Indonesian) if they made the request.
The user replies YES / BETUL
The 6-digit code is sent back in the same chat immediately. A reply like “no” or “bukan” cancels the request.
Your server calls /otp-verify
Send the session id and the code the user typed. On success, store the phone from the response as verified.
Example conversation (Indonesian)
Halo, selamat siang Kak Fulanah 👋 Ada permintaan kode verifikasi untuk masuk ke *YourApp* menggunakan nomor WhatsApp ini (akun fulanah @gmail .com). Jika benar Kakak yang meminta, balas *BETUL* dan kodenya langsung kami kirim. Jika bukan Kakak, abaikan saja pesan ini.
Betul
Terima kasih, Kak Fulanah. *482913* adalah kode verifikasi untuk masuk ke *YourApp*. Berlaku 5 menit. Jangan berikan kode ini kepada siapa pun, termasuk yang mengaku dari YourApp.
Base URL and authentication
https://qtfhadkcqvygntfcnznh.supabase.co/functions/v1Send your API key in the Authorization header as Bearer ro_live_… (the x-api-key header also works). Create a key in the dashboard under API Keys. Call the API from your server only; never put the key in browser or mobile app code.
POST/otp-session
Starts a verification. The mode of the API key decides what happens. expires_in is in seconds (60–900, default 300).
| Body field | Meaning |
|---|---|
| phone | Inbound: optional but recommended; only that number can complete the session. Outbound: required, RouterOTP messages this number. |
| name | Outbound: required. The user's name (2–30 letters), used in the greeting, e.g. “Halo Kak Fulanah”. |
| Outbound: optional. The user's e-mail, shown in the message as fulanah @gmail .com (spaced so WhatsApp does not turn it into a link) so the user recognises the account. | |
| expires_in | Seconds until the session expires, 60–900. Default 300. |
Request (inbound key)
curl -X POST https://qtfhadkcqvygntfcnznh.supabase.co/functions/v1/otp-session \
-H "Authorization: Bearer ro_live_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"phone": "+6281234567890",
"expires_in": 300
}'Response 200 (inbound key)
{
"id": "64bcb603-604b-42ca-9b07-0a3adbe0d5fa",
"mode": "inbound",
"token": "ROTP-SCP9JCH6",
"status": "pending",
"whatsapp": {
"phone": "+6285147129802",
"message": "Permintaan verifikasi saya: ROTP-SCP9JCH6",
"link": "https://wa.me/6285147129802?text=Permintaan%20verifikasi%20saya%3A%20ROTP-SCP9JCH6"
},
"expires_at": "2026-01-01T10:05:00Z"
}Request (outbound key)
curl -X POST https://qtfhadkcqvygntfcnznh.supabase.co/functions/v1/otp-session \
-H "Authorization: Bearer ro_live_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"phone": "+6281234567890",
"name": "Fulanah",
"email": "fulanah@gmail.com",
"expires_in": 300
}'Response 200 (outbound key)
{
"id": "9a1d2c7e-0b6f-4c55-8f0e-5d1f3a2b7c90",
"mode": "outbound",
"status": "pending",
"delivery": { "status": "queued", "to": "+6281234567890" },
"expires_at": "2026-01-01T10:05:00Z"
}Errors
| HTTP | error | Meaning |
|---|---|---|
| 400 | invalid_phone | The phone number is not valid. Use international format, e.g. +6281234567890. |
| 400 | invalid_expires_in | expires_in must be a number of seconds. Values outside 60–900 are clamped. |
| 400 | phone_required | Outbound: phone is required. |
| 400 | name_required | Outbound: name is required for the greeting. |
| 400 | invalid_name | Outbound: name must be 2–30 letters, without digits, links or symbols. |
| 400 | invalid_email | Outbound: email is not a valid e-mail address. |
| 401 | invalid_api_key | The API key is missing, invalid or disabled. |
| 402 | insufficient_credits | Outbound: no Outbound OTP credits left. Buy a pack in the dashboard (Billing). |
| 403 | outbound_not_allowed | The key uses Outbound Verification but the account has not bought an Outbound OTP pack yet. |
| 429 | recipient_rate_limited | Outbound: this number already had 3 requests in the last hour or 6 in the last day. |
| 429 | rate_limited | Outbound: more than 20 sessions per minute on your account. |
| 503 | no_sender_available | No WhatsApp sender is online right now. Retry shortly. |
GET/otp-status?id=…
Optional. Poll every few seconds to show progress, e.g. “Reply YES in WhatsApp” while delivery.status is awaiting_confirmation, or “Check WhatsApp for your code” once status is code_sent.
Request
curl "https://qtfhadkcqvygntfcnznh.supabase.co/functions/v1/otp-status?id=64bcb603-604b-42ca-9b07-0a3adbe0d5fa" \
-H "Authorization: Bearer ro_live_xxxxxxxxxxxx"Response 200 (inbound)
{
"id": "64bcb603-604b-42ca-9b07-0a3adbe0d5fa",
"mode": "inbound",
"status": "code_sent",
"message_received": true,
"expires_at": "2026-01-01T10:05:00Z"
}Response 200 (outbound)
{
"id": "9a1d2c7e-0b6f-4c55-8f0e-5d1f3a2b7c90",
"mode": "outbound",
"status": "pending",
"message_received": false,
"delivery": { "status": "awaiting_confirmation", "error": null },
"expires_at": "2026-01-01T10:05:00Z"
}status
| pending | Session created. Inbound: waiting for the user's message. Outbound: waiting for the confirmation to be sent or answered. |
| code_sent | The code was sent on WhatsApp (inbound: after the user's message; outbound: after the user replied YES / BETUL). |
| verified | The correct code was submitted. The phone number is confirmed. |
| expired | The session ran out of time before verification. |
| blocked | Too many wrong codes. The session cannot be used anymore. |
delivery.status (outbound only)
| queued | The confirmation message is waiting for a free RouterOTP WhatsApp number. |
| sending | The confirmation message is being sent right now. |
| awaiting_confirmation | Delivered. Waiting for the user to reply YES (English) or BETUL (Indonesian). |
| sent | The user confirmed and the code was sent. |
| failed | Stopped. error is declined_by_recipient, not_on_whatsapp, expired_before_send or a transport error. |
POST/otp-verify
Checks the code the user typed. On success, phone is the verified number: for inbound the number that sent the WhatsApp message, for outbound the number that replied YES / BETUL. Store this value.
Request
curl -X POST https://qtfhadkcqvygntfcnznh.supabase.co/functions/v1/otp-verify \
-H "Authorization: Bearer ro_live_xxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"id": "64bcb603-604b-42ca-9b07-0a3adbe0d5fa",
"code": "482913"
}'Response 200
{
"id": "64bcb603-604b-42ca-9b07-0a3adbe0d5fa",
"status": "verified",
"phone": "+6281234567890",
"verified_at": "2026-01-01T10:02:14Z"
}Errors
| HTTP | error | Meaning |
|---|---|---|
| 400 | invalid_id | id must be the session id returned by /otp-session. |
| 400 | invalid_code_format | code must be exactly 6 digits. |
| 401 | invalid_api_key | The API key is missing, invalid or disabled. |
| 404 | otp_not_found | No verification session with this id for your account. |
| 409 | already_verified | This session was already verified. |
| 409 | awaiting_message | Inbound: the user has not sent the WhatsApp message yet, so no code was issued. |
| 409 | awaiting_delivery | Outbound: the confirmation message is still being sent. |
| 409 | awaiting_confirmation | Outbound: the user has not replied YES / BETUL yet, so no code was sent. |
| 409 | delivery_failed | Outbound: the flow stopped. delivery_error is declined_by_recipient, not_on_whatsapp, expired_before_send or a transport error. |
| 410 | otp_expired | The session expired before verification. Start a new session. |
| 422 | invalid_code | The code does not match. attempts_remaining tells how many tries are left. |
| 429 | too_many_attempts | Too many wrong codes. Start a new session. |
Example (Node.js)
// Server-side only. Never expose your API key to the browser.
const BASE = "https://qtfhadkcqvygntfcnznh.supabase.co/functions/v1";
const headers = {
Authorization: `Bearer ${process.env.ROUTEROTP_API_KEY}`,
"Content-Type": "application/json",
};
// 1. Start a session. name and email are used by Outbound Verification keys.
export async function startVerification(phone, name, email) {
const res = await fetch(`${BASE}/otp-session`, {
method: "POST",
headers,
body: JSON.stringify({ phone, name, email, expires_in: 300 }),
});
const body = await res.json();
if (!res.ok) throw new Error(body.error);
// inbound: send body.whatsapp.link to the browser and open it
// outbound: tell the user to reply YES (English) / BETUL (Indonesian) in WhatsApp, then show the code input
return body; // { id, mode, whatsapp?, delivery?, expires_at }
}
// 2. Check the 6-digit code the user typed
export async function confirmVerification(id, code) {
const res = await fetch(`${BASE}/otp-verify`, {
method: "POST",
headers,
body: JSON.stringify({ id, code }),
});
const body = await res.json();
if (!res.ok) return { ok: false, ...body }; // error, message, attempts_remaining?
return { ok: true, phone: body.phone }; // trust this phone, not user input
}Integration tips
- Use one API key per app or environment. Every key has its own app name, language and mode; Outbound OTP credits are shared by all keys of your account.
- Inbound: open
whatsapp.linkright after the user taps your “Send code” button, so they only need to press Send in WhatsApp. To avoid popup blockers, open the new tab before the request and set its URL when the response arrives. - Inbound on desktop: also show a QR code of the same link for scanning with the phone.
- Outbound: right after /otp-session, tell the user “Check WhatsApp and reply YES” and show the code input. If delivery.status becomes failed with not_on_whatsapp, ask the user to check the number.
- Set your app name and reply language in the dashboard. The WhatsApp reply reads, for example: “482913 adalah kode verifikasi untuk masuk ke YourApp.”
- Keep the code entry step. Skipping it would let attackers trick victims into sending the attacker’s token.
- Each session can be verified once. Start a new session after expired or blocked.