API v1REST · JSON · HTTPS

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

POST/v1/otp/verify

Checks the code the user typed. A 200 means it matched; the code is then used up and cannot be verified again.

Body

  • request_idstringrequired
    The request_id from the send.
  • codestringrequired
    What the user typed, 4 to 10 characters.

Response

  • request_idstringrequired
    The request that was verified.
  • verifiedbooleanrequired
    Always true on a 200.
  • verified_atstring (ISO 8601)required
    When it was verified.
StatusCodeWhat to do
400invalid_codeWrong code. Let the user try again.
404not_foundUnknown request_id.
409already_verifiedThis code was already verified once.
410expiredMore than five minutes passed. Send a new code.
429too_many_attemptsFive 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"
  }'
Response200 OK
{
  "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.

Request
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" }'
Correct code200 OK
{
  "request_id": "7c9e6679-7425-40de-944b-e07fc1f90ae7",
  "verified": true,
  "verified_at": "2026-11-16T10:01:12+00:00"
}
Wrong code400 Bad Request
{
  "error": {
    "code": "invalid_code",
    "message": "the code is not correct",
    "request_id": "3f1c9a0e5b7d4e2a8c6f1b0d9e8a7c6b"
  }
}
Request already finished409 Conflict
{
  "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

StatusCodeMeaning
400invalid_codeThe code does not match. The user can try again until five attempts are used.
401unauthorizedThe API key is missing, wrong or revoked.
404not_foundNo request with this request_id on your account.
409already_verifiedThis request was already verified once.
409not_pendingThe request already ended: it expired or ran out of attempts. Send a new code.
410expiredMore than five minutes passed since the code was sent. Returned once; later calls get not_pending.
422invalid_requestrequest_id is missing, or code is not 4 to 10 characters.
429too_many_attemptsFive 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.

Need help integrating?

Our team helps with integration, DLT templates and going live.