Snippets

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 using handlebar syntax that you populate at send time. Use dynamic content to personalize messages 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 HandlebarsAirship’s message personalization syntax using double curly braces, more commonly known as {{handlebars}}. Use handlebars to insert variables and conditional logic in messages and templates. 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.

Learn more about snippets in our Snippets tutorial.