Skip to main content
POST
Send a one-time password (OTP) via SMS for phone number verification or passwordless authentication. This endpoint supports both user registration and login flows.
This endpoint does not require authentication and can create new users if create_user is set to true.

Request Body

string
required
Phone number in E.164 format (e.g., +1234567890) to send the OTP to.
boolean
Whether to create a new user if the phone number doesn’t exist. Defaults to false.
object
Additional user metadata to store if creating a new user.
string
Captcha token for verification if captcha is enabled.
string
Delivery channel for the OTP. Defaults to “sms”.Options:
  • sms - Send via SMS text message
  • whatsapp - Send via WhatsApp (if configured)

Response

string
Unique identifier for the sent OTP message
string
Masked phone number that the OTP was sent to (e.g., “+1***-***-7890”)

Error Responses

OTP Authentication Flow

1

Request OTP

User enters their phone number and requests an OTP
2

SMS Sent

A 6-digit OTP is sent to the user’s phone via SMS
3

User Enters Code

User enters the OTP code in your application
4

Verification

Verify the OTP using the verify endpoint to complete authentication

Implementation Examples

React OTP Request Form

React OTP Verification Form

Complete Phone Authentication Component

Node.js Backend Handler

Phone Number Formats

Supported Formats

The API accepts phone numbers in E.164 format:

Format Validation

Security Features

  • Rate Limiting: Prevents SMS spam and abuse
  • OTP Expiration: Codes expire after 5 minutes
  • Single Use: Each OTP can only be used once
  • Phone Verification: Inherent phone number verification
  • Secure Generation: Cryptographically secure random codes

Rate Limiting

This endpoint is rate limited to prevent abuse:

Best Practices

  • Provide clear phone number formatting guidance
  • Show masked phone number during verification
  • Implement auto-advancing OTP input fields
  • Include countdown timer for resend functionality
  • Offer alternative authentication methods
  • Use 6-digit codes with sufficient entropy
  • Implement proper rate limiting
  • Set reasonable OTP expiration (5 minutes)
  • Log OTP requests for security monitoring
  • Validate phone number formats server-side
  • Use reliable SMS providers with good delivery rates
  • Include clear sender identification
  • Monitor delivery rates and costs
  • Respect opt-out requests and regulations
  • Consider international SMS costs and restrictions

Testing

Unit Tests

Verify OTP

Verify SMS one-time password

Resend OTP

Resend SMS verification code

User Signup

Traditional email/password registration

Magic Link

Passwordless email authentication