Skip to main content

OTP Verification Workflow

To implement OTP verification, follow these steps:

1. Send OTP

Use the /send-otp endpoint to send an OTP via SMS, WhatsApp, or Email. Supports:
  • Custom OTPs
  • SMS delivery via your own sender name registered with Authentica or default sender name offered by Authentica
  • Email delivery via your own email address registered with Authentica or default email address offered by Authentica
  • Control fallback channel, templates with ids 1 and 2 will be used for the fallback OTP based on the language of the main template you used in the request
Note: Check Application setting on Authentica dashboard to set default values for OTP options.

Example Request

curl --location 'api.authentica.sa/api/v2/send-otp' \
--header 'Accept: application/json' \
--header 'X-Authorization: $2y$10$XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
--header 'Content-Type: application/json' \
--data '{
    "method":"sms",
    "phone":"+9665XXXXXXXXX",
    "template_id":31,
    "fallback_email":"email@test.test",
    "otp":"123456"
}'

2. Verify OTP

Use the Verify OTP endpoint to validate the OTP entered by your customer.

Example Request

curl --location 'api.authentica.sa/api/v2/verify-otp' \
--header 'X-Authorization: $XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
    "phone":"+9665XXXXXXXX",
    "email":"email@test.test",
    "otp":"OTP-ENTERED-BY-THE-USER"
}'
See the API Reference for detailed parameter documentation.