This guide provides step-by-step instructions for user self-registration, authentication, and token refresh in our system. It includes details on how to use the "Accept-Language" header for localized responses and the "X-Device-ID" header for device identification.
{ "message": "We've sent a verification code to your email. Please check and enter the code to complete your registration.", "user_id": "12345678-1234-1234-1234-123456789012"}
This is the only step that turns an MFA login into a full session (access_token + refresh cookie).
Do not confuse with credential enrollment. Adding a phone or email credential via /v1/users/credentials is account setup. Login MFA is driven by the user's mfa_mode and /v1/verify-2FA. See Authentication API and Verify 2FA.
Use the Accept-Language header to specify your preferred language for response messages.
Supported values are en (English), de (German), fr (French), and it (Italian).
If not specified, the system will default to English.
Security:
Always use HTTPS for all API communications.
Store the access token securely on the client-side.
The refresh token is automatically managed by the server using HTTP-only cookies.
Treat challenge_token as pre-auth only: use X-MFA-Challenge on /v1/verify-2FA (when enabled), or Authorization: Bearer {challenge_token} only on explicit TOTP setup routes. Never use it on protected APIs or refresh.
Device and app identity:
Use a consistent X-Device-ID for the same device across authentication, verify-2FA, and refresh.
Send X-App-ID (for example web-app) on authenticate, verify-2FA, and refresh so refresh cookies stay scoped per application.
Token Management:
The access token has a shorter lifespan (15 minutes by default) than the refresh token (14 days by default).
Implement logic to handle token expiration and refresh scenarios in your application.
If authentication fails (401 Unauthorized), attempt to refresh the token. If that fails, prompt the user to re-enter their credentials.
Error Handling:
Implement proper error handling for various HTTP status codes.
Pay attention to rate limiting and temporary lock-out scenarios, especially during authentication.
Compliance:
Ensure users accept the terms and conditions and privacy policy during registration.
Handle user data in compliance with relevant data protection regulations.
Specific origins may be restricted based on server configuration.
By following these steps and best practices, you can implement a secure and localized user registration and authentication process in your application.