Snippets

Create reusable content snippets for your Airship messages.

Snippets are reusable pieces of content that you can define in Airship for later use in your messages and templates. A single snippet can be used in multiple channels. Snippets support text or HTML content and can be used for commonly used elements such as a copyright, header image, or custom CSS. You can also add Dynamic ContentVariable message content created using Handlebars syntax. The content is populated at send time, resulting in personalized messaging for each member of your audience..

When you edit a snippet, the changes automatically update anywhere that snippet is in use — for scheduled and recurring messages, resave the message to update with the latest version of the snippet. Example uses:

You create snippets in the dashboard, and you can insert them into your messages and templates using both the dashboard and API.

First, you will enter a name, ID, and content for your snippet. Then you can insert a snippet anywhere that supports HandlebarsHandlebars is Airship’s templating language for personalization. Handlebars expressions use double curly braces wrapped around a content template, ranging from a simple variable, e.g., {{first_name}}, to complex evaluations of personalization data. by entering its ID in the format {{>snippet_ID}}.

Snippets API Usage

To include a snippet in an API request, reference the snippet by name in the snippet_references object, and invoke the snippet in your notification text. The example below loads a “signature” snippet and adds it to the end of the message.

POST /attachments HTTP/1.1
Authorization: Bearer <authorization token>
Content-Type: application/json
Accept: application/vnd.urbanairship+json; version=3

{
   "notification": {
      "alert": "Hi {{ name }}: Thanks for your purchase! {{> signature }}"
   },
   "snippet_references": {
      "snippets": [
         {
            "name": "signature"
         }
      ]
   }
}

See Snippet references object in our API reference for details.

 Note

Snippets are not supported for In-App Automation. Snippets are now supported for In-App Automation, Scenes, and Surveys.

Learn more about snippets in our Snippets tutorial.