Emails

Email Endpoint Reference A full set of REST endpoints are provided for manipulating email assets.

Note: If you are using Marketo Predictive Content, the following endpoints will fail if they reference an email that contains predictive content: Get Email ContentUpdate Email Content SectionApprove Email Draft. The call returns a 709 error code, and the corresponding error message.

Query

The query pattern for emails is identical to that of templates, allowing queries by id, by name, and browsing, and for filtering based on folder with the browse and by name APIs.

Note: If an email is part of an email program that is using A/B Testing, then that email is not available for query using the following endpoints: Get Email by Id, Get Email by Name, Get Emails. The call indicates success, but will contain the following 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

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.

Modules

In Email Editor 1.0, a module is a section of your email that is defined in the template. Modules may contain any combination of elements, variables, and other HTML content as described here. Marketo offers a set of APIs for managing modules within an email. For module-related endpoints that require the HTTP POST method, the body is formatted as “application/x-www-form-urlencoded” (not as JSON).

Most of the module-related endpoints require a “moduleId” as a path parameter. This is a string that describes the module. moduleIds are returned by Get Email Content endpoint as the “htmlId” attribute (see Query section below).

Query

To work with modules, you must specify a moduleId parameter, which uniquely identifies the module. You may also must specify the module index parameter, which is an integer that describes the order of the module in the email.

Retrieve moduleIds and their indexes by specifying the email id as a path parameter.

The following example queries a 1.0 email based on the “Skeleton” template found in “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've 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've 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 elements that describe both modules and HTML elements intermixed. Module elements contain a “contentType”: “Module” attribute, and an “index” attribute. The moduleId is stored in the “htmlId” attribute.

Continuing with the “Skeleton” example above, the following table contains a summary of moduleIds and their corresponding indexes contained in the email.

moduleId (a.k.a. htmlId)
Index
spacer
0
free-image
1
video
2
free-text
3
CTA
4
hr
5
two-articles
6
footer
7

Add

Add a module to an email by selecting from one of the existing modules contained in the email template that is in use. Do this by specifying the email id, and the moduleId as path parameters. The index query parameter is required and determines the order of the module in the email. If the index value exceeds the largest existing index value, then the module is appended 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

Delete a module by specifying the email id, and the 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

Duplicate a module by specifying the email id, and the moduleId as path parameters. This call duplicates the module, placing it underneath the original module and pushing the other modules down.

POST /rest/asset/v1/email/{id}/content/{moduleId}/duplicate.json
{
    "success": true,
    "warnings": [ ],
    "errors": [ ],
    "requestId": "e740#158d705d967",
    "result": [
        {
            "id":1028
        }
    ]
}

Rearrange

Rearrange modulesarray that contains all modules and the desired position within the email for each. Each array element contains a JSON object of the following form:  { “index”: <index>, “moduleId”: “<moduleId>” }, where <index> is the zero-based module order number, and <moduleId> is the moduleId.

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

Rename a module on an email by passing the new name via the name parameter. Specify the email id, and the moduleId (existing name) 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 are used to store values for elements in your email. Each variable is defined by adding Marketo-specific syntax to your HTML as described here. Marketo offers a set of APIs for managing variables within an email.

Query

Retrieve variables for an email by specifying the email id as a path parameter.

The following example queries a 1.0 email based on the “Skeleton” template found in “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
    }
  ]
}

The result array contains elements describing variables, one variable per element.

Variables can be scoped globally to the entire email, or locally to a specific module. Variables of either scope contain “name”, “value”, and “moduleScope” attributes. The “moduleScope” attribute is boolean, where false indicates global and true indicates local. Local variables contain an additional “moduleId” attribute that specifies the module that the variable is associated with.

Update

Update a variable in an email by passing the new desired value via the value parameter. Specify the email id, and the variable name as path parameters. If you are updating a module variable, then you must also pass the moduleId parameter to specify the module that the variable is associated with.

In the following example we update a global variable named “hrBorderSize” to a value of 1.

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
        }
    ]
}

In the following example we update a local variable named “ctaLinkText” to a value of “Click this button!” in moduleId “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 pattern for approvals of asset records. You can approve a draft, unapprove an approved version, and discard an existing draft of an email 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 must be populated before the email can be approved.

POST /rest/asset/v1/email/{id}/approveDraft.json
{
   "success":true,
   "warnings":[ ],
   "errors":[ ],
   "requestId":"15dbf#14a1832ae86",
   "result":[
      {
         "id":1362
      }
   ]
}

Unapprove

The unapprove operation can only be performed on approved emails.

POST /rest/asset/v1/email/{id}/unapprove.json
{
   "success":true,
   "warnings":[ ],
   "errors":[ ],
   "requestId":"3514#14a1832b0fa",
   "result":[
      {
         "id":1364
      }
   ]
}

Discard

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

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

Marketo provides a simple method for cloning an Email. This type of request is made with an application/x-www-url-urlencoded POST, and takes two required parameters, name, and folder, an embedded JSON object with id and type. description is also an optional parameter. If no approved version exists, then the draft version is cloned.

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

You can trigger a sample email via the api, to be sent to the emailAddress query parameter. You can also optionally add a leadId parameter to impersonate a particular lead from your database, and a textOnly parameter to send 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

Marketo provides the Get Email Full Content endpoint to retrieve a live preview of an email as it would be sent to a recipient. This endpoint can only be used on Version 1.0 Emails. There is one required parameter, the id path parameter which is the id of the email asset you wish to preview. There are three additional optional query parameters:

  • status: Accepts the values “draft” or “approved” which will default to the approved version, if approved, draft if unapproved
  • type: Accepts “Text” or “HTML” and defaults to HTML
  • leadId:. Accepts the integer id of a lead. When set, previews the email as though it were received by the designated lead
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

Marketo provides the Update Email Full Content endpoint to replace the entire contents of an email asset. This endpoint can only be used on Version 1.0 Emails which have had the UI “Edit Code” function used on them, and have had the relationship to their parent template broken. This API is primarily intended for use on assets that have been cloned as part of a program, and cannot be modified with the standard content endpoints. Emails with dynamic content are not supported. Also, if you try to replace HTML on an email where the relationship is intact, then an error is returned.

This endpoint expects a Content-Type : multipart/form-data with the id parameter in the path, the id of the email, and one parameter in the body, content as a complete HTML email document with the Content-Type “text/html.”. A malformed HTML document emits a warning, but may not permit approval, while inclusion of JavaScript and/or <script>tags in the document cause the call to fail and emit 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
      }
   ]
}
recommendation-more-help
bb269a6d-047a-4bf7-9acd-23ad9a63dc59