Verify the WhatsApp code the user typed through the API
The reference for the verify address of ArabyBot's OTP API: the fields, the response, a wrong code and the attempts left, an expired code, and the refusals.
On this page 8
The short answer
With a POST request to the verify address carrying the request id and the code the user typed. If the code matches, the response returns success with the phone number and the time of verification. A code verifies once, a wrong code comes back with the number of attempts remaining, and once they are used up the user asks for a new code.
Also asked as: «اتحقق من كود الواتساب في الكود ازاي» · «التحقق من رمز otp واتساب» · «verify whatsapp otp code api»
The address and authentication
POST https://app.arabybot.com/wa_otp_api/verify
Send the OTP app's public key in the header X-Public-Key: ab_otp_…. You create the app in the OTP section of the dashboard, which gives you the public key and a secret shown once. If you switched request signing on for the app, add the header X-Signature: sha256=…, an HMAC-SHA256 of the raw request body keyed with the app secret.
The fields
request_id(required) The request id returned when the code was sent.code(required) The code the user typed.
An example request
cURL
curl -X POST https://app.arabybot.com/wa_otp_api/verify \
-H "X-Public-Key: ab_otp_YOUR_PUBLIC_KEY" \
-H "Content-Type: application/json" \
-d '{ "request_id": "3f6c2a9e-41b7-4c0d-9a51-7e2b8d4f1c60", "code": "482913" }' PHP
$ch = curl_init('https://app.arabybot.com/wa_otp_api/verify');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['X-Public-Key: ab_otp_YOUR_PUBLIC_KEY', 'Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'request_id' => '3f6c2a9e-41b7-4c0d-9a51-7e2b8d4f1c60',
'code' => '482913',
]),
]);
$answer = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
curl_close($ch); Python
import requests
r = requests.post(
'https://app.arabybot.com/wa_otp_api/verify',
headers={
"X-Public-Key": "ab_otp_YOUR_PUBLIC_KEY",
},
json={
"request_id": "3f6c2a9e-41b7-4c0d-9a51-7e2b8d4f1c60",
"code": "482913",
},
timeout=30,
)
print(r.status_code, r.json()) Node.js
// Node.js 18+
const r = await fetch('https://app.arabybot.com/wa_otp_api/verify', {
method: 'POST',
headers: {"X-Public-Key": "ab_otp_YOUR_PUBLIC_KEY", "Content-Type": "application/json"},
body: JSON.stringify({
"request_id": "3f6c2a9e-41b7-4c0d-9a51-7e2b8d4f1c60",
"code": "482913"
}),
});
console.log(r.status, await r.json());
The response
200
{ "success": true, "request_id": "3f6c2a9e-41b7-4c0d-9a51-7e2b8d4f1c60",
"phone": "966501234567", "verified_at": "2026-11-16 18:05:02" } - A code verifies once; the same verification asked a second time comes back with status 410.
What we measured on this API
Half of the users typed the code within 13 to 25 seconds, and nine in ten within 46 seconds; so a validity of a few minutes is enough. Of every hundred codes sent, about 75 were verified. The limit of this measurement is that one app carries 91% of the sends; these are these apps' figures, not a general average.
The refusals
Every refusal comes back as JSON with "success": false, an error_code and a message, plus retry_after in seconds when the cause is a rate limit:
- 401
invalid_code: The code is wrong; the attempts left are inattempts_remaining. - 401
missing_key / invalid_key: The public key is missing or wrong. - 401
missing_signature / bad_signature: The app requires request signing and the signature is missing or does not match. - 404
not_found: No request with this id. - 410
expired / already_resolved: The code has expired, or the request was already resolved. - 422
missing_fields: The request id or the code is missing. - 429
too_many_attempts: The attempts are used up; request a new code.
The limits
Every code is a paid WhatsApp message at Meta's authentication rate for the recipient's country. For protection there are limits on requests per phone number and per app, per minute and per day; passing them returns status 429 with retry_after in seconds.
The OTP API guide · All APIs for developers
Frequently asked questions
How many times can the user get the code wrong?
With every wrong code the attempts left come back in attempts_remaining. Once they are used up the request returns too_many_attempts, and you request a new code.
Where do I call verification from: the browser or the server?
From your server. The result of verification is what opens the account or confirms the order, so never leave it to a page the visitor controls, and never put the app secret in a browser.
Read next
Try the agent before you pay anything
The agent that will answer your customers is the one answering you now: ask it from the chat button here or on WhatsApp. Your account is free with no credit card, and the free trial on your own number or page is activated after you contact our team on customer-service WhatsApp.