Skip to content

Generate And Validate OTP

Use this pair of endpoints when your app must prove a phone number: login, checkout, or password reset. The platform generates the OTP using a verification configuration you created in the dashboard, sends it to the handset, and later checks the code the user types.

Flow

  1. Create a verification configuration in the dashboard (channel, template, expiry). Copy its id — that is configId.
  2. Call Generate OTP with configId and to. The response data value is verifyId.
  3. The user receives the OTP on the channel that configuration uses (SMS or otherwise).
  4. Call Verify OTP with that verifyId and the otp the user entered.
  5. On success, grant the action in your app. Do not reuse the same verifyId.

Endpoint

https://api.azmarq.com/v1/verify

Headers

  • Name
    Content-Type
    Type
    string
    Description

    application/json

  • Name
    apikey
    Type
    string
    Description

    Dashboard API key. See Authentication.

Generate OTP

Creates a one-time password for to using the dashboard configuration in configId. The OTP is single-use and expires after the timeframe set on that configuration. Store the data value from the response — you need it as verifyId.

Required attributes

  • Name
    configId
    Type
    string
    Description

    ID of the verification configuration that controls channel, template, and expiry.

  • Name
    to
    Type
    string
    Description

    Recipient MSISDN with country code, for example 91XXXXXXXXXX.

Request

curl --location --request POST 'https://api.azmarq.com/v1/verify' \
--header 'Content-Type: application/json' \
--header 'apikey: YOUR_API_KEY' \
--data-raw '{
  "configId": " a73cd9xe-XXXX-XXXX-XXXX-7f731bcf4y64",
  "to": "91XXXXXXXXXX "
}'

Response

  {
      "data": "33888968-XXXX-XXXX-XXXX-3010e0069668",
      "error": null,
      "message": "OTP Generated Successfully!"
  }

Verify OTP

Checks the code the user submitted against the OTP created for verifyId. On success, message is OTP Verified Successfully!. Use this once; a second verify on the same id will not succeed.

Required attributes

  • Name
    verifyId
    Type
    string
    Description

    The Verify ID which was sent in the Generate OTP API response.

  • Name
    otp
    Type
    string
    Description

    One Time Password which was sent to the users to validate them.

Request

curl --location --request POST 'https://api.azmarq.com/v1/verify/validate' \
--header 'Content-Type: application/json' \
--header 'apikey: YOUR_API_KEY' \
--data-raw '{
  "verifyId": "33888968-XXXX-XXXX-XXXX-3010e0069668",
  "otp": "XXXXXX"
}'

Response

{
    "data": "33888968-XXXX-XXXX-XXXX-3010e0069668",
    "error": null,
    "message": "OTP Verified Successfully!"
}

Was this page helpful?