Standard Status Code for One Time Password(OTP) Verification API

Viewed 1565

I am using below status codes for Verification API. Are they correct? If not what should be standard status codes for below scenarios.

  • OTP validation Successful(200)

  • OTP is not verified(401)

  • OTP is Expired(410)

  • OTP resend limit exceeded(429)

  • OTP is invalid(409)

  • OTP is already verified(409)

1 Answers

OTP lifie cycle ::

ACTIVE – The OTP is still active

VERIFIED – The OTP was verified successfully

EXPIRED – The OTP expired

TOO_MANY_ATTEMPTS – The OTP validation requests exceeded the maximum allowed by the application configuration

OTP status code ::

  1. 202 Accepted => OTP validation Successful

  2. 403 Forbidden => which will return once all of the allowed attempts are reached to verify the code and were all unsuccessful (three by default) or the OTP code has expired (after five minutes, by default)

  3. 410 Gone => Once an OTP reaches a final state (verified, expired or failed after too many attempts), the API always returns HTTP response code "410 Gone"

  4. 401 => OTP is not valid ( Unauthorized ).

Related