Emails
Use the email REST endpoints to query and manage email assets.
If an email contains Marketo Predictive Content, the following endpoints fail with error code 709 and a corresponding error message:
Query
Emails support the same query patterns as templates: by id, by name, and by browsing. The by-name and browse endpoints also support folder filtering.
If an email belongs to an email program that uses A/B Testing, the following endpoints do not return that email:
The call indicates success but includes the warning No assets found for the given search criteria.
By ID
GET /rest/asset/v1/email/1351.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"9ad0#14a1832af8c",
"result":[
{
"id":1356,
"name":"sakZxhxkwV",
"description":"sample description",
"createdAt":"2014-12-05T02:06:21Z+0000",
"updatedAt":"2014-12-05T02:06:21Z+0000",
"subject":{
"type":"Text",
"value":"sample subject"
},
"fromName":{
"type":"Text",
"value":"RBxEtmdQZz"
},
"fromEmail":null,
"replyEmail":{
"type":"Text",
"value":"Qlikf@testmail.com"
},
"folder":{
"type":"folder",
"value":10421
},
"operational":false,
"textOnly":false,
"publishToMSI":false,
"webView":false,
"status":false,
"template":338,
"workspace":"Default",
"isOpenTrackingDisabled": false,
"version": 2,
"autoCopyToText": true,
"ccFields": [
{
"attributeId": "157",
"objectName": "lead",
"displayName": "Lead Owner Email Address",
"apiName": null
}
],
"preHeader": "My awesome preheader!"
}
]
}
By Name
When querying by name, optionally pass a folder to limit the search to 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
Email browsing follows the standard Asset API pattern and supports these optional filters:
status: EitherApprovedorDraft.folder: A JSON object containingidandtype.earliestUpdatedAtandlatestUpdatedAt: The update time range.maxReturn: The number of results to return. The default is 20, and the maximum is 200.offset: Works withmaxReturnto page through large result sets. The 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
To retrieve an email’s editable sections, query its content. Optionally filter by status to return sections from the Approved or Draft version.
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"
}
]
}
A section can have a type of dynamicContent. For more information, see Dynamic Content.
Query CC Fields
Call the Get Email CC Fields endpoint to retrieve the fields enabled for email CC in the target instance.
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
Create an email from a source template. The email’s editable sections come from the template’s HTML elements that have the mktEditable class and a unique id property.
The Create Email call requires these parameters:
name: The email name.template: The source template.folder: The parent folder.
The optional creation parameters are subject, fromName, fromEmail, replyEmail, operational, and isOpenTrackingDisabled. The following defaults apply when these parameters are omitted:
subjectis empty.fromName,fromEmail, andreplyEmailuse the instance defaults.operationalandisOpenTrackingDisabledarefalse.
The isOpenTrackingDisabled parameter determines whether the sent email includes the open-tracking pixel.
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
}
]
}
To update an email, pass its ID and update the email’s description or name.
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
Update each email content section individually. Use the Update Email Content endpoint to update subject, fromName, fromEmail, and replyEmail. This endpoint also lets you set these values to use dynamic content instead of static content.
Each parameter is a type/value JSON object. The type is Text or DynamicContent. The value is the corresponding text or the ID of the segmentation used for dynamic content. Send the data as a POST with application/x-www-form-urlencoded, not as JSON. You can also set isOpenTrackingDisabled 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
}
]
}
To configure a section to use dynamic content, first retrieve its section ID with Get Email Content.
Update Editable Section
Update an editable section by its htmlId. The email id and section htmlId are required path parameters. The type, value, and textValue parameters are optional.
The type determines the contents of value:
Text:valueis a string containing the section’s HTML content.DynamicContent:valueis a JSON object containingtypeset toDynamicContent,segmentationset to the segmentation ID, anddefaultset to the default HTML content.Snippet: A supported section type.
The optional textValue parameter contains the text version of the section. Send the data as a POST with application/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
}
]
}
If autocopy to text is disabled for an embedded snippet, updating the snippet HTML and then updating another section’s text version causes the email text version to reflect the updated snippet HTML. It does not retain the previous snippet text as expected when autocopy is disabled.
Modules
In Email Editor 1.0, a module is an email section defined in the template. Modules can contain elements, variables, and other HTML content as described in Email template syntax.
Use the module APIs to manage modules within an email. For module endpoints that use HTTP POST, format the request body as application/x-www-form-urlencoded, not as JSON.
Most module endpoints require moduleId as a path parameter. The Get Email Content endpoint returns module IDs in the htmlId attribute. See Query.
Query
To work with modules, specify the moduleId that uniquely identifies the module. You might also need the integer module index, which describes the module’s order in the email.
To retrieve module IDs and their indexes, specify the email ID as a path parameter.
The following example queries a 1.0 email based on the Skeleton template in the Starter Templates section of the Template Picker UI.
GET /rest/asset/v1/email/{moduleId}/content.json
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "3d79#158da6492bd",
"result": [
{
"htmlId": "free-image",
"contentType": "Module",
"index": 1,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "single",
"value": {
"width": "600",
"altText": "",
"style": "-ms-interpolation-mode: bicubic; outline: none; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; text-decoration: none; border-top-width: 0; display: block; max-width: 100%; line-height: 100%; height: auto; width: 600px"
},
"contentType": "Image",
"parentHtmlId": "free-image",
"isLocked": false
},
{
"htmlId": "video",
"contentType": "Module",
"index": 2,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "video2",
"value": {
},
"contentType": "Video",
"parentHtmlId": "video",
"isLocked": false
},
{
"htmlId": "free-text",
"contentType": "Module",
"index": 3,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "text",
"value": [
{
"type": "HTML",
"value": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Harum officiis dolorum, nulla, mollitia ducimus iure modi perferendis tenetur ea illum veniam aut sapiente deserunt repellendus. Excepturi illo numquam sint harum."
},
{
"type": "Text",
"value": "Lorem ipsum dolor sit amet, consectetur adipisicing elit. Harum officiis dolorum, nulla, mollitia ducimus iure modi perferendis tenetur ea illum veniam aut sapiente deserunt repellendus. Excepturi illo numquam sint harum."
}
],
"contentType": "Text",
"parentHtmlId": "free-text",
"isLocked": false
},
{
"htmlId": "two-articles",
"contentType": "Module",
"index": 6,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "article3",
"value": {
"height": "auto",
"width": "270",
"style": "-ms-interpolation-mode: bicubic; outline: none; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; text-decoration: none; border-top-width: 0; display: block; max-width: 100%; line-height: 100%; height: auto; width: 270px"
},
"contentType": "Image",
"parentHtmlId": "two-articles",
"isLocked": false
},
{
"htmlId": "articleTitle",
"value": [
{
"type": "HTML",
"value": "LOREM IPSUM DOLOR SIT AMET"
},
{
"type": "Text",
"value": "LOREM IPSUM DOLOR SIT AMET"
}
],
"contentType": "Text",
"parentHtmlId": "two-articles",
"isLocked": false
},
{
"htmlId": "text2",
"value": [
{
"type": "HTML",
"value": "Gumbo beet greens corn soko endive gumbo gourd. shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini."
},
{
"type": "Text",
"value": "Gumbo beet greens corn soko endive gumbo gourd. shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini."
}
],
"contentType": "Text",
"parentHtmlId": "two-articles",
"isLocked": false
},
{
"htmlId": "article4",
"value": {
"height": "auto",
"width": "270",
"style": "-ms-interpolation-mode: bicubic; outline: none; border-right-width: 0; border-bottom-width: 0; border-left-width: 0; text-decoration: none; border-top-width: 0; display: block; max-width: 100%; line-height: 100%; height: auto; width: 270px"
},
"contentType": "Image",
"parentHtmlId": "two-articles",
"isLocked": false
},
{
"htmlId": "articleTitle2",
"value": [
{
"type": "HTML",
"value": "LOREM IPSUM DOLOR SIT AMET"
},
{
"type": "Text",
"value": "LOREM IPSUM DOLOR SIT AMET"
}
],
"contentType": "Text",
"parentHtmlId": "two-articles",
"isLocked": false
},
{
"htmlId": "text3",
"value": [
{
"type": "HTML",
"value": "Gumbo beet greens corn soko endive gumbo gourd. shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini."
},
{
"type": "Text",
"value": "Gumbo beet greens corn soko endive gumbo gourd. shallot courgette tatsoi pea sprouts fava bean collard greens dandelion okra wakame tomato. Dandelion cucumber earthnut pea peanut soko zucchini."
}
],
"contentType": "Text",
"parentHtmlId": "two-articles",
"isLocked": false
},
{
"htmlId": "footer",
"contentType": "Module",
"index": 7,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "footerText",
"value": [
{
"type": "HTML",
"value": "<p style=\"text-align: center;\"><span style=\"color: #333333;\"><strong>Acme, Inc<\/strong><\/span><\/p> \n<div style=\"text-align: center;\">\n You received this because you have subscribed to our newsletter. Click \n <a href=\"{{system.unsubscribeLink}}\" target=\"_blank\" class=\"mktNoTrack\">here<\/a> to unsubscribe. \n <br> \n<\/div>"
},
{
"type": "Text",
"value": "Acme, Inc \n You received this because you have subscribed to our newsletter. Click here <{{system.unsubscribeLink}}> to unsubscribe."
}
],
"contentType": "Text",
"parentHtmlId": "footer",
"isLocked": false
},
{
"htmlId": "spacer",
"contentType": "Module",
"index": 0,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "CTA",
"contentType": "Module",
"index": 4,
"parentHtmlId": "template-wrapper",
"isLocked": false
},
{
"htmlId": "hr",
"contentType": "Module",
"index": 5,
"parentHtmlId": "template-wrapper",
"isLocked": false
}
]
}
The result array contains both module and HTML element descriptions. Module elements have a contentType of Module and include an index. The htmlId attribute contains the moduleId.
For the Skeleton example, the following table maps each moduleId to its index in the email.
Add
To add a module, select an existing module from the email’s template. Specify the email ID and moduleId as path parameters. The required index query parameter determines the module’s position. If index exceeds the largest existing index, the API appends the module to the email.
POST /rest/asset/v1/email/{id}/content/{moduleId}/add.json
Content-Type: application/x-www-form-urlencoded
index=10
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "1063e#158d6ad2c3f",
"result": [
{
"id": 1028
}
]
}
Delete
To delete a module, specify the email ID and moduleId as path parameters.
POST /rest/asset/v1/email/{id}/content/{moduleId}/delete.json
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "2356#158d6f6104a",
"result": [
{
"id":1028
}
]
}
Duplicate
To duplicate a module, specify the email ID and moduleId as path parameters. The API places the duplicate below the original module and moves the remaining modules down.
POST /rest/asset/v1/email/{id}/content/{moduleId}/duplicate.json
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "e740#158d705d967",
"result": [
{
"id":1028
}
]
}
Rearrange
To rearrange modules, submit an array that contains every module and its desired position. Each array element is a JSON object in the form { "index": <_index_>, "moduleId": "<_moduleId_>" }, where <_index_> is the zero-based module position and <_moduleId_> is the module ID.
POST /rest/asset/v1/email/{id}/content/rearrange.json
Content-Type: application/x-www-form-urlencoded
positions=[ {"index": 0, "moduleId": "free-image"}, {"index": 1, "moduleId": "title"}, {"index": 2, "moduleId": "mkvideo"}, {"index": 3, moduleId": "free-text"}, {"index": 4, "moduleId": "blankSpace"}, {"index": 5, "moduleId": "Separator"}, {"index": 6, "moduleId": "callToAction"}, {"index": 7, "moduleId": "blankSpace2"}, {"index": 8, "moduleId": "blankSpace3"} ]
{
"success": true,
"warnings":[ ],
"errors":[ ],
"requestId": "e67a#158d72d1cde",
"result":[
{
"id": 1030
}
]
}
Rename
To rename a module, pass the new name in the name parameter. Specify the email ID and existing moduleId as path parameters.
POST /rest/asset/v1/email/{id}/content/{moduleId}/rename.json
Content-Type: application/x-www-form-urlencoded
name=MarketoVideo
{
"success": true,
"warnings":[ ],
"errors": [ ],
"requestId":"11521#158d740abc0",
"result": [
{
"id": 1030
}
]
}
Variables
In Email Editor 1.0, variables store values for email elements. Define each variable by adding Marketo-specific syntax to the HTML, as described in Email template syntax. Use the variable APIs to manage variables within an email.
Query
To retrieve variables, specify the email ID as a path parameter.
The following example queries a 1.0 email based on the Skeleton template in the Starter Templates section of the Template Picker UI.
GET /rest/asset/v1/email/{id}/variables.json
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "756#158dade55e8",
"result": [
{
"name": "twoArticlesSpacer5",
"value": "20",
"moduleScope": false
},
{
"name": "twoArticlesSpacer6",
"value": "15",
"moduleScope": false
},
{
"name": "twoArticlesBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "footerSpacer2",
"value": "20",
"moduleScope": false
},
{
"name": "twoArticlesSpacer7",
"value": "20",
"moduleScope": false
},
{
"name": "twoArticlesLinkText2",
"value": "CALL TO ACTION",
"moduleScope": false
},
{
"name": "twoArticlesSpacer8",
"value": "40",
"moduleScope": false
},
{
"name": "twoArticlesLinkText",
"value": "CALL TO ACTION",
"moduleScope": false
},
{
"name": "freeTextSpacer",
"value": "40",
"moduleScope": false
},
{
"name": "freeTextSpacer2",
"value": "40",
"moduleScope": false
},
{
"name": "ctaSpacer2",
"value": "20",
"moduleScope": false
},
{
"name": "hrBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "freeTextBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "spacerBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "twoArticlesLink2",
"value": "http:\/\/mylink",
"moduleScope": false
},
{
"name": "hrBorderColor",
"value": "#e6e6e6",
"moduleScope": false
},
{
"name": "twoArticlesSpacer",
"value": "40",
"moduleScope": false
},
{
"name": "twoArticlesBorderSize",
"value": "1",
"moduleScope": false
},
{
"name": "ctaLink",
"value": "http:\/\/mylink",
"moduleScope": false
},
{
"name": "freeImageBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "spacerSpacer",
"value": "40",
"moduleScope": false
},
{
"name": "footerSpacer",
"value": "10",
"moduleScope": false
},
{
"name": "ctaLinkText",
"value": "CALL TO ACTION",
"moduleScope": false
},
{
"name": "twoArticlesButtonBackgroundColor2",
"value": "#333333",
"moduleScope": false
},
{
"name": "ctaBorderSize",
"value": "1",
"moduleScope": false
},
{
"name": "ctaBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "footerBackgroundColor",
"value": "#ffffff",
"moduleScope": false
},
{
"name": "twoArticlesLink",
"value": "http:\/\/mylink",
"moduleScope": false
},
{
"name": "twoArticlesBorderColor",
"value": "#333333",
"moduleScope": false
},
{
"name": "ctaBorderColor",
"value": "#333333",
"moduleScope": false
},
{
"name": "twoArticlesBorderColor2",
"value": "#333333",
"moduleScope": false
},
{
"name": "hrBorderSize",
"value": "1",
"moduleScope": false
},
{
"name": "twoArticlesButtonBackgroundColor",
"value": "#333333",
"moduleScope": false
},
{
"name": "twoArticlesBorderSize2",
"value": "1",
"moduleScope": false
},
{
"name": "ctaButtonBackgroundColor",
"value": "#333333",
"moduleScope": false
},
{
"name": "twoArticlesSpacer4",
"value": "20",
"moduleScope": false
},
{
"name": "twoArticlesSpacer3",
"value": "15",
"moduleScope": false
},
{
"name": "twoArticlesSpacer2",
"value": "20",
"moduleScope": false
},
{
"name": "ctaSpacer",
"value": "20",
"moduleScope": false
}
]
}
Each element in the result array describes one variable.
Variables can have global scope for the entire email or local scope for a module. Every variable contains name, value, and moduleScope attributes. The Boolean moduleScope attribute is false for global variables and true for local variables. A local variable also includes the moduleId of its associated module.
Update
To update a variable, pass the new value in the value parameter. Specify the email ID and variable name as path parameters. When updating a module variable, also pass moduleId to identify the associated module.
The following example updates the global variable hrBorderSize.
POST /rest/asset/v1/email/{id}/variable/{name}.json
Content-Type: application/x-www-form-urlencoded; charset=utf-8
value=2
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"feb5#158db4be57e",
"result": [
{
"name":"hrBorderSize",
"value":"2",
"moduleScope":false
}
]
}
The following example updates the local variable ctaLinkText to Click this button! in module CTA.
POST /rest/asset/v1/email/1032/variable/ctaLinkText.json
Content-Type: application/x-www-form-urlencoded
value=Click this button!&moduleId=CTA
{
"success": true,
"warnings":[ ],
"errors":[ ],
"requestId": "7f34#158dc28d2f7",
"result": [
{
"name":"ctaLinkText",
"value":"Click this button!",
"moduleScope":true,
"moduleId":"CTA"
}
]
}
Approval
Emails follow the standard asset approval lifecycle. Separate endpoints let you approve a draft, unapprove an approved version, or discard an existing draft.
Approve
The approval endpoint validates the email against Marketo email rules. The from name, from email, reply to email, and subject must be populated before approval.
POST /rest/asset/v1/email/{id}/approveDraft.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"15dbf#14a1832ae86",
"result":[
{
"id":1362
}
]
}
Unapprove
Use the unapprove operation only on an approved email.
POST /rest/asset/v1/email/{id}/unapprove.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"3514#14a1832b0fa",
"result":[
{
"id":1364
}
]
}
Discard
You can discard only an email in draft status. You cannot discard an approved email.
POST /rest/asset/v1/email/{id}/discardDraft.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"182c0#14a1832af4f",
"result":[
{
"id":1362
}
]
}
Delete
POST /rest/asset/v1/email/{id}/delete.json
{
"success":true,
"warnings":[ ],
"errors":[ ],
"requestId":"169cd#14a1832adba",
"result":[
{
"id":1361
}
]
}
Clone
To clone an email, send an application/x-www-form-urlencoded POST request with these parameters:
name: Required. The cloned email name.folder: Required. An embedded JSON object withidandtype.description: Optional. The cloned email description.
If the source email has no approved version, the endpoint clones the draft version.
POST /rest/asset/v1/email/{id}/clone.json
Content-Type: application/x-www-form-urlencoded
name=Clone of Social Sharing in Email&folder={"id":239,"type":"Folder"}&description=This is a test of clone email
{
"success": true,
"warnings": [],
"errors": [],
"requestId": "bd49#15706f43d96",
"result": [
{
"id": 2250,
"name": "Clone of Social Sharing in Email",
"description": "This is a test of clone email",
"createdAt": "2016-09-07T23:20:52Z+0000",
"updatedAt": "2016-09-07T23:20:52Z+0000",
"url": "https://app-abm.marketo.com/#EM2250B2",
"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": "Folder",
"value": 239,
"folderName": "Tradeshows and Events"
},
"operational": false,
"textOnly": false,
"publishToMSI": false,
"webView": false,
"status": "draft",
"template": 24,
"workspace": "Default",
"isOpenTrackingDisabled": false
}
]
}
Send Sample
To send a sample email, specify the recipient in the emailAddress query parameter. You can also include these optional parameters:
leadId: Impersonates a specific lead from the database.textOnly: Sends only the text version of the email.
POST /rest/asset/v1/email/{id}/sendSample.json
Content-Type: application/x-www-form-urlencoded
emailAddress=abe@testmail.com&textOnly=true
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "360b#14cce7d2708",
"result": [
{
"id": 2179
}
]
}
Preview Email
Use the Get Email Full Content endpoint to retrieve a live preview of an email as a recipient would receive it. This endpoint supports only Version 1.0 emails.
The required id path parameter identifies the email to preview. The endpoint also accepts three optional query parameters:
status: Acceptsdraftorapproved. The default is the approved version for an approved email or the draft version for an unapproved email.type: AcceptsTextorHTML. The default isHTML.leadId: Accepts the integer ID of a lead and previews the email as though that lead received it.
GET /rest/asset/v1/email/{id}/fullContent.json
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": null,
"result": [
{
"id": 339,
"status": "draft",
"content": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 1.01 Transitional//EN\" \"http://www.w1.org/TR/html4/loose.dtd\">\n<html>\n <head>\n <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n <title></title>\n </head>\n <body>\n <div style=\"font: 14px tahoma; width: 100%\" class=\"mktEditable\" id=\"edit_text_3\">\n Content from testCreateEmailTemplate2\n </div>\n </body>\n</html>"
}
]
}
Replace HTML
Use the Update Email Full Content endpoint to replace all content in an email asset. This endpoint supports only Version 1.0 emails that have used the Edit Code function in the UI and are no longer linked to their parent template.
The endpoint is intended primarily for assets cloned as part of a program that cannot be changed with the standard content endpoints. It does not support emails with dynamic content. If the email is still linked to its template, the endpoint returns an error.
Send a multipart/form-data request with the email id in the path. The request body must contain one content parameter with a complete HTML email document and a content type of text/html.
A malformed HTML document produces a warning and might prevent approval. Including JavaScript or <script> tags causes the call to fail with an error.
POST /rest/asset/v1/email/{id}/fullContent.json
content-type: multipart/form-data; boundary=--------------------------116301888604800085728247
content-length: 599
----------------------------116301888604800085728247
Content-Disposition: form-data; name="content"; filename="email_content.html"
Content-Type: text/html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 1.01 Transitional//EN" "http://www.w1.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
</head>
<body>
<div style="font: 14px tahoma; width: 100%" class="mktEditable" id="edit_text_3">
EMAIL TEST CONTENT
</div>
</body>
</html>
----------------------------116301888604800085728247--
{
"success": true,
"warnings": [ ],
"errors": [ ],
"requestId": "15dbf#14a1832ae86",
"result": [
{
"id": 1001
}
]
}