Verify an OTPPOST /v1/otp/verify
Check the code your user typed against the one DiOTP sent. A 200 response means the number is theirs; every other outcome has its own error code.
OTP
Verify an OTP
Checks the code the user typed. A 200 means it matched; the code is then used up and cannot be verified again.
Body
- request_idstringrequiredThe
request_idfrom the send. - codestringrequiredWhat the user typed, 4 to 10 characters.
Response
- request_idstringrequiredThe request that was verified.
- verifiedbooleanrequiredAlways
trueon a200. - verified_atstring (ISO 8601)requiredWhen it was verified.
| Status | Code | What to do |
|---|---|---|
| 400 | invalid_code | Wrong code. Let the user try again. |
| 404 | not_found | Unknown request_id. |
| 409 | already_verified | This code was already verified once. |
| 410 | expired | More than five minutes passed. Send a new code. |
| 429 | too_many_attempts | Five wrong tries. Send a new code. |
curl -X POST https://api-diotp.diorbit.com/v1/otp/verify \ -H "Authorization: Bearer $DIOTP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "code": "482913" }'
const res = await fetch("https://api-diotp.diorbit.com/v1/otp/verify", { method: "POST", headers: { Authorization: `Bearer ${process.env.DIOTP_API_KEY}`, "Content-Type": "application/json", }, body: JSON.stringify({ request_id: requestId, code: codeTheUserTyped }), }); if (res.ok) { // The number is verified: sign the user in. } else { const { error } = await res.json(); // e.g. error.code === "invalid_code" }
res = requests.post(
"https://api-diotp.diorbit.com/v1/otp/verify",
headers={"Authorization": f"Bearer {os.environ['DIOTP_API_KEY']}"},
json={"request_id": request_id, "code": code_the_user_typed},
timeout=10,
)
if res.ok:
pass # The number is verified: sign the user in.
else:
error = res.json()["error"] # e.g. error["code"] == "invalid_code"<?php $ch = curl_init("https://api-diotp.diorbit.com/v1/otp/verify"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HTTPHEADER => [ "Authorization: Bearer " . getenv("DIOTP_API_KEY"), "Content-Type: application/json", ], CURLOPT_POSTFIELDS => json_encode([ "request_id" => $requestId, "code" => $codeTheUserTyped, ]), ]); $body = json_decode(curl_exec($ch), true); $verified = curl_getinfo($ch, CURLINFO_HTTP_CODE) === 200;
{
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"verified": true,
"verified_at": "2026-11-16T10:01:12+00:00"
}How verification works
When you send a code, DiOTP returns a request_id and keeps the code itself. Your server never sees it. When the user types the code into your app, your server sends the request_id and what they typed to this endpoint, and DiOTP compares the two. Only a 200 response means the number belongs to the person in front of you. Treat every other response as a failed check.
Each request allows five attempts within five minutes. A correct code uses the request up: it cannot be verified a second time, so a code read over someone's shoulder is worthless once the owner has used it. Verifying is free; only sending a code is charged.
Request and response examples
Call the endpoint from your server, never from the browser or the app, so your API key stays secret. The code is a string, so a leading zero is kept.
curl -X POST https://api-diotp.diorbit.com/v1/otp/verify \ -H "Authorization: Bearer $DIOTP_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7", "code": "048291" }'
{
"request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
"verified": true,
"verified_at": "2026-11-16T10:01:12+00:00"
}{
"error": {
"code": "invalid_code",
"message": "the code is not correct",
"request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
}
}{
"error": {
"code": "not_pending",
"message": "request is expired",
"request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
}
}What to show the user
- invalid_code: say the code is wrong and let them try again. Tell them how many tries are left if you count them.
- expired, too_many_attempts or not_pending: the request is finished. Offer to send a new code.
- already_verified: the number was confirmed a moment ago, usually by a double tap. Carry on as if this call succeeded.
- not_found: the request_id is wrong or belongs to another account. Check what your server stored.
Error codes
| Status | Code | Meaning |
|---|---|---|
| 400 | invalid_code | The code does not match. The user can try again until five attempts are used. |
| 401 | unauthorized | The API key is missing, wrong or revoked. |
| 404 | not_found | No request with this request_id on your account. |
| 409 | already_verified | This request was already verified once. |
| 409 | not_pending | The request already ended: it expired or ran out of attempts. Send a new code. |
| 410 | expired | More than five minutes passed since the code was sent. Returned once; later calls get not_pending. |
| 422 | invalid_request | request_id is missing, or code is not 4 to 10 characters. |
| 429 | too_many_attempts | Five attempts were used. Returned once; later calls get not_pending. |
Verify an OTP: FAQ
No. DiOTP never returns the code to you, so only the verify endpoint can check it. That is deliberate: a code that never reaches your servers cannot leak from your logs or database.
Codes are digits, and verification is the same whether the code went out by SMS or WhatsApp. Send exactly what the user typed, as a string.
No. Verify calls are not charged, right or wrong. Only sending a code uses your balance.
Store the request_id against the user or session when you send the code, and look it up when they submit. DiOTP only checks that the request belongs to your account.
Need help integrating?
Our team helps with integration, DLT templates and going live.

