Skip to main content
OTP verification takes two calls: authentica.otp.send() delivers a code to your user, and authentica.otp.verify() checks the code they enter.

Send OTP

Parameters

Pass either phone or email, matching the method. Passing both throws an AuthenticaValidationError and nothing is sent.

Examples

Template IDs and default OTP settings are managed in your application settings on the Authentica dashboard.

Response

boolean
Whether the API accepted the send request.
string
Message returned by the API.
The response has no verification ID. To verify, pass the same phone number or email together with the code your user entered.

Verify OTP

Parameters

Provide exactly one of phone or email.

Examples

Pass otp as a string, exactly as the user entered it. This preserves leading zeros. Do not assume a fixed code length.

Response

boolean
true if the OTP is valid.
string
Message returned by the API.

Handling a rejected code

A rejected code can come back in two ways, depending on the API response:
  • a normal result with status: false, or
  • an AuthenticaApiError with status 422.
Handle both:
A 422 does not always mean the code was mistyped. The code may have expired, or the request may have been rejected for another reason.
Never log OTP codes. Avoid logging phone numbers or email addresses unless you need them.
See also: OTP Verification Workflow and the Send OTP API Reference.