Creating message templates

Create a message template and associate it with an alert group. Use the /emailmessagetemplates endpoint to create the message.

Before you begin

Get a JSON Web Token (JWT) for your API call. For more information, see API authentication.

About this task

You can customize the message template for the default group or for any other group. You can select the language of the message template. The default message template is provided in English but you can choose any of the supported languages.

Use any of the message substitution variables. The variables allow you to insert dynamic text, such as the name of the weather event or the government alert headline message.

You can edit the subject and the message. You can edit the content of the message, for example, you can modify the basic HTML styling, change the text, and add logos and links to your company website. You can add content that is specific to your group.

The URL of the API call to the emailmessagetemplates endpoint includes a {geo} field, which is a 2-letter code that represents the region. For North America, the code is na.

Procedure

  1. Define and register the message template by making a POST API call that is similar to the following example.
    URL
    https://api.ibm.com/infohub/run/metadata/api/v1/na/emailmessagetemplates?tenantId=<tenantId>
    Method POST
    Content-Type application/json
    Body
    {
        "name": "default_template",
        "logicalName": "default_template",
        "description": "default_template",
        "descriptionInfo": "default_template",
        "tenantId": "123456",
        "type": "EmailMessageTemplate",
        "messages": [
            {
                "bodyContentType": "HTML",
                "subjectLine": "Email Subject",
                "body": "<!DOCTYPE html><html lang=\"en\"><head><title>Email Title</title></head><body>Email Body</body></html>",
                "locale": "en"
            }
        ],,
        "enabled": true,
        "defaultLocale": "en",
        "isGloballyVisible": false,
        "isComplete": true
    • Include the following key value pairs in the header:
      
        Authorization: Bearer {{your-JWT-token}}
        x-ibm-client-id: infohub-{{your-tenant-id}}
    • Add tenantId as a field.
    • Set Type to EmailMessageTemplate.
    • In messages, define the text and style of each message in each language.
  2. Get a list of message templates. Make the following GET API call:
    URL
    https://api.ibm.com/infohub/run/metadata/api/v1/na/emailmessagetemplates?tenantId=<tenantId>
    Method GET

    This API supports the following optional URL parameters:

    limit
    Limits the number of message templates that are returned to the integer value of the limit parameter. If no limit parameter is specified, the default limit is 10.
    offset
    Skips the first N messages. The offset is zero-based. If no offset is specified, the default offset is 0.
    fields
    A value that can contain a comma-delimited list of fields to return in each message template that is returned. For example, if the parameter is set to &fields=name,messageTemplateId, then only the name and messageTemplateId fields for each template are returned. If no fields parameter is passed, then all fields are included for all returned templates.
    name
    Filters the rules that are returned to only those rules with a name that matches the value of the name URL parameter. The name URL parameter accepts wild cards and matches message templates. If there is no matching message, an empty array is returned. If no name filter parameter is specified, the default behavior is to return all messages, up to the page size that is specified by the limit parameter.