Generate OTP

This page provides you with information on generating OTP.

👍

For detailed information about our APIs and for hands-on testing, refer documentation in API overview and step-by-step guide on making your first API call in Make your first API call .

🚧

Warning

Make sure that the OTP template does not have multiple placeholders for the OTP. This can lead to displaying OTP in all placeholders.

This API enables the issuing of validation code (OTP) to the defined communication channel for redeeming points/coupons, and registration.

Prerequisites

  • Basic or OAuth credentials
  • OTP access group resource with WRITE access
  • Make sure that the template contains a placeholder for OTP and that the appropriate templates are approved.
  • Make sure that you have configured appropriate OTP configurations as required. For more information, refer to the OTP configuration documentation.
  • Make sure that the channel gateway configuration is completed. For the configuration, create a JIRA ticket for the gateway team.
  • Make sure that the appropriate OTP template is configured and approved. For more information on the OTP template, refer to the OTP template documentation.

Resource information

URI/v2/otp/generate
HTTP methodPOST
Rate limit500 OTP per user in a day
Batch supportNo

OTP template selection hierarchy

First preference - OTP template defined in the API body

Second preference - The default template

Third preference - If no template is configured and the template field is left blank, the system uses the inbuilt Capillary template.

Request body parameters

📘

Notes

  • If the email template is not specified, the OTP will be sent in the default email template format specified below: “emailTemplate”:{ “subject”:“Validation Code”, “body”:“Dear Customer, The validation code for your request is: {{ validation_code }}. You will also receive the validation code by SMS on your registered mobile number shortly.” },
  • If SMS template is not specified, the OTP will be sent in the SMS format "Hi user.Your otp for validation is {{ validation_code }}."
Parameter Type Description

entityType

enum

Specify MOBILE to identify customer by mobile number or EMAIL to identify customer by email id.

entityValue

String

Value of the entity

action

String

Action performed. COUPON (for coupon redemption), POINTS (for points redemption), REGISTRATION, USERGROUP, SUBSCRIPTION, GENERIC (for other purposes), POINTSTRANSFER, CUSTOMER_STATUS_UPDATE, CUSTOMER_IDENTIFIER_CHANGE, CUSTOMER_ISSUE_LINK_CARD.

template

String

Defines the message template for sending OTP via SMS. Example: "Hi user. Your OTP for validation is {{ validation_code }}.Enjoy".
Notes:

  • Leave the template name blank if you want to use the pre-defined SMS template.
    If you leave the template name and do not have any pre-defined template, the system will use the default hardcoded template.
  • Templates are defined at action-level. Each action can have one template.

whatsappTemplateName

String

Approved WhatsApp template name. This is applicable only to WhatsApp communication.

zaloTemplateIdentifier

String

ZALO template identifier

emailTemplate

Object

Defines the message template for sending OTP via Email.
Notes:

  • Leave the template details blank if you want to use the pre-defined Email template.
  • If you do not add any template name and do not have any pre-defined template, the system will use the default hardcoded template.

-- subject

String

Email subject (e.g., Validation Code)

-- body

String

Email body template (e.g., Dear Customer, The validation code for your request is: {{ validation_code }}. You will also receive the validation code by SMS on your registered mobile number shortly.)

channels

Array

Array of communication channels

--- type

String

Type of channel. The supported channels are EMAIL, SMS, MOBILE or PHONE (phone call), ZALO, and WHATSAPP. The OTPs are sent to the defined channels simultaneously. For example, if you have defined SMS and Email, OTP will be sent to both Email and SMS channel simultaneously.
Note: The channel selected here should match with the channel selected in the (OTP configuration).

--- value

String

Value for the channel

{
   "entityType":"email",
   "entityValue":"[email protected]",
   "action":"REGISTRATION",
   "template":"Hi user.Your OTP for validation is {{ validation_code }}.Enjoy",
   "emailTemplate":{
      "subject":"Validation Code",
      "body":"Dear Customer, The validation code for your request is: {{ validation_code }}. You will also receive the validation code by SMS on your registered mobile number shortly."
   },
   "channels":[
      {
         "type":"SMS",
         "value":"9191919191"
      },
      {
         "type":"EMAIL",
         "value":"[email protected]"
      },
      {
         "type":"PHONE",
         "value":"9191919191"
      }
   ]
}

{
  "entityType": "mobile",
  "entityValue": "919986000581",
  "action": "POINTS",
   "whatsappTemplateName": "test_temp2",
  "channels": [
    {
      "type": "whatsapp",
      "value": "919986000586"
    }
    
  ]
}
{
   "entityType":"MOBILE",
   "entityValue":"911234567896",
   "action":"POINTSTRANSFER",
   "template":"Hi user.Your OTP for validation is {{ validation_code }}.Enjoy",
   "channels":[
      {
         "type":"SMS",
         "value":"911234567896"
      },
      {
         "type":"PHONE",
         "value":"911234567896"
      }

Response

ParameterTypeDescription
createdIdlongUnique ID generated for the current request.
{
    "createdId": 10,
    "warnings": []
}
📘

Note

If the OTPs are regenerated within the OTP expiry limit, the same OTP is generated again, and the createdId value appears as 1.

Error codes

Error code Description

607 Mandatory template name not passed for
whatsapp type channel

If whatsapp as a channel is provided in payload, make sure that whatsappTemplateName parameter is added

621 Zalo template identifier cannot be empty

If zalo as a channel is provided in payload, make sure that parameter zaloTemplateIdentifier is added

8056 Invalid mobile

Enter valid mobile number

608 Something went wrong while fetching otp template

Make sure that OTP templates are configured and approved

Gateway error

The Gateway configuration is not completed. Contact the Gateway team for the configuration.

Language
Credentials
Basic
base64
:
URL
Click Try It! to start a request and see the response here!