Snippets are short reusable pieces of email content. Snippets can be imported into any template content or transmission content using substitution syntax.
For example, if you have a snippet with the ID ourfooter
and the following HTML content:
<footer>
<p>Our HTML footer</p>
</footer>
The snippet can be imported into an HTML email's content using the render_snippet
macro call.
<html>
<p>Our body content</p>
{{ render_snippet( "ourfooter" ) }}
</html>
The resulting rendered HTML content would look like:
<html>
<p>Our body content</p>
<footer><p>Our HTML footer</p></footer>
</html>
See the Template Language documentation
for a more detailed explanation of the render_snippet
macro and more complicated examples.
Unique ID used to reference the snippet.
Display name
HTML, AMPHTML, and/or text content.
Whether this snippet can be used by subaccounts.
Subaccount the snippet belongs to. Only present on snippets that belong to a subaccount.
POST /api/labs/snippets
{
"id": "header",
"name": "Header snippet",
"content": {
"html": "<b>Our cool header snippet for {{name}}</b>"
}
}
{
"results": {
"id": "header"
}
}
Unique ID used to reference the snippet.
Display name
HTML, AMPHTML, and/or text content. Substitution syntax is supported with the exception of the render_dynamic_content()
and render_snippet()
macro calls. In other words, snippets may not reference other snippets.
false
Whether this snippet can be used by subaccounts.
GET /api/labs/snippets/ourfooter
{
"results": {
"id": "ourfooter",
"name": "Footer",
"content": {
"html": "<b>Our standard footer</b>",
"text": "Our standard footer",
"amp_html": "<b>Our standard footer</b>"
},
"created_at": "2018-10-11T19:13:29.548Z",
"updated_at": "2018-10-11T19:14:50.181Z",
"subaccount_id": 273
}
}
PUT /api/labs/snippets/ourfooter
{
"content": {
"html": "<b>Our updated footer</b>",
"text": "Our updated footer",
"amp_html": "<b>Our updated footer</b>"
}
}
// Empty response body
PUT /api/labs/snippets/ourfooter
{
"content": {
"html": "",
"amp_html": "<b>Our updated footer</b>"
}
}
// Empty response body
Unlike the Templates API, if a content object is provided in the update request, it only needs to include the fields that are being updated. Fields that are not included will keep their current values.
To remove a content field that was specified previously, simply set that field to an empty string in the update request.
Display name
HTML, AMPHTML, and/or text content. Substitution syntax is supported with the exception of the render_dynamic_content()
and render_snippet()
macro calls. In other words, snippets may not reference other snippets.
Whether this snippet can be used by subaccounts.
DELETE /api/labs/snippets/ourfooter
// Empty response body
GET /api/labs/snippets
{
"results": [
{
"id": "header",
"name": "Header",
"shared_with_subaccount": false,
"created_at": "2018-10-11T19:13:29.548Z",
"updated_at": "2018-10-11T19:14:50.181Z"
},
{
"id": "footer",
"name": "Footer",
"shared_with_subaccount": true,
"created_at": "2018-10-05T20:21:04.853Z",
"updated_at": "2018-10-09T19:23:53.022Z"
}
]
}
If true, returns only shared snippets. If false, returns only non-shared snippets. When not provided, returns both shared and non-shared snippets.
Returns an array with all your Snippets.