Send one-time verification codes via email for authentication and for verifying users’ email addresses.
Authsignal SDKs can be used to implement email OTP challenges in two scenarios.
Sign-in. Use our Server SDKs to authenticate users with email OTP as the 1st factor. This integration only requires an email address to initiate.
Adaptive MFA. Use Server SDKs together with Client SDKs to authenticate users with email OTP as a secondary factor. This integration requires a user ID to initiate and assumes the user has already been authenticated with a primary factor.
Navigate to Authenticators in the Authsignal Portal, find email OTP, and click Set up.
Choose an email provider. You can choose Authsignal for development but it’s recommended to use an alternative provider in production for more control over templates and delivery.
Scenario - Let users sign-in with email OTP as the 1st factor.
Our Server SDKs include methods to initiate and verify an OTP challenge for a given email address.
These methods are well-suited for passwordless sign-in scenarios where you need to authenticate a user with email OTP as a primary factor.
You can choose a value for the action here which best describes what the user is doing in your app (e.g. signing in with email).
It will be used to track user activity in the Authsignal Portal.
Now that the challenge has been verified, you can lookup the user in your IdP or DB based on their email.
For passwordless flows with a combined sign-up and sign-in UX, you may need to create the user at this point if no account exists.
Then claim the challenge once you know the primary user ID associated with the email.
Scenario - Challenge users with email OTP as a 2nd factor and use rules to decide when and
where in your app to trigger the challenge.
The following steps demonstrate how to implement adaptive MFA with email OTP - either at sign-in or as step-up authentication when the user performs a sensitive action in your app (e.g. making a payment).In this scenario we assume the user has already been identified by authenticating with another method (e.g. username and password) and is being prompted to complete an email OTP challenge as a 2nd factor.
You can choose a value for the action here which best describes what the user is doing in your app (e.g. signIn or createPayment).
Each action can have its own set of rules.
To learn more about using rules and handling different action states refer to our documentation on actions and rules.
If the action state is CHALLENGE_REQUIRED then you can present an email OTP challenge using the Web SDK or Mobile SDK.
Custom UI
Pre-built UI
Copy
Ask AI
// Set token from the track responseauthsignal.setToken("eyJhbGciOiJ...");// Send the user an email OTP code// You can call this multiple times via a 'resend' buttonawait authsignal.email.challenge();// Verify the inputted code matches the original codeconst response = await authsignal.email.verify({ code: "123456" });// Obtain a new tokenconst token = response.token;
Scenario - Enroll users in email OTP while they’re authenticated so it can be used later as a
method for adaptive MFA.
To use email OTP for adaptive MFA, users must be enrolled with email OTP as an authentication method.
This means their email address has previously been verified and can be trusted.The following steps demonstrate how to implement an enrollment flow using a Server SDK.
The add:authenticators scope is required to enroll a new email OTP authenticator for an existing user.
This scope should only be used when the user is in an already authenticated state.
For more information on using scopes safely refer to our documentation on authenticator binding.
The update:authenticators scope is required to update a user’s existing email OTP authenticator to change the email address.
This scope should only be used when the user is in an already authenticated state.
For more information on using scopes safely refer to our documentation on authenticator binding.
Scenario - Enroll or update an email OTP authenticator for a user when you’ve already verified
their email address in another system, so it can be used later as a method for adaptive MFA.
In some cases you may have already verified a user’s email address using another system.
This means the user can be enrolled without having to complete an email OTP challenge.