We here at SparkPost are happy to announce a new feature coming soon to our platform: Snippets; pieces of reusable content that, once created, can be imported into any html or text email content using our render_snippet  macro call. Both stored templates, as well as inline content, can reference a snippet. Snippets are similar to dynamic_html  and dynamic_plain  available today in SparkPost, with the key difference being that snippets are created and stored ahead of time rather than passed inline within a transmissions request.

The /api/v1/snippets endpoint can be used to create snippets. For example, check out this snippet called our_new_footer:

The our_new_footer snippet can be imported into any content, both stored template or inline, using the render_snippet  macro call. For example, if a transmission was injected inline, with content.html:

The resulting rendered HTML email content would look like:

Sounds almost Inception-like, might you say a “template within a template.” How does this help me?

Snippets can be leveraged to substitute in distinct sections of your email content, such as a header or footer, that’s standardized across hundreds of your approved corporate branded email campaigns. Prior to snippets, making edits or updates to those sections required manually updating stored templates individually, or requiring you to manage campaigns outside of SparkPost before passing the content inline.

With Snippets, via the /api/v1/snippets endpoint, content like headers or footers can be updated and applied across all your templates simultaneously. Imagine not having to go into each template and updating the content for one small change to the banner or footer that spans across all your transactional emails.

…but wait, there’s more!

The snippet id  may in fact may come from substitution_data  and metadata . This provides the ability to customize snippets per individual email recipient. The following example illustrates how one of two plain text snippets can be utilized, based on the recipient’s substitution_data .

Two snippets are created via the /api/v1/snippets endpoint:

A single transmission can be injected with content.text:

Where Recipient 1 has substitution_data {“banner_id” : “banner_snippet_A”} and Recipient 2 has substitution_data {“banner_id” : “banner_snippet_B”}.

What’s even cooler is that a snippet may also contain substitution syntax itself, just like a regular template!

By allowing you to substitute in various snippets per recipient, this provides the ability to customize entire sections or portions of your email bodies and apply those changes widely across numerous templates. This is great for seasonal banners, time specific promotions, rotating and testing new sections for increasing engagement, and much, much more.

Some things to note about snippets:

  • Although snippets themselves may contain substitution syntax, some restrictions apply: snippets cannot reference other snippets, nor can they call render_dynamic_content().
  • Snippets may contain links (which will be click tracked if click_tracking is enabled).
  • If a render_snippet call references a snippet which does not exist, the email will be rejected.
  • Each of the HTML and plain text email parts may execute, at most, 30 calls to render_snippet. If this limit is exceeded, the email will be rejected.

Buckle your seatbelt and get ready…

We’re still developing and fine tuning our snippets and want to release to you what we believe a simple way that can completely change how you design and inject using SparkPost. Snippets can provide more flexibility and creativity when sending email campaigns; we want to minimize the time and energy spent updating numerous templates and let you use that time to build more awesome emails!

In the meantime, if you’d like to be kept up to date with status updates on where we are with Snippets and perhaps be included as part of our first group of users to gather feedback, sign up here.

We’d love to get your thoughts about snippets and how we could expand our feature offerings around them. Plus, it’s great just to hear whether or not you’re excited about this. Either way, Tweet us or give us a shout out in our Community Slack!

— Isaac Kim
Technical Product Manager