API reference
Verify a code
POST /api/v1/otp-verify — check a code the user entered against an otpId.
POST
/api/v1/otp-verifyChecks a code the user entered against the otpId you received from Send a verification code.
Headers
| Header | Value |
|---|---|
X-API-Key |
Your key (or Authorization: Bearer <key>) |
Content-Type |
application/json |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
otp_id |
string | Yes | The otpId value from the send response. otpId is accepted as an alias |
otp |
string | Yes | The code the user entered. code is accepted as an alias |
Only codes issued for your own account can be verified.
Response
Status 200 is returned for every verification outcome. Rely on the valid field.
Correct code:
JSON
{ "valid": true }
Incorrect code:
JSON
{ "valid": false, "reason": "Invalid OTP" }
reason |
Meaning |
|---|---|
OTP not found |
The ID does not exist or does not belong to your account |
Invalid OTP |
Wrong code (counts as an attempt) |
OTP expired |
The code has expired |
OTP already used |
The code was already used |
Too many attempts |
More than 5 wrong attempts; the code was invalidated |
After one successful verification, the code is used and cannot be verified again.
Errors
| Status | error |
|---|---|
400 |
otp_id and otp required |
401 |
Invalid API key |
403 |
plan_no_api / permission_denied (the key needs the otp permission) |
429 |
Too many requests (with a Retry-After header) |
Examples
curl -X POST https://waabek.com/api/v1/otp-verify \
-H "X-API-Key: $WABEK_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "otp_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "otp": "482913" }'
const res = await fetch("https://waabek.com/api/v1/otp-verify", {
method: "POST",
headers: {
"X-API-Key": process.env.WABEK_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ otp_id: otpId, otp: userInput }),
});
const { valid, reason } = await res.json();
if (!valid) console.warn("OTP rejected:", reason);
<?php
$ch = curl_init('https://waabek.com/api/v1/otp-verify');
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . getenv('WABEK_API_KEY'),
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'otp_id' => $_SESSION['otp_id'],
'otp' => $_POST['otp'],
]),
]);
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
if (!empty($result['valid'])) {
// Code accepted: sign the user in.
}
import os
import requests
resp = requests.post(
"https://waabek.com/api/v1/otp-verify",
headers={"X-API-Key": os.environ["WABEK_API_KEY"]},
json={"otp_id": otp_id, "otp": user_input},
timeout=30,
)
result = resp.json()
if result.get("valid"):
print("Verified")
else:
print("Rejected:", result.get("reason"))