Personalization template objects

Personalization templates objects, including pushes to templates and template listing.

Push template payload

A push template payload defines a push by overriding the variables defined in a specific template object. Specifically, a push template object specifies push audience and device types, along with substitutions for the variables defined in a template.

Jump to examples ↓

OBJECT PROPERTIES
  • audience object<Audience selector (max 1000)>REQUIRED

    The audience for the template.

    An audience selector forms the expression that determines the set of channels to target.

  • campaigns object<Campaigns object>

    An object specifying custom campaign categories related to the notification.

  • device_types array[string]REQUIRED

    An array containing one or more strings identifying targeted platforms.

  • merge_data objectREQUIRED

    A template selector describing the template ID and variable substitutions to use with it.

    OBJECT PROPERTIES
    • substitutions object

      An object containing overrides for your template’s variables. The key-value pairs in this object are the value of the key items defined in your template, and the values you want to substitute for the default_value of those keys.

    • template_id stringREQUIRED

      Specifies the template to override; corresponds to the id in /templates responses.

Used in:

Examples

Push template payload example

{
   "audience": {
      "tag": [
         "yanny",
         "laurel"
      ]
   },
   "device_types": [
      "email",
      "ios",
      "android",
      "web"
   ],
   "merge_data": {
      "template_id": "8cce6cc8-7d78-43c7-80b5-81ac24c07672",
      "substitutions": {
         "FIRST_NAME": "Bob",
         "LAST_NAME": "Takahashi",
         "TITLE": null
      }
   },
   "campaigns": {
      "categories": [
         "winter sale",
         "west coast"
      ]
   }
}

Template object

A template object is a skeleton for a push. This is the object used for template creation, and returned by the template listing and lookup endpoints.

Jump to examples ↓

OBJECT PROPERTIES
  • created_at string

    The date-time when this template was created.

  • description string

    The description for the template.

  • id string

    The unique ID assigned to this template. Used to retrieve or use the template in other endpoints.

  • last_used string

    The date-time when this template’s definition was last used. This attribute cannot template-based specified when the template is created and will only be present when template objects are provided by the template retrieval and template listing endpoints.

  • modified_at string

    The date-time when this template was last modified.

  • name stringREQUIRED

    The name of the template.

  • A partial push object describing everything about a push notification, except for the audience and device_types keys (which are defined in the Push template payload) and the message key (which is incompatible with templates).

  • variables arrayREQUIRED

    An array of variable specifications. Variables can be customized when pushing based on the template.

Used in:

Examples

Basic template object

{
   "name": "<template name>",
   "description": "<template description>",
   "variables": ["<variable specifications>"],
   "push": "<push-object>",
   "id": "<template-id>",
   "created_at" : "timestamp",
   "modified_at" : "timestamp",
   "last_used" : "timestamp"
}

Template push object

A partial push object describing everything about a push notification, except for the audience and device_types keys (which are defined in the Push template payload) and the message key (which is incompatible with templates).

Jump to examples ↓

OBJECT PROPERTIES
  • campaigns object<Campaigns object>

    An object specifying custom campaign categories related to the notification.

  • in_app object<In-app message>

    A JSON object describing an in-app message payload.

  • no_throttle boolean

    If true, the push will ignore global throttling rates that have been configured for the application, resulting in delivery as quickly as possible.

  • notification object<Notification object>

    The notification payload that is required unless either message or in_app is present. You can provide an alert and any platform overrides that apply to the device_type platforms you specify.

  • options object

    A JSON dictionary for specifying non-payload options related to the delivery of the push.

    OBJECT PROPERTIES
    • expiry object

      Delivery expiration, as either absolute ISO UTC timestamp, or number of seconds from now.

      One of

Used in:

Examples

Example

{
    "audience" : {
        "OR" : [
            { "tag" : ["sports", "entertainment"]},
            { "device_token" : "871922F4F7C6DF9D51AC7ABAE9AA5FCD7188D7BFA19A2FA99E1D2EC5F2D76506" },
            { "apid" : "5673fb25-0e18-f665-6ed3-f32de4f9ddc6" }
        ]
    },
    "device_types" : [ "ios" ],
    "merge_data": {
        "template_id": "ef34a8d9-0ad7-491c-86b0-aea74da15161",
        "substitutions": {
            "FIRST_NAME": "Bob"
        }
    }
}

Template variables

A template variable object describes the pieces of your template to override when creating template-based pushes. These are the fields you want to customize when you send a push based on the template.

Jump to examples ↓

OBJECT PROPERTIES
  • default_value string

    A default value for the variable. If the key for this variable is not specified in a Template Selector (substitutions) when issuing push notifications based on this template, the push will use this value.

  • description string

    A description of the variable.

  • key stringREQUIRED

    The key used to reference the variable inside the template push. (32 chars, starting and ending with alphanumeric characters, and consisting of alphanumeric characters and underscores).

  • name string

    A friendly name for the variable.

Used in:

Examples

Template variable example

{
   "key" : "<key>",
   "name" : "<variable name>",
   "description" : "<variable description>",
   "default_value" : "<fallback value>"
}