> For the complete documentation index, see [llms.txt](/docs/llms.txt)

# Message Variables | FusionAuth Docs

Learn which replacement variables and corresponding message templates are available.

# Message Variables

The message template body supports replacement variables. This means place holders can be inserted and the value will be calculated at the time the message template is rendered and sent to a user.

Most templates will contain the User object as returned on the Retrieve User API. This means you can utilize any value found on the User object such as email, first name, last name, etc.

Below you will find each stock template that FusionAuth ships for reference. The available replacement values will be outlined below for each template.

## Previewing Message Templates[#](#previewing-message-templates)

FusionAuth provides the capability to preview message templates via the [Message Template API](/docs/apis/message-templates) or the administrative user interface by navigating to Customizations -> Message Templates -> Edit -> Preview . The following sample values are used when rendering the template.

| Parameter | Sample Value | Purpose |
| --- | --- | --- |
| `${application}` | `{ "name": "My Application", "oauthConfiguration": { "clientId": "123456" } }` | Application name, `oauthConfiguration.clientId` for themed message links |
| `${baseUrl}` | `https://example.com` | Base URL used when rendering links in message templates. |
| `${changePasswordId}` | `1234567890` | Embedded in change password and set password URLs |
| `${code}` | `123456` | Embedded in MFA/Two-Factor messages |
| `${event}` | `{ "type": "UserLoginSuspicious", "info": {...} }` | Embedded in User Event messages |
| `${method}` | `{ "id" : "FQLM", "method" : "email" }` | Embedded in Two-Factor Add/Remove event messages |
| `${oneTimeCode}` | `88888` | Embedded in passwordless login messages |
| `${spokenCode}` | `1 2 3 4 5 6` | Embedded in MFA/Two-Factor messages when sent via voice. Use instead of `{code}` so the code is not read as a single number. |
| `${tenant}` | `{ "name": "My Tenant", "id": "78910" }` | `tenant.id` allows links embedded in messages to render using the correct theme for that tenant. |
| `${user}` | `{ "firstName": "John", "lastName": "Doe" }` | User information and `user.tenantId` for themed message links |
| `${verificationId}` | `987654` | Embedded in phone number verification messages |
| `${verificationOneTimeCode}` | `abcdef` | Embedded in phone number verification messages |

## Retrieving Default Templates[#](#retrieving-default-templates)

In order to version control the templates or customize them, you can use the admin UI. But you can also pull retrieve them all by using the following command:

```
wget -i https://raw.githubusercontent.com/FusionAuth/fusionauth-site/main/astro/src/content/docs/_shared/message/template_url_list
```

This will place all the message templates in the current working directory.

## Using Replacement Variables[#](#using-replacement-variables)

Below are some basic examples of using replacement values in your message templates.

Consider the following User represented by this condensed JSON object.

```
{
  "phoneNumber": "+15555551234",
  "firstName": "Monica",
  "id": "1c592f8a-59c6-4a09-82f8-f4257e3ea4c8",
  "lastName": "Hall"
}
```

The following are example usages with a rendered output based upon the above mentioned example User. The replacement variables are rendered using [Apache FreeMarker](https://freemarker.apache.org/docs/index.html) which is an HTML template language.

A default value should be provided for variables that may be undefined at runtime such as `firstName`. See `firstName` in the example below is followed by a bang `!` and then the string `Unknown User`. This indicates that if `firstName` is undefined when the template is rendered the value of `Unknown User` should be used as a default value.

*Template Source*

```
Hi ${user.firstName!'Unknown User'}, welcome to Pied Piper.

Please verify your phone number ${user.phoneNumber} by following the provided link.

https://piedpiper.fusionauth.io/identity/verify/${verificationId}
- Admin
```

*Rendered Output*

```
Hi Monica, welcome to Pied Piper.

Please verify your phone number +15555551234 by following the provided link.

https://piedpiper.fusionauth.io/identity/verify/YkQY5Gsyo4RlfmDciBGRmvfj3RmatUqrbjoIZ19fmw4
- Admin
```

## Available Message Templates[#](#available-message-templates)

Below is an overview of each message template that ships with FusionAuth.

For production, configure either the Application or Tenant **baseURL** to a public URL such as `https://auth.example.com` so links rendered from templates point to the correct host.

### Forgot Password[#](#forgot-password)

This is also known as the "Change Password" template.

```
[#setting url_escaping_charset="UTF-8"]
To change your password click on the following link.

  [#-- The optional 'state' map provided on the Forgot Password API call is exposed in the template as 'state'.
       If we have an application context, append the client_id to ensure the correct application theme when applicable.
  --]
[#assign url = "${baseUrl}/password/change/${changePasswordId}?client_id=${(application.oauthConfiguration.clientId)!''}&tenantId=${user.tenantId}" /]
[#list state!{} as key, value][#if key != "tenantId" && key != "client_id" && value??][#assign url = url + "&" + key?url + "=" + value?url/][/#if][/#list]

${url}

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables)

`application`Application

The Application object, see the [Application API](/docs/apis/applications) for field definitions.

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined.

`baseUrl`StringAvailable since 1.68.0

The base URL used when rendering links in this template. FusionAuth resolves this value from the Application `baseURL`, then the Tenant `baseURL`, then a local development fallback URL.

`changePasswordId`String

The change password Id that must be included as a path segment in the `/password/change` link. See the [theme variables](/docs/customize/look-and-feel/advanced-themes/template-variables) documentation for more information on how this value is used.

`state`Object

If the `state` was provided during the Forgot Password request, it will be available to you in the message template.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Passwordless Login[#](#passwordless-login)

```
[#setting url_escaping_charset="UTF-8"]
You have requested to log into FusionAuth using this phone number. If you do not recognize this request please ignore this message.

[#if oneTimeCode??]
  Login code: ${oneTimeCode}
[#else]
[#-- The optional 'state' map provided on the Start Passwordless API call is exposed in the template as 'state' --]
    [#assign url = "${baseUrl}/oauth2/passwordless/${code}?tenantId=${user.tenantId}" /]
    [#list state!{} as key, value][#if key != "tenantId" && value??][#assign url = url + "&" + key?url + "=" + value?url/][/#if][/#list]

    ${url}
[/#if]

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables-1)

`application`Application

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

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined.

`baseUrl`StringAvailable since 1.68.0

The base URL used when rendering links in this template. FusionAuth resolves this value from the Application `baseURL`, then the Tenant `baseURL`, then a local development fallback URL.

`code`String

The unique code intended to be used by the [Complete a Passwordless Login](/docs/apis/passwordless/complete-a-passwordless-login) API.

`state`Object

If the `state` was provided when the Passwordless request was initiated, it will be available to you in the template.

`tenant`Tenant

The Tenant object, see the Tenant API for field definitions of a Tenant.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Phone Verification[#](#phone-verification)

```
[#-- When a one-time code is provided, you will want the user to enter this value interactively using a form. In this workflow the verificationId
     is not shown to the user and instead the one-time code must be paired with the verificationId which is usually in a hidden form field. When the two
     values are presented together, the phone number can be verified --]
[#if verificationOneTimeCode??]
Verification code: ${verificationOneTimeCode}
[#else]
To complete your phone number verification click on the following link.

${baseUrl}/phone/verify/${verificationId}?client_id=${(application.oauthConfiguration.clientId)!''}&tenantId=${tenant.id}
[/#if]

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables-2)

`application`Application

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

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined.

`baseUrl`StringAvailable since 1.68.0

The base URL used when rendering links in this template. FusionAuth resolves this value from the Application `baseURL`, then the Tenant `baseURL`, then a local development fallback URL.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

`verificationId`String

The verification Id intended to be used by the [Identity Verify](/docs/apis/identity-verify) API.

`verificationOneTimeCode`String

The verification One Time Code (OTP) to be used with the gated Phone Verification workflow. The user enters this code to verify their phone number.

### Set Up Password[#](#set-up-password)

```
Your account has been created and you must click the following link to set a password.

${baseUrl}/password/change/${changePasswordId}?client_id=${(application.oauthConfiguration.clientId)!''}&tenantId=${user.tenantId}
```

#### Replacement Variables[#](#replacement-variables-3)

`application`Application

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

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined.

`baseUrl`StringAvailable since 1.68.0

The base URL used when rendering links in this template. FusionAuth resolves this value from the Application `baseURL`, then the Tenant `baseURL`, then a local development fallback URL.

`changePasswordId`String

The change password Id intended to be used by the [Change a User's Password](/docs/apis/users/change-password) API.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Threat Detected[#](#threat-detected)

This feature is only available in the Enterprise plan. To learn more, see [our pricing page](/pricing).

```
[#setting url_escaping_charset="UTF-8"]
[#if event.type == "UserLoginSuspicious"]
A suspicious login was made on your account. If this was you, you can safely ignore this message. If this wasn't you, we recommend that you change your password as soon as possible.
[#elseif event.type == "UserLoginNewDevice"]
A login from a new device was detected on your account. If this was you, you can safely ignore this message. If this wasn't you, we recommend that you change your password as soon as possible.
[#else]
Suspicious activity has been observed on your account. In order to secure your account, it is recommended to change your password at your earliest convenience.
[/#if]

Device details

* Device name: ${(event.info.deviceName)!'-'}
* Device description: ${(event.info.deviceDescription)!'-'}
* Device type: ${(event.info.deviceType)!'-'}
* User agent: ${(event.info.userAgent)!'-'}

Event details

* IP address: ${(event.info.ipAddress)!'-'}
* City: ${(event.info.location.city)!'-'}
* Country: ${(event.info.location.country)!'-'}
* Zipcode: ${(event.info.location.zipcode)!'-'}
* Lat/long: ${(event.info.location.latitude)!'-'}/${(event.info.location.longitude)!'-'}

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables-4)

`application`Application

The Application object, see the [Application API](/docs/apis/applications) for field definitions.

`event.info`EventInfo

The EventInfo object, see the [User Login Suspicious](/docs/extend/events-and-webhooks/events/user/login/user-login-suspicious) event definition for example field definitions.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Two-Factor Authentication[#](#two-factor-authentication)

This feature is only available in the Enterprise plan. To learn more, see [our pricing page](/pricing).

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

${code}

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables-5)

`application`Application

The Application object, see the [Application API](/docs/apis/applications) for field definitions.

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined. You can check for this variable safely in FreeMarker using the missing value test operator and an `if` statement:

```
[#if application??]
  [#-- Use application here --]
[/#if]
```

This object is not available on the message template when:

*   The multi-factor workflow was [started](/docs/apis/two-factor/start-multi-factor) without providing the `applicationId` on that request.
*   Multi-factor authentication is required during a call to the [login API](/docs/apis/login/authenticate) without providing the `applicationId` parameter. That documentation points out that there is likely no production use case where calling the API without the `applicationId` parameter is useful.
*   The message is being sent to [enable](/docs/apis/two-factor/send-a-multi-factor-code-when-enabling-mfa) or [disable](/docs/apis/two-factor/send-a-multi-factor-code-when-disabling-mfa) a multi-factor method without providing the `applicationId` on the request.

`code`String

A code that the user must provide to complete multi-factor authentication.

`email`String

Email address associated with the `user`.

`mobilePhone`String

Mobile phone number associated with the `user`.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Two-Factor Authentication Method Added[#](#two-factor-authentication-method-added)

This feature is only available in the Enterprise plan. To learn more, see [our pricing page](/pricing).

```
The following two factor method was added to ${user.phoneNumber}:

- Method: ${method.method}
- Identifier: ${method.id}

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables-6)

`application`Application

The Application object, see the [Application API](/docs/apis/applications) for field definitions.

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined. You can check for this variable safely in freemarker by wrapping the variable as such: `${(application)!""}`.

`event`Event

The Event object for a two-factor add event. See the [Webhooks & Events section](/docs/extend/events-and-webhooks/events/user/user-two-factor-method-add) for field definitions.

`method`Object

The two-factor method that was added. See the [Multi-Factor/Two-Factor APIs](/docs/apis/two-factor) for property definitions and example JSON.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Two-Factor Authentication Method Removed[#](#two-factor-authentication-method-removed)

This feature is only available in the Enterprise plan. To learn more, see [our pricing page](/pricing).

```
The following two factor method was removed from ${user.phoneNumber}:

- Method: ${method.method}
- Identifier: ${method.id}

- FusionAuth Admin
```

#### Replacement Variables[#](#replacement-variables-7)

`application`Application

The Application object, see the [Application API](/docs/apis/applications) for field definitions.

*Note*: This object may not be available depending upon when this template is constructed. If you utilize this object in your template, ensure you first check to see if it is defined. You can check for this variable safely in freemarker by wrapping the variable as such: `${(application)!""}`.

`event`Event

The Event object for a two-factor remove event. See the [Webhooks & Events section](/docs/extend/events-and-webhooks/events/user/user-two-factor-method-remove) for field definitions.

`method`Object

The two-factor method that was removed. See the [Multi-Factor/Two-Factor APIs](/docs/apis/two-factor) for property definitions and example JSON.

`tenant`Tenant

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`User

The User object, see the [User API](/docs/apis/users) for field definitions of a User.

### Admin Two-Factor Authentication Method Removed[#](#admin-two-factor-authentication-method-removed)

```
Your ${(method.method == "sms")?then("SMS", method.method)} two-factor authentication method[#if method.name?has_content], ${method.name},[/#if] was removed from ${user.phoneNumber} by your administrator. Contact your administrator if you have questions.
```

#### Replacement Variables[#](#replacement-variables-8)

`method`ObjectAvailable since 1.68.0

The two-factor method that was removed by an administrator. See the [User API](/docs/apis/users) under `user.twoFactor.methods` for property definitions and example JSON.

`tenant`TenantAvailable since 1.68.0

The Tenant object, see the [Tenant API](/docs/apis/tenants) for field definitions.

`user`UserAvailable since 1.68.0

The User object, see the [User API](/docs/apis/users) for field definitions of a User.