Email Templates

Email Template Endpoint Reference

Email templates form the basis for each new email in Marketo.  While emails can be unlinked from templates through HTML replacement, emails must be created initially with a template as the basis.  Templates are created as pure HTML documents in Marketo with metadata such as names and descriptions.  There are few restrictions on content, but the HTML of the template must be valid, and must contain at least one editable section, which follows the requirements outlined here.

Query

Querying email templates follows the standard pattern for assets, allowing for queries by id, by name and browsing a given folder.

By Id

By Name

Browse

Querying the record itself will return just metadata about the record.  To get content, refer to the #content section.

Create and Update

Creating or updating a template is fairly straightforward.  The content of each template is stored as an HTML document and must be passed into Marketo using a multipart/form-data type of POST.  You must pass the appropriate Content-Type header that includes a boundary as described in the RFCs for multipart and multipart/form-data.

Creating a template requires you to include three parameters: name, folder, content.  An optional description parameter may be included.  The HTML document is passed in the content parameter, which must also include the conventional filename parameter as part of its Content-Disposition header.

Updating content is done using a separate endpoint which requires the id of the Email template.  This endpoint only allows the submission of the content parameter in the body.  When an update is made, whatever is passed in the content parameter will completely replace the existing content of the email in a new draft if updating an approved version, or replace the current draft if the asset is in a draft-only state.

Update Metadata

To update a template’s metadata, name and description, you can use the same endpoint as to update content, but pass an application/x-www-url-formencoded POST instead, with the name and description parameters.

Approval

Email templates follow the standard pattern for approvals of asset records.  You can approve a draft, unapprove an approved version, and discard an existing draft of an email template through each of their own endpoints.

Approve

When calling the approval endpoint, the email will be validated against the rules for Marketo emails. The from name, from email, reply to email, and subject have to be populated before the email can be approved.

Unapprove

The unapprove endpoint can only be used on approved templates.

Discard

The draft version of the template is created after an approved email is updated.

Delete

Clone

Marketo provides a simple method for cloning an Email Template.  Unlike creating, this type of request is made with an application/x-www-url-formencoded POST, and takes two required parameters, name, and folder, an embedded JSON object with id and type.  Description is also an optional parameter.