Key Concepts
- TOTP Device: A registered authenticator (e.g., Google Authenticator, Authy) that generates time-based codes
- Device Verification: New devices must be verified with a valid TOTP code before they can be used for authentication
- Code Verification: After device verification, TOTP codes can be used to authenticate users
- Rate Limiting: Failed verification attempts are tracked and limited to prevent brute force attacks
Device Lifecycle
- Create Device - Register a new TOTP device and receive a secret key
- Verify Device - Confirm the device works by providing a valid TOTP code
- Use Device - Verify TOTP codes during authentication
- Manage Devices - List, update, or remove devices
Available Endpoints
Device Management
POST /recipe/totp/device- Create a new TOTP devicePUT /recipe/totp/device- Update (rename) an existing deviceGET /recipe/totp/device/list- Get all devices for a userDELETE /recipe/totp/device- Remove a TOTP devicePOST /recipe/totp/device/import- Import an existing TOTP device
Verification
POST /recipe/totp/device/verify- Verify a newly created devicePOST /recipe/totp/verify- Verify a TOTP code for authentication
Response Format
All endpoints return JSON responses with astatus field. Common status values:
OK- Request succeededUNKNOWN_DEVICE_ERROR- The specified device does not existUNKNOWN_USER_ID_ERROR- No TOTP devices found for the userINVALID_TOTP_ERROR- The provided TOTP code is incorrectLIMIT_REACHED_ERROR- Too many failed attempts, retry after the specified timeDEVICE_ALREADY_EXISTS_ERROR- A device with that name already exists
Security Features
Rate Limiting
TOTP verification includes built-in rate limiting:- Failed attempts are tracked per user
- After reaching the maximum number of failed attempts, users must wait before retrying
- The
LIMIT_REACHED_ERRORresponse includesretryAfterMsindicating when to retry
Device Parameters
- Skew: Number of time windows to check (default: 1)
- Period: Time window duration in seconds (default: 30)
Next Steps
Create TOTP Device
Register a new authenticator device
Verify Device
Verify a newly created device
Verify TOTP Code
Authenticate with a TOTP code