Documentation

Send OTP

POST https://otp.dearprime.in/api/v1/send-otp

Creates a one-time passcode, stores only a peppered hash of it, and delivers it over email, SMS or both.

Parameters

FieldTypeRequiredNotes
api_keystringYes**Or the X-API-Key header.
emailstringConditionalValid email address. Required if mobile is absent.
mobilestringConditionalDigits with optional country code. Required if email is absent.
purposestringNoShort label such as login, signup, reset. Defaults to verification.

Supply both email and mobile to send the same code on both channels under one request ID.

Request

{
  "api_key": "YOUR_API_KEY",
  "email": "user@example.com",
  "mobile": "919812345678",
  "purpose": "login"
}

Success - 200

{
  "success": true,
  "message": "OTP sent successfully",
  "request_id": "REQ_8F2A1C4B9D",
  "expires_in": 300,
  "channels": { "email": "sent", "sms": "sent" }
}

Store request_id against the user session - it is required to verify the code. expires_in is in seconds.

Failures

CodeHTTPMeaning
VALIDATION_ERROR422Missing or invalid destination / purpose.
RESEND_COOLDOWN429A code was already sent to this destination recently.
QUOTA_EXCEEDED429Daily or monthly quota reached.
DELIVERY_FAILED502No channel accepted the message.

Next: Verify OTP