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#

Global API Key Authentication
Search for Email Templates
GET/api/email/template/search?name={name}

Request Parameters#

nameStringoptional

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*.

numberOfResultsIntegeroptionalDefaults to 25

The number of results to return from the search.

orderByStringoptionalDefaults to name ASC

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 Template
  • insertInstant - the instant when the Email Template was created
  • name - 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.

startRowIntegeroptionalDefaults to 0

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.

Global API Key Authentication
Search for Email Templates
POST/api/email/template/search
OpenAPI Spec

When calling the API using a POST request you will send the search criteria in a JSON request body.

Request Body#

search.nameStringoptional

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*.

search.numberOfResultsIntegeroptionalDefaults to 25

The number of results to return from the search.

search.orderByStringoptionalDefaults to name ASC

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 Template
  • insertInstant - the instant when the Email Template was created
  • name - 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.

search.startRowIntegeroptionalDefaults to 0

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.

Example JSON Request

{
  "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.

Response Codes
CodeDescription
200The request was successful. The response will contain a JSON body.
400The 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.
401You 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.
500There was an internal error. A stack trace is provided and logged in the FusionAuth log files. The response will be empty.

Response Body#

emailTemplatesArray

The list of all the Email Templates.

emailTemplates[x].defaultFromNameString

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).

emailTemplates[x].defaultHtmlTemplateString

The default HTML Email Template.

emailTemplates[x].defaultSubjectString

The default Subject used when sending emails.

emailTemplates[x].defaultTextTemplateString

The default Text Email Template.

emailTemplates[x].fromEmailString

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).

emailTemplates[x].idUUID

The Id of Email Template.

emailTemplates[x].insertInstantLong

The instant when the Email Template was created.

emailTemplates[x].lastUpdateInstantLong

The instant when the Email Template was last updated.

emailTemplates[x].localizedFromNamesMap<Locale,String>

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.

emailTemplates[x].localizedHtmlTemplatesMap<Locale,String>

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.

emailTemplates[x].localizedSubjectsMap<Locale,String>

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.

emailTemplates[x].localizedTextTemplatesMap<Locale,String>

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.

emailTemplates[x].nameString

A descriptive name for the email template (i.e. "April 2016 Coupon Email").

totalInteger

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.

Example Response JSON for Email Template Search

{
  "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
}