Email APIs
Overview
This page contains the APIs for managing Email Templates as well as emailing users using those templates. Here are the APIs:
Create an Email Template
This API is used to create an Email Template. Specifying an Id on the URI will instruct FusionAuth to use that Id when creating the Email Template. Otherwise, FusionAuth will generate an Id for the Email Template.
Request
Request Parameters
The Id to use for the new Email Template. If not specified a secure random UUID will be generated.
Request Body
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”)
{
"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!"
},
"name": "Hello World"
}
}
Response
The response for this API contains the information for the Email Template that was created.
Response CodesCode | 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 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. |
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
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
The Id of Email Template.
The instant when the Email Template was created.
The instant when the Email Template was last updated.
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”).
{
"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",
"id": "00000000-0000-0000-0000-0000000000ab",
"insertInstant": 1572469040579,
"lastUpdateInstant": 1572477740579,
"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!"
},
"name": "Hello World"
}
}
Retrieve an Email Template
This API is used to retrieve one or all of the configured Email Templates. Specifying an Id on the URI will retrieve a single Email Template. Leaving off the Id will retrieve all of the Email Templates.
Request
Request Parameters
The Id of the Email Template to retrieve.
Response
The response for this API contains either a single Email Template or all of the Email Templates. When you call this API with an Id the response will contain just that Email Template. When you call this API without an Id the response will contain all of the Email Templates. Both response types are defined below along with an example JSON response.
Code | Description |
---|---|
200 | The request was successful. The response will contain a JSON body. |
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. |
404 | The object you requested doesn't exist. The response will be empty. |
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
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
The Id of Email Template.
The instant when the Email Template was created.
The instant when the Email Template was last updated.
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”).
{
"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",
"id": "00000000-0000-0000-0000-0000000000ab",
"insertInstant": 1572469040579,
"lastUpdateInstant": 1572477740579,
"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!"
},
"name": "Hello World"
}
}
Response Body
The list of all the Email Templates.
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
The Id of Email Template.
The instant when the Email Template was created.
The instant when the Email Template was last updated.
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”).
{
"emailTemplates": [
{
"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",
"id": "00000000-0000-0000-0000-0000000000ab",
"insertInstant": 1572469040579,
"lastUpdateInstant": 1572477740579,
"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!"
},
"name": "Hello World"
}
]
}
Search for Email Templates
This API has been available since 1.45.0
This API is used to search for Email Templates and may be called using the GET
or POST
HTTP methods. Examples of each are provided below. The POST
method is provided to allow for a richer request object without worrying about exceeding the maximum length of a URL. Calling this API with either the GET
or POST
HTTP method will provide the same search results given the same query parameters.
Request
Request Parameters
The case-insensitive string to search for in the Email Template name. This can contain wildcards using the asterisk character (*
). If no wildcards are present, the search criteria will be interpreted as *value*
.
The number of results to return from the search.
The database field to order the search results as well as an order direction.
The possible values are:
id
- the unique Id of the Email TemplateinsertInstant
- the instant when the Email Template was createdname
- the Email Template name
The order direction is optional. Possible values of the order direction are ASC
or DESC
. If omitted, the default sort order is ASC
.
For example, to order the results by the insert instant in a descending order, use insertInstant DESC
.
The offset into the total results. In order to paginate the results, increment this value by the numberOfResults for subsequent requests.
For example, if the total search results are greater than the page size designated by numberOfResults , set this value to 25
to retrieve results 26-50
, assuming the default page size.
When calling the API using a POST
request you will send the search criteria in a JSON request body.
Request Body
The case-insensitive string to search for in the Email Template name. This can contain wildcards using the asterisk character (*
). If no wildcards are present, the search criteria will be interpreted as *value*
.
The number of results to return from the search.
The database field to order the search results as well as an order direction.
The possible values are:
id
- the unique Id of the Email TemplateinsertInstant
- the instant when the Email Template was createdname
- the Email Template name
The order direction is optional. Possible values of the order direction are ASC
or DESC
. If omitted, the default sort order is ASC
.
For example, to order the results by the insert instant in a descending order, use insertInstant DESC
.
The offset into the total results. In order to paginate the results, increment this value by the numberOfResults for subsequent requests.
For example, if the total search results are greater than the page size designated by numberOfResults , set this value to 25
to retrieve results 26-50
, assuming the default page size.
{
"search": {
"name": "Hello",
"numberOfResults": 25,
"orderBy": "insertInstant",
"startRow": 0
}
}
Response
The response for this API contains the Email Templates matching the search criteria in paginated format.
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 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. |
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
The list of all the Email Templates.
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
The Id of Email Template.
The instant when the Email Template was created.
The instant when the Email Template was last updated.
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”).
The total number of Email Templates matching the search criteria. Use this value along with the numberOfResults and startRow in the Search request to perform pagination.
{
"emailTemplates": [
{
"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",
"id": "00000000-0000-0000-0000-0000000000ab",
"insertInstant": 1572469040579,
"lastUpdateInstant": 1572477740579,
"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!"
},
"name": "Hello World"
}
],
"total": 1
}
Update an Email Template
This API is used to update an existing Email Template.
You must specify all of the properties of the Email Template when calling this API with the PUT
HTTP method. When used with PUT
, this API doesn’t merge the existing Email Template and your new data. It replaces the existing Email Template with your new data.
Utilize the PATCH
HTTP method to send specific changes to merge into an existing Email Template.
Request
When using the PATCH method, you can either use the same request body documentation that is provided for the PUT request for backward compatibility. Or you may use either JSON Patch/RFC 6902] or JSON Merge Patch/RFC 7396. See the PATCH documentation for more information.
When using the PATCH method with a Content-Type
of application/json
the provided request parameters will be merged into the existing object, this means all parameters are optional when using the PATCH method and you only provide the values you want changed. A null
value can be used to remove a value. Patching an Array
will result in all values from the new list being appended to the existing list, this is a known limitation to the current implementation of PATCH.
Request Parameters
The Id of the Email Template to update.
Request Body
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”)
{
"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!"
},
"name": "Hello World"
}
}
Response
The response for this API contains the new information for the Email Template that was updated.
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 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. |
404 | The object you are trying to update doesn't exist. The response will be empty. |
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
The default From Name used when sending emails. If not provided, and a localized value cannot be determined, the default value for the tenant will be used. This is the display name part of the email address ( i.e. Jared Dunn jared@piedpiper.com).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. If not provided, the default value for the tenant will be used. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
The Id of Email Template.
The instant when the Email Template was created.
The instant when the Email Template was last updated.
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.
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.
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.
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.
A descriptive name for the email template (i.e. “April 2016 Coupon Email”).
{
"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",
"id": "00000000-0000-0000-0000-0000000000ab",
"insertInstant": 1572469040579,
"lastUpdateInstant": 1572477740579,
"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!"
},
"name": "Hello World"
}
}
Delete an Email Template
This API is used to delete an Email Template. You must specify the Id of the Email Template on the URI.
Request
Request Parameters
The Id of the Email Template to delete.
Response
This API does not return a JSON response body.
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 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. |
404 | The object you requested doesn't exist. The response will be empty. |
500 | There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty. |
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
Request Body
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).
The default HTML Email Template.
The default Subject used when sending emails.
The default Text Email Template.
The email address that this email will be sent from. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
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.
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.
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.
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.
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.
{
"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 CodesCode | 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 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. |
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
The email address that this email will be sent from. This is the address part email address (i.e. Jared Dunn jared@piedpiper.com).
The From display name this email will be sent from. This is the name part email address ( i.e. Jared Dunn jared@piedpiper.com).
The HTML Email.
The Subject used when sending the email.
The Text Email.
An Errors object that contains any errors in the Email Template.
{
"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": {}
}
Send an Email
This API is used to send an Email to one or more users using an Email Template.
Request
Request Parameters
The Id of the Email Template to use to generate the Email from.
Request Body
An optional application Id, when provided the application object will be available in the email template for variable replacement.
A list of email addresses to BCC when sending the Email.
A list of email addresses to CC when sending the Email.
An ordered list of locale strings to utilize when localizing the email template for address provided in the toAddresses . See Locales.
An optional JSON object that is passed to the Email Template during rendering. The variables in the JSON object will be accessible to the FreeMarker templates of the Email Template.
A list of email addresses to send the Email to. It is not required that a user exist in FusionAuth with this email address, this may be useful when sending invitations to users that do not yet exist in FusionAuth.
This field may be used in addition to, or as an alternative to the userIds field.
The email address for the user. Using the toAddresses is optional, but when providing one or more entries, this field is required.
An optional display name that can be used to construct the to address.
For example, in this example string Erlich Bachman<bachman@piedpiper.com>
, Erlich Bachman
is the display name and bachman@piedpiper.com
is the address.
The list of User Ids to send the Email to.
This field may be used in addition to, or as an alternative to the toAddresses field.
Prior to version 1.28.0
, this field was required.
{
"bccAddresses": [
"jared@piedpiper.com"
],
"ccAddresses": [
"james@bond.com"
],
"requestData": {
"message": "Thank you for purchasing the answer to the universe. We appreciate your business",
"paymentAmount": 42
},
"toAddresses": [
{
"address": "accounting@piedpiper.com",
"display": "Piped Piper Accounting"
},
{
"address": "sales@piedpiper.com"
}
],
"userIds": [
"ce485a91-906f-4615-af75-81d37dc71e90"
]
}
Response
Response CodesCode | Description |
---|---|
202 | The request was successful. The response will contain a JSON body. If the JSON body is empty the template was rendered correctly and queued to be sent for all user Ids provided. If one or more failed the response will contain errors in the response format documented below. |
400 | The request was invalid and/or malformed. The response will contain an Errors 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. |
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
This is a Mapping between the email address that had errors and the errors that were encountered. This mapping is used for errors that occur when using the toAddresses field on the send request.
Contains any parse errors that occurred while parsing the Email Template parts. The key of the Map is the field that failed (i.e. from) and the value is the error message.
Contains any template errors that occurred while executing the Email Template parts. The key of the Map is the field that failed (i.e. from) and the value is the error message.
This is a Mapping between the User Ids that had errors and the errors that were encountered.
Contains any parse errors that occurred while parsing the Email Template parts. The key of the Map is the field that failed (i.e. from) and the value is the error message.
Contains any template errors that occurred while executing the Email Template parts. The key of the Map is the field that failed (i.e. from) and the value is the error message.
{
"results": {
"00000000-0000-0001-0000-000000000000": {
"renderErrors": {
"html": "freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:\n==> requestData.not [in nameless template at line 1, column 3]\n\n----\nTip: It's the step after the last dot that caused this error, not those before it.\n----\nTip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use [#if myOptionalVar??]when-present[#else]when-missing[/#if]. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??\n----\n\n----\nFTL stack trace (\"~\" means nesting-related):\n\t- Failed at: ${requestData.not.here} [in nameless template at line 1, column 1]\n----"
}
}
}
}