By Name
For by name, you can optionally pass a folder to search only in that folder.
GET /rest/asset/v1/email/byName.json?name=My Email&folder={"id":1056,"type"="Folder"}
{
"success":true,
"warnings":[
],
"errors":[
],
"requestId":"3a7f#14c484de875",
"result":[
{
"id":1032,
"name":"My Email",
"description":"eCjxjIHmYPLtecoSphkvIXlrygOBDLhgyQKnsKMpiKWgSCKhkPMUFvFPUvEylmFiLjQGnffXGaiNLxAwiFOmIDvxEINoaSYascJw",
"createdAt":"2015-03-23T20:23:25Z+0000",
"updatedAt":"2015-03-23T20:23:25Z+0000",
"subject":{
"type":"Text",
"value":"ezyKBmDcyCcUIrXASrLSvRuWQgWpRZxQstJoStgMSLEBASGKMpAnVeWrgJsaVFoFJUEXhEIPpDAWpzajzingUruFpiMcRRwtoBzU"
},
"fromName":{
"type":"Text",
"value":"dAiqRNJOdY"
},
"fromEmail":{
"type":"Text",
"value":"ilZxG@testmail.com"
},
"replyEmail":{
"type":"Text",
"value":"VYsCS@testmail.com"
},
"folder":{
"type":"folder",
"value":1056
},
"operational":false,
"textOnly":false,
"publishToMSI":false,
"webView":false,
"status":"draft",
"template":32,
"workspace":"Default",
"isOpenTrackingDisabled": false,
"version": 2,
"autoCopyToText": true,
"ccFields": [
{
"attributeId": "157",
"objectName": "lead",
"displayName": "Lead Owner Email Address",
"apiName": null
}
],
"preHeader": "My awesome preheader!"
}
]
}
Browse
Browsing folders works like other Asset API browse endpoints, and allows optional filtering on status
, folder
, earliestUpdatedAt
/latestUpdatedAt
, maxReturn
, and offset
. status
is either Approved or Draft. folder
is a JSON object containing id
and type
. maxReturn
is an integer that limits the number of results (default is 20, maximum is 200), and offset
is an integer that can be used with maxReturn
to read through large result sets (default is 0).
GET /rest/asset/v1/emails.json?maxReturn=3&folder={"id":341,"type":"Folder"}
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "17576#14e22eb29cb",
"result": [
{
"id": 2137,
"name": "Social Sharing in Email",
"description": "",
"createdAt": "2011-03-04T17:12:42Z+0000",
"updatedAt": "2011-03-04T19:04:36Z+0000",
"url": null,
"subject": {
"type": "Text",
"value": "Republish this content to your favorite social site!"
},
"fromName": {
"type": "Text",
"value": "Demo Master Marketo"
},
"fromEmail": {
"type": "Text",
"value": "demomaster@marketo.com"
},
"replyEmail": {
"type": "Text",
"value": "demomaster@marketo.com"
},
"folder": {
"type": "Folder",
"value": 341,
"folderName": "Social Media"
},
"operational": false,
"textOnly": false,
"publishToMSI": false,
"webView": true,
"status": "approved",
"template": null,
"workspace": "Default",
"isOpenTrackingDisabled": false,
"version": 2,
"autoCopyToText": true,
"ccFields": [
{
"attributeId": "157",
"objectName": "lead",
"displayName": "Lead Owner Email Address",
"apiName": null
}
],
"preHeader": "My awesome preheader!"
}
]
}
Query Content
You can retrieve the available editable sections for an email by querying its content, and optionally filter on status to get the sections for either the Approved or Draft versions.
GET /rest/asset/v1/email/1356/content.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"8a44#14c484de8c8",
"result":[
{
"htmlId":"edit_text_3",
"value":[
{
"type":"HTML",
"value":"Content from testCreateEmailTemplate2"
},
{
"type":"Text",
"value":"Content from testCreateEmailTemplate2"
}
],
"contentType":"Text"
}
]
}
Sections may return as having a type of dynamicContent. See the Dynamic Content section for more info.
Query CC Fields
You can retrieve the set of fields enabled for Email CC in the target instance by calling the Get Email CC Fields endpoint.
GET /rest/asset/v1/email/ccFields.json
{
"success":true,
"errors":[ ],
"requestId":"e54b#16796fdbd4e",
"warnings":[ ],
"result":[
{
"attributeId":"157",
"objectName":"lead",
"displayName":"Lead Owner Email Address",
"apiName":"leadOwnerEmailAddress"
},
{
"attributeId":"396",
"objectName":"company",
"displayName":"Account Owner Email Address",
"apiName":"accountOwnderEmailAddress"
}
]
}
Create and Update
Emails are created based from a source template, and have a list of editable sections derived from each separate HTML element in that template with a class of “mktEditable” and a unique id property. Creating an email with the API creates a record based on the template along with any additional metadata passed. The following parameters are required for a successful Create Email call: name, template, folder.
The following parameters are optional for creation: subject
, fromName
, fromEmail
, replyEmail
, operational
, isOpenTrackingDisabled
. If unset, subject
will be empty, fromName
, fromEmail
and replyEmail
will be set to instance defaults, and operational
and isOpenTrackingDisabled
will be false. isOpenTrackingDisabled
determines whether the open-tracking pixel is included in an email when sent.
POST /rest/asset/v1/emails.json
Content-Type: application/x-www-form-urlencoded
name=My New Email 02 - deverly&folder={"id":1017,"type":"Program"}&template=24&description=This is a test email&subject=Hey There&fromName=SomeBody&fromEmail=somebody@marketo.com&replyEmail=somebody@marketo.com
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "f557#14e22db88d9",
"result": [
{
"id": 2212,
"name": "My New Email 02 - deverly",
"description": "This is a test email",
"createdAt": "2015-06-23T23:58:09Z+0000",
"updatedAt": "2015-06-23T23:58:09Z+0000",
"url": "https://app-abm.marketo.com/#EM2212A1LA1",
"subject": {
"type": "Text",
"value": "Hey There"
},
"fromName": {
"type": "Text",
"value": "SomeBody"
},
"fromEmail": {
"type": "Text",
"value": "somebody@marketo.com"
},
"replyEmail": {
"type": "Text",
"value": "somebody@marketo.com"
},
"folder": {
"type": "Program",
"value": 1017,
"folderName": "Landing Page - promotion"
},
"operational": false,
"textOnly": false,
"publishToMSI": false,
"webView": false,
"status": "draft",
"template": 24,
"workspace": "Default",
"isOpenTrackingDisabled": false,
"version": 2,
"autoCopyToText": false,
"ccFields": null,
"preHeader": null
}
]
}
Updating an email record can be done by id. This allows for updating the description or name of the email.
POST /rest/asset/v1/email/{id}.json
Content-Type: application/x-www-form-urlencoded
description=This is an Email&name=Updated Email
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "f557#14e22db88d9",
"result": [
{
"id": 2212,
"name": "Updated Email",
"description": "This is an Email",
"createdAt": "2015-06-23T23:58:09Z+0000",
"updatedAt": "2015-06-23T23:58:09Z+0000",
"url": "https://app-abm.marketo.com/#EM2212A1LA1",
"subject": {
"type": "Text",
"value": "Hey There"
},
"fromName": {
"type": "Text",
"value": "SomeBody"
},
"fromEmail": {
"type": "Text",
"value": "somebody@marketo.com"
},
"replyEmail": {
"type": "Text",
"value": "somebody@marketo.com"
},
"folder": {
"type": "Program",
"value": 1017,
"folderName": "Landing Page - promotion"
},
"operational": false,
"textOnly": false,
"publishToMSI": false,
"webView": false,
"status": "draft",
"template": 24,
"workspace": "Default",
"isOpenTrackingDisabled": false,
"version": 2,
"autoCopyToText": false,
"ccFields": null,
"preHeader": null
}
]
}
Content Section, Type, and Update
The content for each section of an email must be updated individually, apart from the subject, fromName, fromEmail, and replyEmail, which are updated using the Update Email Content endpoint. When using this endpoint, these values can also be set to use dynamic content instead of static content. Each parameter is a type/value JSON object, where type is either “Text” or “DynamicContent” and value is either the appropriate text value, or the id of the segmentation to use for the dynamic content. Data is passed as POST x-www-form-urlencoded, not as JSON. isOpenTrackingDisabled may be set with Update Email Content
POST /rest/asset/v1/email/{id}/content.json
Content-Type: application/x-www-form-urlencoded
subject={"type":"Text","value":"Gettysburg Address"}&fromEmail={"type":"Text","value":"abe@testmail.com"}&fromName={"type":"Text","value":"Abe Lincoln"}&replyTO={"type":"Text","value":"replies@testmail.com"}
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"c865#14a1832afac",
"result":[
{
"id":1356
}
]
}
If setting a section to use dynamic content, the section ID must be retrieved via the Get Email Content call.
Update Editable Section
Editable sections are updated by their individual htmlIds. Only the id of the email and htmlId of the section are required as path parameters, while type, value, and textValue are optional. Type may be one of “Text,” “DynamicContent,” or “Snippet” and will affect what is passed in the value. If the type is Text, then the value is a string containing the HTML content of the section. If it is DynamicContent, then it is a JSON block, with three members, type, which will be “DynamicContent”, segmentation which is the id of the segmentation to use for the content, and default, which is a string containing the default HTML content of the section. The optional textValue parameter is a string containing the text version of the section. Data is passed as POST x-www-form-urlencoded, not as JSON.
POST /rest/asset/v1/email/{id}/content/{htmlId}.json
Content-Type: application/x-www-form-urlencoded
type=Text&value=<h1>Hello World!</h1>&textValue=Hello World!
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "155ac#14d58dfa9ad",
"result": [
{
"id": 2179
}
]
}
Note: If autocopy to text is disabled for a snippet embedded in an email, then the HTML value of the snippet is updated, and then the text version of another section in the email is updated, then the text version of the email will have text reflecting the updated value of the snippet HTML, not the previous version as would be expected with autocopy disabled.