# Two-Factor Authentication Message Template

Learn when FusionAuth sends the message with a multi-factor code, and which variables the template receives.

> For the index of this section of the site, see [llms.txt](https://fusionauth.io/docs/llms.txt)

> **PLAN:** This feature requires [at least a Starter plan](https://fusionauth.io/docs/concepts/plans-and-limits/plans-features.md#starter-features).

FusionAuth sends this message with a code when a user completes a multi-factor login with the `sms` method, or enables or disables the `sms` method. FusionAuth renders the text template by default, and the voice template when the request sets **`messageType`** to `Voice`. Assign the templates in **SMS template** and **Voice template** under Tenants -> Your Tenant -> Multi-Factor -> Phone settings . To override the templates for one Application, set **SMS template** and **Voice template** on the Application's Multi-Factor tab.

## Default Templates

FusionAuth ships a default text template and a default voice template. The voice template uses **`spokenCode`**, so a voice service reads the digits one at a time:

```ftl
Two Factor Code: ${code}
```

```ftl
This is your two factor code: ${spokenCode}, repeat ${spokenCode}
```

## Replacement Variables

`application`

*   Type: `Application`

The Application object. For field definitions, see the [Application API](https://fusionauth.io/docs/apis/applications.md).

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

```ftl
[#if application??]
  ${application.name}
[/#if]
```

`baseUrl`

*   Type: `String`
*   Available since `1.68.0`

The base URL for links in the message. 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.

`email`

*   Type: `String`

The email address on the two-factor method. A method that sends messages usually has no email address, so check for the variable before you use it.

`phoneNumber`

*   Type: `String`
*   Available since `1.59.0`

The **`mobilePhone`** of the two-factor method. Before `1.59.0`, the variable was named **`mobilePhone`**. The [Generic messenger](https://fusionauth.io/docs/messengers/generic-messenger.md) request has the same value in **`phoneNumber`**.

`spokenCode`

*   Type: `String`
*   Available since `1.65.0`

The code with the digits separated, so a voice service reads them one at a time. The variable is present only in the voice template.

`tenant`

*   Type: `Tenant`

The Tenant object. For field definitions, see the [Tenant API](https://fusionauth.io/docs/apis/tenants.md).

`user`

*   Type: `User`

The User object for the recipient. For field definitions, see the [User API](https://fusionauth.io/docs/apis/users.md).

`userId`

*   Type: `UUID`

The Id of the user. The [Generic messenger](https://fusionauth.io/docs/messengers/generic-messenger.md) request has the same value in **`userId`**.

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

*   [Start Multi-Factor](https://fusionauth.io/docs/apis/two-factor/start-multi-factor.md).
*   The [Login API](https://fusionauth.io/docs/apis/login/authenticate.md), when multi-factor authentication is required. A production login request should always include **`applicationId`**.
*   The requests that send a code to [enable](https://fusionauth.io/docs/apis/two-factor/send-a-multi-factor-code-when-enabling-mfa.md) or [disable](https://fusionauth.io/docs/apis/two-factor/send-a-multi-factor-code-when-disabling-mfa.md) a method.

Related

[Email Two-Factor Authentication Email Template Learn when FusionAuth sends the email that contains a two-factor code, and which variables the template receives. two-factor templatemulti-factor authenticationfreemarker](https://fusionauth.io/docs/email/template-reference/security/two-factor-authentication.md)

[Messengers Message Template Reference Learn about the message templates FusionAuth sends through messengers and the replacement variables each template receives. freemarkermulti-factor authentication](https://fusionauth.io/docs/messengers/template-reference.md)

[APIs Create an Email Template API API documentation for the FusionAuth Create an Email Template API. freemarker](https://fusionauth.io/docs/apis/emails/create-an-email-template.md)

[APIs Email API Learn about the APIs for creating, retrieving, updating and deleting email templates as well as sending emails to users. freemarker](https://fusionauth.io/docs/apis/emails.md)
---

## Other pages in Security

> For the full index of this section, see [Messengers](https://fusionauth.io/docs/llms-messengers.txt).

- [Admin Two-Factor Method Removed Message Template](https://fusionauth.io/docs/messengers/template-reference/security/admin-two-factor-method-removed.md): Learn when FusionAuth sends the message that tells a user an administrator removed a two-factor method, and which variables the template receives.
- [Identity Update Message Template](https://fusionauth.io/docs/messengers/template-reference/security/identity-update.md): Learn when FusionAuth sends the message that tells a user their phone number changed, and which variables the template receives.
- [Login Id Duplicate on Create Message Template](https://fusionauth.io/docs/messengers/template-reference/security/login-id-duplicate-on-create.md): Learn when FusionAuth sends the message that tells a user someone tried to sign up with their login Id, and which variables the template receives.
- [Login Id Duplicate on Update Message Template](https://fusionauth.io/docs/messengers/template-reference/security/login-id-duplicate-on-update.md): Learn when FusionAuth sends the message that tells a user another account tried to take their login Id, and which variables the template receives.
- [Password Reset Success Message Template](https://fusionauth.io/docs/messengers/template-reference/security/password-reset-success.md): Learn when FusionAuth sends the message that confirms a password reset, and which variables the template receives.
- [Password Update Message Template](https://fusionauth.io/docs/messengers/template-reference/security/password-update.md): Learn when FusionAuth sends the message that tells a user their password changed, and which variables the template receives.
- [Threat Detected Message Template](https://fusionauth.io/docs/messengers/template-reference/security/threat-detected.md): Learn when FusionAuth sends the message about a new device or suspicious login, and which variables the template receives.
- [Two-Factor Method Added Message Template](https://fusionauth.io/docs/messengers/template-reference/security/two-factor-method-added.md): Learn when FusionAuth sends the message that tells a user a two-factor method was added, and which variables the template receives.
- [Two-Factor Method Removed Message Template](https://fusionauth.io/docs/messengers/template-reference/security/two-factor-method-removed.md): Learn when FusionAuth sends the message that tells a user a two-factor method was removed, and which variables the template receives.
