Skip to main content

Send Email 2FA Code

POST 

/api/auth/2fa/email/send

Send an email containing a 2FA code to the user.

Learn more about email as 2FA method here.

This endpoint is used to send a 2FA email code for enabling email as a 2FA method and to resend 2FA codes when authenticating user that already enabled email as a 2FA method.

Note: Each request will generate a new code and invalidate all old codes.

If email is the preferred 2FA method, an email will be sent automatically after successful authentication with the user's password. You can learn more about preferred 2FA methods here.

Requirements

  • The user can authenticate using password. 2FA will not work with OAuth2. The OAuth2 provider will validate the second factor if the user enabled it for the provider.

Locale

A locale can be specified for this request. The email will be sent in the specified locale. You can learn more about locale in emails here.

If no locale is specified, the applications default locale will be used. You can learn more about configuring the default locale here.

Tokens

There are two options:

  1. If email as a 2FA method is disabled, you can request an email with a token to enable it. In this case you need a valid AccessToken. If email is already enabled, this request will return 400 - BAD REQUEST.
  2. If email as 2FA method is already enabled, you can request a 2FA email code with a valid TwoFactorAuthenticationToken.

Note: After each email, a cooldown will be started. When the cooldown is active, no new email can be sent. You can request the remaining cooldown throw the endpoint GET /api/auth/2fa/email/cooldown. The cooldown can be configured here.

Request

Responses

Success.