The templates endpoints manage notifications templates and notifications contents. Each content is based on one specific template. Each template can be associated with multiple contents.

Each environment has a set of predefined notifications templates it can access. A template represents a specific process flow, for example, device_pairing or strong_authentication, that requires a notification. Each template defines the deliveryMethods (Email, SMS, or Push) that it supports. You can read templates with this API, but you cannot create, update, or delete them.

A content defines one message text choice for a notification. Each content is always associated with one template and has one deliveryMethod and one locale. Each template comes with one predefined default content for each of its supported deliveryMethods. You cannot delete or update default contents with this API. You can however, create an unlimited number of custom contents for each template. To create custom contents, see Creating custom contents.

Runtime logic for content selection

Each content, whether default or custom, is associated with one template, one deliveryMethod, one locale, and optionally, one variant (For more information on variants, see Creating custom contents). When a request for content is executed at runtime, it includes a template, deliveryMethod, locale and , optionally, a variant.

  1. PingOne looks for contents (default and custom) within the environment with an associated template and deliveryMethod that match the request’s template and deliveryMethod. The results are the pool of possible contents. The pool always includes one default content. Note that the default content has a locale that matches the Notifications settings defaultLanguage property. If defaultLanguage is not set, it defaults to en.

  2. PingOne then looks at the request’s variant, if included. For more information about variant see Variants and Content properties. If the request includes a variant, all custom contents without a matching variant are discarded from the pool. The default content remains in the pool, although default contents never include a variant.

  3. PingOne then looks at the contents’ locale. A locale can consist of an ISO language code only or it can consist of an ISO language code + a country code. For example, locale can be en for English or it can be en-GB for English (United Kingdom). The value of en is less specific. The value of en-GB is more specific.

    1. PingOne first tries to match the request’s locale to the locale of the custom contents in the pool.

      • If there is an exact match, that content is used for the notification. For example, the request’s locale is en and there is a content with the locale of en or the request’s locale is en-GB and there is a content with the locale of en-GB.
      • If there is no exact match and the request’s locale is less specific (en), PingOne looks for a more specific match. For example, a content with locale of en-GB. If found, that content is used for the notification. Otherwise, PingOne moves to step 3.2.
      • If there is no exact match and the request’s locale is more specific (en-GB), PingOne moves to step 3.2.

    2. PingOne next tries to match the Users property preferredLanguage to the locale of the custom contents in the pool.

      • If there is an exact match, that content is used for the notification. For example, preferredLanguage is en and there is a content with the locale of en or preferredLanguage is en-GB and there is a content with the locale of en-GB.
      • If there is no exact match and preferredLanguage is less specific (en), PingOne looks for a more specific match. For example, a content with locale of en-GB. If found, that content is used for the notification. Otherwise, PingOne moves to step 3.3.
      • If there is no exact match and preferredLanguage is more specific (en-GB), PingOne moves to step 3.3.
      • If preferredLanguage is not set, PingOne moves to step 3.3.

    3. PingOne finally tries to match the Notifications settings property defaultLanguage to the locale of the custom contents in the pool. If defaultLanguage is not set, it defaults to en.

      • If there is an exact match, that content is used for the notification. For example, defaultLanguage is en and there is a content with the locale of en or defaultLanguage is en-GB and there is a content with the locale of en-GB.
      • If there is no exact match and defaultLanguage is less specific (en), PingOne looks for a more specific match. For example, a content with locale of en-GB. If found, that content is used for the notification. Otherwise, the predefined default content is used for the notification.
      • If there is no exact match and defaultLanguage is more specific (en-GB), the predefined default content is used for the notification.

Creating custom contents

Add and update custom contents with POST /environments/{envID}/templates/{templateName}/contents and PUT /environments/{envID}/templates/{templateName}/contents/{contentID}. Each content is associated with one template and has one deliveryMethod and one ISO language code (locale). You can define multiple custom contents for each template + deliveryMethod + locale combination with the variant property.

Variants

If you have more than one custom content that uses the same template, deliveryMethod, and local, these contents must have different values for the variant property. The variant property holds the unique user-defined name for each content variant that uses the same template + deliveryMethod + locale combination.

variant values can be reused by contents across different template + deliveryMethod + locale combinations. They need to be unique within the same template + deliveryMethod + locale combination only. As a best practice, use the same variant value for contents with the same message text. For example, the variant value variant_A can be used by a content with the strong_authentication + email + en combination and also by a content with the strong_authentication + push + en combination. For two contents that both use the strong_authentication + email + en combination though, if one content uses the variant value of variant_A, the other content must use a variant value such as variant_B.

Use PATCH environments/{envID}/templates/{templateName}/contents?filter=variant eq {variantName} to bulk update the variant value in contents with the same variant value. Use DELETE environments/{envID}/templates/{templateName}/contents?filter=variant eq {variantName} to bulk delete contents with the same variant value.

Variables

Variables are placeholders for values that change dependiing on the context. For example:

The resulting message is:
Hi John! Your one time passcode is 548263, which includes the variable values John and 548263.

Predefined variables

If a template includes predefined variables, the template lists which variables can be optionally used in its contents and which variables are required in its contents. For example, user.username can be optionally used by strong_authentication contents, while otp is required for all SMS and Email contents.

"variables": {
    "user.username": {
        "required": false
    },
    "otp": {
        "required": true,
        "requiredForDeliveryMethods": [
            "SMS",
            "Email"
        ]
    }
}

Dynamic variables

In addition to predefined variables, some templates also allow dynamic variables. If a template has the property allowDynamicVariables set to true, its contents can contain any user-defined variable in the format ${variable_name}. Define dynamic variables in the JSON Web Token (body.pi.template.variables) passed as the request body for GET /{envID}/as/authorize and POST /{envID}/as/authorize.

JWT: "header" :
{
  "alg": "HS256",
  "typ": "JWT"
},
"body" : 
{
  "aud": "https://auth.pingone.com/{envId}/as",
  "iss": "{applicationId}",
  "pi.template": {
    "name": "{templateName}",
    "variables": {
      "key1": "value1"
    }
  },
  "pi.clientContext": {
    "key2": "value2"
  }
}

Variable settings per template

Template Required Predefined Variables Optional Predefined Variables Dynamic Variables Allowed
Transaction otp (SMS & Email) None Yes
Verification Code code.value None No
Password Recovery code.value None No
Device Pairing otp user.username Yes
Strong Authentication otp (SMS & Email) user.username Yes

Filtering result data

You can filter GET /environments/{envID}/templates and GET /environments/{envID}/templates/{templateName}/contents results by applying a SCIM filtering expression to the request URL. For large collections, a filtering expression appended to the query returns a targeted, more useful data set. For example, the following URL-encoded SCIM filter returns templates created before 2018-07-30 and updated after 2018-08-30:

[https://api.pingone.com/v1/environments/000c2764-3489-4d34-a707-b23dd488049c/templates?filter=(createdAt%20lt%20%222018-08-30%22)%20and%20(updatedAt%20gt%20%222018-07-30%22)%20](https://api.pingone.com/v1/environments/000c2764-3489-4d34-a707-b23dd488049c/templates?filter=(createdAt%20lt%20%222018-08-30%22)%20and%20(updatedAt%20gt%20%222018-07-30%22)%20)

SCIM operators can be applied to the following attributes:

Collection Attribute Supported
Templates and contents collections createdAt
  • eq (equals)
  • ne (not equals)
  • gt (greater than)
  • (greater than or equals)
  • lt (less than)
  • le (less than or equals)
Templates and contents collections updatedAt
  • eq (equals)
  • ne (not equals)
  • gt (greater than)
  • (greater than or equals)
  • lt (less than)
  • le (less than or equals)
Contents collections default
  • eq (equals)
Contents collections locale
  • eq (equals)
  • sw (starts with)
Contents collections deliveryMethod
  • eq (equals)
Contents collections variant
  • eq (equals)
  • sw (starts with)

Additionally, the logical and and or operators may be used for building compound expressions.

Ordering result data

You can order the collections returned by the GET collection endpoints according to the createdAt and updatedAt attribute. Ordering by any attribute returns the collection in a descending order. Using the attribute with the “-” prefix returns the collection ordered in ascending order. For example, the following URL returns all the templates ordered by ascending creation date:

[https://api.pingone.com/v1/environments/000c2764-3489-4d34-a707-b23dd488049c/templates?order=-createdAt](https://api.pingone.com/v1/environments/000c2764-3489-4d34-a707-b23dd488049c/templates?order=-createdAt)

For more information about SCIM syntax and operators, see Conventions.

Properties

Template Properties

Property Description
id Read-only A string that specifies the template id.
displayName Read-only A string that specifies the template’s display name.
deliveryMethods Read-only An array of strings that specifies the delivery methods supported for this template. Valid values are SMS, Email and Push.
createdAt Read-only The time the resource was created.
updatedAt Read-only The time the resource was last updated.
description Read-only A string that specifies the description of the template.
variables Read-only The variables object lists the variables you can use in each template content. The required property indicates whether the variable is required in template content. If required is true, the requiredForDeliveryMethods property lists the deliveryMethods types that require the variable. Note that if required is true, but requiredForDeliveryMethods is not returned, all deliveryMethods types are required. For more information, see Variables.
allowDynamicVariables Read-only A boolean that specifies whether dynamic variables can be used in the template’s contents. For more information, see Dynamic variables.

Content Properties

Property Description
id Read-only A string that specifies the template id.
createdAt Read-only The time the resource was created.
updatedAt Read-only The time the resource was last updated.
default Read-only A boolean indicator that specifies whether the template is a predefined default template.
locale Required Cannot be changed after it is initially set in POST /environments/{envID}/templates/{templateName}/contents. A valid case-insensitive locale, complying with the ISO-639 language code and ISO-3166 country code standards:
  • Two-character language code, for example, “en”.
  • Two-character language code followed by a two-character country code, separated by an underscore or dash, for example: “en_GB”, “en-GB”.
deliveryMethod Required Cannot be changed after it is initially set in POST /environments/{envID}/templates/{templateName}/contents. The content’s delivery method. Possible values are Email, SMS, or Push.
content Required when deliveryMethod is SMS. The SMS text. UC-2 encoding is used for text that contains non GSM-7 characters. UC-2 encoded text cannot exceed 67 characters. GSM-7 encoded text cannot exceed 153 characters. If supported, can include variables.
body Required when deliveryMethod is Email or Push. The email or push text. Email text cannot be larger than 100 kB. Email text can contain HTML. If supported, can include variables.
variant Optional Holds the unique user-defined name for each content variant that uses the same template + deliveryMethod + locale combination. This property is case insensitive and has a limit of 100 characters. For more information, see Creating custom contents.
sender Relevant when deliveryMethod is SMS. The SMS sender ID. This property can contain only alphanumeric characters and spaces, and its length cannot exceed 11 characters. In some countries, including the US, it is impossible to send an SMS with an alphanumeric sender ID. For those countries, the sender ID must be empty. Due to India’s pre-registration laws, “PingID” is always used as the sender ID for SMS recipients in India.
from Relevant when deliveryMethod is Email. The email’s “from” address. The address “noreply@pingidentity.com” is qualified for all environments by default. Other addresses can be configured per environment.
subject Relevant when deliveryMethod is Email. The email’s subject line. Cannot exceed 256 characters. If supported, can include variables.
replyTo Relevant when deliveryMethod is Email. The email’s “reply to” address. The address “noreply@pingidentity.com” is qualified for all environments by default. Other addresses can be configured per environment.
charset Optional Relevant when deliveryMethod is Email. If not specified, UTF-8 is the default value.
emailContentType Optional Relevant when deliveryMethod is Email. If not specified, text/html is the default value.
title Relevant when deliveryMethod is Push. The push title. If supported, can include variables.

Response codes

Code Message
200 Successful operation.
201 Successfully created.
204 Successfully removed. No content.
400 The request could not be completed.
401 You do not have access to this resource.
404 The requested resource was not found.