Phone OTP Webhook
Phone OTP Webhook (2FA SMS Verification)
This webhook enables you to send phone-based two-factor authentication (2FA) OTP codes via your own SMS provider. When a submitter with require_phone_2fa: true tries to access the signing form, SealRoute will call your webhook endpoint with the OTP code instead of sending it directly.
Use Cases
- Use your own SMS gateway (Twilio, AWS SNS, etc.)
- Custom SMS branding and formatting
- Cost control over SMS sending
- Integration with existing notification systems
Configuration
Via Settings UI
- Go to Settings → Phone OTP Webhook
- Enter your webhook URL
- Optionally add a Bearer token for authentication
- Save
Environment/Admin API
The webhook is stored in EncryptedConfig with key phone_otp_webhook:
Code
Webhook Payload
When a submitter needs phone verification, SealRoute sends a POST request:
Code
Payload Fields
| Field | Type | Description |
|---|---|---|
phone_number | string | Submitter's phone number (E.164 format) |
otp | string | 6-digit OTP code to send via SMS |
timestamp | string | ISO 8601 timestamp when the OTP was generated |
submitter_id | integer | Unique identifier of the submitter |
submitter_email | string | Submitter's email address (if provided) |
submitter_name | string | Submitter's name (if provided) |
submission_id | integer | Unique identifier of the submission |
template_name | string | Name of the template |
Request Headers
Code
The Authorization header is only included if you configured a bearer token.
Expected Response
Your webhook should return a 2xx status code to indicate success:
Code
If your webhook returns a non-2xx status, SealRoute will log the failure and the OTP will not be considered delivered.
OTP Validity
- OTP codes are valid for 10 minutes (drift behind window)
- OTP codes are 6 digits
- Generated using TOTP (Time-based One-Time Password) algorithm with SHA1
- A new code is generated every 30 seconds (standard TOTP interval)
Enabling Phone 2FA in API
To require phone verification for a submitter, use the require_phone_2fa parameter:
Create Submission with Phone 2FA
Code
Using /api/submissions/docx
Code
Submitter Parameters for 2FA
| Parameter | Type | Default | Description |
|---|---|---|---|
require_phone_2fa | boolean | false | Require phone OTP verification to access documents |
require_email_2fa | boolean | false | Require email OTP verification to access documents |
phone | string | - | Phone number (required if require_phone_2fa: true) |
email | string | - | Email address (required if require_email_2fa: true) |
Example Webhook Handler (Python)
Code
Example Webhook Handler (Node.js)
Code
Security Considerations
- Validate Bearer Token: Always verify the
Authorizationheader matches your configured token - Use HTTPS: Ensure your webhook endpoint uses HTTPS
- Rate Limiting: Implement rate limiting on your webhook endpoint
- Logging: Log all OTP requests for audit purposes
- Don't Store OTPs: Never store OTP codes; they're time-based and will expire
Troubleshooting
Webhook Not Being Called
- Check that the Phone OTP Webhook URL is configured in Settings
- Verify the submitter has
require_phone_2fa: true - Ensure the submitter has a valid phone number
OTP Verification Failing
- OTP codes expire after 10 minutes
- Ensure the user enters the code exactly as received (6 digits)
- Check server time synchronization (NTP)
Webhook Returning Errors
Check the submission events for send_2fa_phone event type which includes:
webhook_status: HTTP status code returnedwebhook_success: Boolean indicating success
Related
- Form Webhook - Form events (viewed, started, completed)
- Submission Webhook - Submission lifecycle events
- Template Webhook - Template events