Two-Factor Authentication Email Template

On this page

FusionAuth sends this email with a code when a user completes a multi-factor login with the email method, or enables or disables the email method. Assign the template in Template under Tenants -> Your Tenant -> Multi-Factor -> Email settings . To override the template for one Application, set Email template on the Application's Multi-Factor tab.

Default Template#

FusionAuth ships the following default template:

<p>
  To complete your login request, enter this one-time code code on the login form when prompted.
</p>
<p>
  <strong>${code}</strong>
</p>

- FusionAuth Admin
To complete your login request, enter this one-time code code on the login form when prompted.

${code}

- FusionAuth Admin

Replacement Variables#

application
  • Type: Application
  • Available since 1.46.0

The Application object. For field definitions, see the Application API.

The variable is present only when the request that sends the email identifies an Application. Check for the variable before you use it:

[#if application??]
  ${application.name}
[/#if]
baseUrl
  • Type: String
  • Available since 1.68.0

The base URL for links in the email. FusionAuth uses the Application baseURL, then the Tenant baseURL, then http://localhost:9011.

code
  • Type: String

The code the user enters to complete multi-factor authentication.

tenant
  • Type: Tenant
  • Available since 1.18.2

The Tenant object. For field definitions, see the Tenant API.

user
  • Type: User

The User object for the recipient. For field definitions, see the User API.

The application variable is missing when a request that sends the code has no applicationId. The requests are the following:

  • Start Multi-Factor.
  • The Login API, when multi-factor authentication is required. A production login request should always include applicationId.
  • The requests that send a code to enable or disable a method.