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

# Preview an Email Template

API documentation for the FusionAuth Preview an Email Template API.

# Preview an Email Template

This API is used to preview an Email Template. You simply pass all of the information for the Email Template in the request and a rendered version of the Email is sent back to you in the response. The Email Template in the request does not need to be completely filled out either. You can send in a partial Email Template and the response will contain only what you provided.

## Request

[!Global API Key Authentication](https://fusionauth.io/docs/apis/authentication.md#global-api-key-authentication)

Preview an Email Template

POST/api/email/template/preview

OpenAPI Spec

### Request Body

`emailTemplate.defaultFromName`required

The default From Name used when sending emails. This is the display name part of the email address ( i.e. **Jared Dunn** [jared@piedpiper.com](mailto:jared@piedpiper.com)).

`emailTemplate.defaultHtmlTemplate`required

The default HTML Email Template.

`emailTemplate.defaultSubject`required

The default Subject used when sending emails.

`emailTemplate.defaultTextTemplate`required

The default Text Email Template.

`emailTemplate.fromEmail`Stringrequired

The email address that this email will be sent from. This is the address part email address (i.e. Jared Dunn [jared@piedpiper.com](mailto:jared@piedpiper.com)).

`emailTemplate.localizedFromNames`optional

The From Name used when sending emails to users who speak other languages. This overrides the default From Name based on the user's list of preferred languages.

`emailTemplate.localizedHtmlTemplates`optional

The HTML Email Template used when sending emails to users who speak other languages. This overrides the default HTML Email Template based on the user's list of preferred languages.

`emailTemplate.localizedSubjects`optional

The Subject used when sending emails to users who speak other languages. This overrides the default Subject based on the user's list of preferred languages.

`emailTemplate.localizedTextTemplates`optional

The Text Email Template used when sending emails to users who speak other languages. This overrides the default Text Email Template based on the user's list of preferred languages.

`locale`Localeoptional

The locale to use when rendering the Email Template. If this is null, the defaults will be used and the localized versions will be ignored.

*Example Request JSON*

```json
{
  "emailTemplate": {
    "defaultFromName": "Administrator",
    "defaultHtmlTemplate": "<p>Hello ${user.username}</p><p>Welcome To FusionAuth!</p>",
    "defaultSubject": "Hello World",
    "defaultTextTemplate": "Hello ${user.username},\nWelcome To FusionAuth!",
    "fromEmail": "email@example.com",
    "localizedFromNames": {
      "de": "Verwalter",
      "fr": "Administrateur"
    },
    "localizedHtmlTemplates": {
      "de": "<p>Hallo ${user.username}</p><p>Willkommen auf der FusionAuth!<p>",
      "fr": "<p>Bonjour ${user.username}</p><p>Bienvenue à FusionAuth!<p>"
    },
    "localizedSubjects": {
      "de": "Hallo Welt",
      "fr": "Bonjour le monde"
    },
    "localizedTextTemplates": {
      "de": "Hallo ${user.username},\nWillkommen auf der FusionAuth!",
      "fr": "Bonjour ${user.username},\nBienvenue à FusionAuth!"
    }
  },
  "locale": "de"
}
```

## Response

The response for this API contains the rendered Email and also an Errors that contains any rendering issues FusionAuth found. The template might have syntax or logic errors and FusionAuth will put these errors into the response.

*Response Codes*

| Code | Description |
| --- | --- |
| 200 | The request was successful. The response will contain a JSON body. |
| 400 | The request was invalid and/or malformed. The response will contain an [Errors](https://fusionauth.io/docs/apis/errors.md) JSON Object with the specific errors. This status will also be returned if a paid FusionAuth license is required and is not present. |
| 401 | You did not supply a valid Authorization header. The header was omitted or your API key was not valid. The response will be empty. See [Authentication](https://fusionauth.io/docs/apis/authentication.md). |
| 500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |

#### Response Body

`email.from.address`String

The email address that this email will be sent from. This is the address part email address (i.e. Jared Dunn [jared@piedpiper.com](mailto:jared@piedpiper.com)).

`email.from.display`String

The From display name this email will be sent from. This is the name part email address ( i.e. **Jared Dunn** [jared@piedpiper.com](mailto:jared@piedpiper.com)).

`email.html`String

The HTML Email.

`email.subject`String

The Subject used when sending the email.

`email.text`String

The Text Email.

`email.errors`

An [Errors](https://fusionauth.io/docs/apis/errors.md) object that contains any errors in the Email Template.

*Example Response JSON*

```json
{
  "email": {
    "from": {
      "address": "email@example.com",
      "display": "Verwalter"
    },
    "html": "<p>Hallo {{user.username}}</p><p>Willkommen auf der FusionAuth!<p>",
    "subject": "Hallo Welt",
    "text": "Hallo {{user.username}},\nWillkommen auf der FusionAuth!"
  },
  "errors": {}
}
```