Overview
Verify a one-time password (OTP) code that was previously sent via SMS. This endpoint validates the code against the request ID returned from the Initiate OTP endpoint.Endpoint
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
request_id | string (UUID) | ✅ | The request ID returned from the initiate OTP endpoint |
code | string | ✅ | The OTP code entered by the user |
Parameter Details
request_id
request_id
The unique identifier returned when the OTP was initiated.
- Format: UUID (e.g.,
8c8a6f2f-9a3b-4d86-9b2c-1e3f8f9c2ab1) - Source: Returned from the Initiate OTP endpoint
- Validity: Must correspond to an active, non-expired OTP request
code
code
The OTP code that the user received via SMS.
- Format: Numeric string (4 or 6 digits)
- Case sensitivity: Not applicable (numeric only)
- Validation: Must match the generated code exactly
Response
Success Response (200 OK)
Response Fields
| Field | Type | Description |
|---|---|---|
message | string | Success message |
phone_number | string | The phone number associated with this OTP |
verified_at | string | ISO 8601 timestamp when verification occurred |
attempts_used | integer | Number of verification attempts used |
max_attempts | integer | Maximum allowed verification attempts |
Error Responses
400 Bad Request - Invalid Code
400 Bad Request - Expired OTP
400 Bad Request - Too Many Attempts
404 Not Found - Invalid Request ID
401 Unauthorized
403 Forbidden
Verification Rules
Attempt Limits
- Maximum attempts: 3 verification attempts per OTP request
- Lockout: After 3 failed attempts, the OTP becomes invalid
- New request required: Must initiate a new OTP after lockout
Expiration
- Time-based: OTP expires based on the expiration time set during initiation
- Single use: Once successfully verified, the OTP cannot be used again
- Automatic cleanup: Expired OTPs are automatically cleaned up
Implementation Example
Security Considerations
Rate Limiting
Implement client-side delays between verification attempts
Secure Storage
Never log or store the actual OTP codes
Attempt Tracking
Monitor failed attempts for potential abuse
Cleanup
Clear OTP data after successful verification
Best Practices
Client-Side Validation
Error Handling Strategy
- Invalid Code: Allow retry with remaining attempts
- Expired OTP: Prompt user to request new OTP
- Max Attempts: Force new OTP request
- Network Error: Allow retry with same code
User Experience Tips
- Show remaining attempts to users
- Display expiration countdown
- Provide clear error messages
- Auto-submit when code length is reached