Authentication
Send OTP
Send SMS one-time password
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
Phone number in E.164 format (e.g., +1234567890) to send the OTP to.
Whether to create a new user if the phone number doesn’t exist. Defaults to false.
Additional user metadata to store if creating a new user.
Captcha token for verification if captcha is enabled.
Delivery channel for the OTP. Defaults to “sms”.Options:
sms- Send via SMS text messagewhatsapp- Send via WhatsApp (if configured)
Response
Unique identifier for the sent OTP message
Masked phone number that the OTP was sent to (e.g., “+1***-***-7890”)
Error Responses
OTP Authentication Flow
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:| Country | Format | Example |
|---|---|---|
| United States | +1XXXXXXXXXX | +12345678901 |
| United Kingdom | +44XXXXXXXXX | +447123456789 |
| Canada | +1XXXXXXXXXX | +12345678901 |
| Australia | +61XXXXXXXXX | +61412345678 |
| Germany | +49XXXXXXXXX | +4915123456789 |
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:| Limit Type | Limit | Window |
|---|---|---|
| Per Phone | 3 requests | 5 minutes |
| Per IP | 10 requests | 10 minutes |
Best Practices
User Experience
User Experience
- 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
Security
Security
- 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
SMS Delivery
SMS Delivery
- 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
Related Endpoints
Verify OTP
Verify SMS one-time password
Resend OTP
Resend SMS verification code
User Signup
Traditional email/password registration
Magic Link
Passwordless email authentication