Email Templates

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.

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.

Header

1

Content-Type:multipart/form-data;boundary=mktoBoundary1480963323998

Request

1

POST/rest/asset/v1/emailTemplates.json

Body

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

--mktoBoundary1480963323998

Content-Disposition:form-data;name="name"

Sample Email Template

--mktoBoundary1480963323998

Content-Disposition:form-data;name="folder"

{"id":15,"type":"Folder"}

--mktoBoundary1480963323998

Content-Disposition:form-data;name="content";filename="testHTML.html"

Content-Type:text/html

<html>

<body>

<h1>TEST HTML</h1>

</body>

</html>

--mktoBoundary1480963323998

Content-Disposition:form-data;name="description"

Create email template using API

--mktoBoundary1480963323998--

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"a99f#14e22b2b85e",

"result":[

{

"id":1022,

"name":"Sample Email Template",

"description":"Create email template using API",

"createdAt":"2015-06-23T23:13:34Z+0000",

"updatedAt":"2015-06-23T23:13:34Z+0000",

"url":"https://app-abm.marketo.com/#ET1022B2ZN12",

"folder":{

"type":"Folder",

"value":15,

"folderName":"Templates"

},

"status":"draft",

"workspace":"Default",

"version":1

}

]

}

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.

Request

1

POST/rest/asset/v1/emailTemplate/{id}.json

Body

1

description=Updated description&name=NewName

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"17ca5#14a12ab900a",

"result":[

{

"id":19,

"name":"New Name",

"description":"Updated description",

"createdAt":"2014-11-14T02:41:26Z+0000",

"updatedAt":"2014-11-14T02:41:26Z+0000",

"folder":{

"type":"Folder",

"value":15

},

"status":"Draft",

"workspace":"Default"

}

]

}

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.

Delete

Request

1

POST/rest/asset/v1/emailTemplate/{id}/delete.json

Response

1

2

3

4

5

6

7

8

9

10

11

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"15cef#149d3de83db",

"result":[

{

"id":12

}

]

}

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.

Latest Blog Posts

Keep up with what's new in the developer world

Important Change to Activity Records in Marketo APIs March 1, 2017 Note: This post will be updated to reflect changes made to activity records returned by the API due to migration to new infrastructure.
With the rollout of Marketo’s next-generation Activity Service beginning in September 2017, we will be unable to enforce the uniqueness or presence of the integer “id” field in activities, data value changes, or lead ... Read More >

Spring 2018 Updates June 29, 2018 In the Spring 2018 release we are releasing new REST APIs, and web tracking privacy enhancements. See the full list of updates below.
REST API
Static List CRUD
Allows users to remotely Create, Read, Update, and Delete Static List Records. Enables management of the entire lifecycle of a static list through REST APIs, including populating and maintaining membership. ... Read More >

Winter 2018 Updates March 2, 2018 In the Winter 2018 release, we are releasing a few enhancements to our APIs. See the full list of updates below.
Asset APIs
Activate/Deactivate Trigger Campaigns
We have added the ability to activate and deactivate trigger campaigns, which can simplify the process of automating your program templates. This is achieved by calling two newly added endpoints: Activate Smart Campaign, Deactivate ... Read More >