Snippets

Snippet Endpoint Reference

Snippets are reusable HTML components which can be embedded into Emails and Landing Pages and which can be segmented for dynamic content.  Snippets don’t have associated templates, and can be created and deployed within other assets within Marketo.

Query

Querying snippets follows the standard pattern for assets, except it does not have a By Name method.  Both the By Id and Browse methods allow the use of the status field to retrieve either approved or draft versions of the snippet.

By Id

Browse

Query Content

The content of a given snippet can be retrieved based on the snippet id.

The call will return a list of content sections,  which consist of sections of type HTML or type DynamicContent, and optionally a section with a type of Text.

Create and Update

Snippets follow the complex asset creation pattern, where the call to create snippet, and its content are made separately, so the first call needs to be to the create endpoint, with an optional description.   Data is passed as x-www-form-urlencoded, not as JSON.

Adding or replacing content in a snippet is done by id.  The content can be of the types Text, HTML, or DynamicContent.  If the type is Text, then the content parameter is just plain text endpoint, while if it is HTML, then it is the desired markup text.  If the type is set to DynamicContent, then the content parameter should be set to the id of the segmentation to be associated with the snippet.

Updating metadata is also done by id.  Only name and description can be updated:

Dynamic Content

Snippets follow the standard pattern for dynamic content, but they only represent one whole content section by themselves, so each snippet may contain only one dynamic section, with a list of internal sections optionally for each segment in the used segmentation.  Dynamic content can be queried by snippet id alone, since there may only be one dynamic content section in a snippet.

Approval

Snippets have endpoints available for approving, unapproving and discarding drafts, which follow the standard asset pattern. A snippet must be in draft status for it to be approved.

Approve

Unapprove

The unapprove endpoint can only be used on approved snippets.

Discard Draft

The snippet must be in draft status to be discarded.  An approved snippet cannot be discarded.

Clone

Cloning a snippet with the API is simple and follows the standard pattern, with a required name, id of the original snippet and folder, as well as an optional description.  If no approved version exists, then the draft version will be cloned.