电子邮件

电子邮件终结点引用提供了一整组REST终结点以处理电子邮件资源。

注意:如果您使用Marketo预测内容,并且以下端点引用了包含预测内容的电子邮件,则将失败: 获取电子邮件内容更新电子邮件内容部分批准电子邮件草稿。 调用返回709错误代码以及相应的错误消息。

查询

电子邮件的查询模式与模板模式相同,允许按ID按名称浏览进行查询,以及根据具有浏览和按名称API的文件夹进行筛选。

注意:如果电子邮件是使用A/B测试的电子邮件程序的一部分,则无法使用以下端点查询该电子邮件: 按Id获取电子邮件按名称获取电子邮件获取电子邮件。 调用指示成功,但将包含以下警告:“未找到符合给定搜索条件的资源。”

按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!"
      }
   ]
}

按名称

对于按名称,您可以选择传递文件夹以仅在该文件夹中进行搜索。

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

浏览

浏览文件夹的工作方式与其他资产API浏览端点类似,并且允许对statusfolderearliestUpdatedAt/latestUpdatedAtmaxReturnoffset进行可选筛选。 status已批准或已草稿。 folder是包含idtype的JSON对象。 maxReturn是限制结果数的整数(默认值为20,最大值为200),offset是可与maxReturn一起用于读取大型结果集的整数(默认值为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!"
        }
    ]
}

查询内容

您可以通过查询电子邮件的内容来检索电子邮件的可用可编辑部分,还可以选择筛选状态以获取已批准版本或草稿版本的部分。

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

部分可能会返回为具有dynamicContent类型。 有关详细信息,请参阅动态内容部分。

查询抄送字段

您可以通过调用获取电子邮件抄送字段终结点,检索目标实例中为电子邮件抄送启用的字段集。

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

创建和更新

电子邮件基于源模板创建,并包含派生自该模板中每个单独HTML元素的可编辑部分的列表,其中具有“mktEditable”类和唯一的ID属性。 使用API创建电子邮件时,会根据模板以及传递的任何其他元数据创建记录。 成功创建电子邮件调用需要以下参数:名称、模板、文件夹。

创建时可以选择以下参数: subjectfromNamefromEmailreplyEmailoperationalisOpenTrackingDisabled。 如果未设置,subject将为空,fromNamefromEmailreplyEmail将设置为实例默认值,operationalisOpenTrackingDisabled将为false。 isOpenTrackingDisabled确定发送时电子邮件中是否包含打开跟踪像素。

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

可以按ID更新电子邮件记录。 这允许更新电子邮件的描述或名称。

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

内容区域、类型和更新

除了主题、 fromName 、 fromEmail和replyEmail之外,必须单独更新电子邮件每个部分的内容,这些内容是使用更新电子邮件内容端点更新的。 使用此端点时,这些值也可以设置为使用动态内容而不是静态内容。 每个参数都是一个类型/值JSON对象,其中类型是“Text”或“DynamicContent”,值是相应的文本值,或用于动态内容的分段的ID。 数据以POST x-www-form-urlencoded形式传递,而不是以JSON形式传递。  isOpenTrackingDisabled可设置为更新电子邮件内容

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

如果设置节使用动态内容,则必须通过“获取电子邮件内容”调用检索节ID。

更新可编辑部分

可编辑部分会根据其各自的htmlId进行更新。 只有电子邮件的ID和部分的htmlId作为路径参数是必需的,而type、value和textValue是可选的。 类型可以是“Text”、“DynamicContent”或“Snippet”之一,并将影响值中传递的内容。 如果类型为文本,则值为包含部分的HTML内容的字符串。 如果是DynamicContent,则它是一个JSON块,具有三个成员:类型,将为“DynamicContent”,分段,即用于内容的分段的ID;默认,即包含部分的默认HTML内容的字符串。 可选的textValue参数是一个包含节的文本版本的字符串。 数据以POST x-www-form-urlencoded形式传递,而不是以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
        }
    ]
}

注意:如果对电子邮件中嵌入的代码片段禁用了“自动复制到文本”功能,则更新了该代码片段的HTMLHTML值,然后更新了电子邮件中其他部分的文本版本,则电子邮件文本版本将包含反映该代码片段更新值的文本,而不是禁用自动复制功能时应有的先前版本。

模块

在电子邮件编辑器1.0中,模块是在模板中定义的电子邮件的一部分。 模块可以包含元素、变量和其他HTML内容的任意组合,如此处所述。 Marketo提供了一组API来管理电子邮件中的模块。 对于需要HTTP POST方法的模块相关端点,正文将格式化为“application/x-www-form-urlencoded”(而不是JSON)。

大多数与模块相关的端点都需要“moduleId”作为路径参数。 这是一个描述模块的字符串。 获取电子邮件内容端点将moduleId作为“htmlId”属性返回(请参阅下面的查询部分)。

查询

要使用模块,必须指定唯一标识模块的moduleId参数。 您还可以指定模块索引参数,该参数是一个整数,用于描述模块在电子邮件中的顺序。

通过指定电子邮件ID作为路径参数来检索moduleId及其索引

以下示例根据模板选取器UI的“入门模板”部分中的“骨架”模板查询1.0电子邮件。

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

结果数组包含描述混合模块和HTML元素的元素。 模块元素包含“contentType”:“Module”属性和“index”属性。 moduleId存储在“htmlId”属性中。

继续上述“框架”示例,下表包含电子邮件中包含的moduleId及其相应索引的摘要。

moduleId (也称为htmlId)
索引
分隔条
0
自由图像
1
视频
2
自由文本
3
CTA
4
小时
5
两篇文章
6
页脚
7

Add

通过选择正在使用的电子邮件模板中包含的现有模块之一,向电子邮件中添加模块。 为此,请指定电子邮件ID和moduleId作为路径参数。 需要索引查询参数,并确定模块在电子邮件中的顺序。 如果索引值超过最大的现有索引值,则模块将被附加到电子邮件中。

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

删除

通过指定电子邮件ID和moduleId作为路径参数删除模块

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

重复

通过指定电子邮件ID和moduleId作为路径参数来复制模块。 此调用会复制模块,将其放在原始模块下方,然后向下按其他模块。

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

重新排列

重新排列模块数组,其中包含所有模块以及每个模块在电子邮件中的所需位置。 每个数组元素包含具有以下形式的JSON对象:  { "index": <index>, "moduleId": "<moduleId>" },其中<index>是从零开始的模块订单编号,<moduleId>是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
        }
    ]
}

重命名

通过name参数传递新名称,重命名电子邮件上的模块。 将电子邮件ID和moduleId(现有名称)指定为路径参数。

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

变量

在Email Editor 1.0中,变量用于存储电子邮件中元素的值。 每个变量都是通过向HTML添加特定于Marketo的语法来定义的,如此处所述。 Marketo提供了一组API来管理电子邮件中的变量。

查询

通过指定电子邮件ID作为path参数,为电子邮件检索变量

以下示例根据模板选取器UI的“入门模板”部分中的“骨架”模板查询1.0电子邮件。

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

结果数组包含描述变量的元素,每个元素一个变量。

变量可以在全局范围内限定为整个电子邮件,也可以在本地限定为特定模块。 任一范围的变量都包含“name”、“value”和“moduleScope”属性。 “moduleScope”属性是布尔值,其中false表示全局,true表示本地。 局部变量包含一个额外的“moduleId”属性,该属性指定与变量关联的模块。

更新

通过value参数传递新的所需值来更新电子邮件中的变量。 将电子邮件ID和变量名称指定为路径参数。 如果要更新模块变量,则还必须传递moduleId参数以指定与变量关联的模块。

在以下示例中,我们将名为“hrBorderSize”的全局变量更新为值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
        }
    ]
}

在以下示例中,我们将名为“ctaLinkText”的局部变量更新为“单击此按钮!”的值。 在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"
        }
    ]
}

审批

电子邮件遵循批准资产记录的标准模式。 您可以批准草稿、取消批准已批准的版本,并通过其各自的端点丢弃电子邮件的现有草稿。

批准

在调用审批端点时,将根据Marketo电子邮件规则验证电子邮件。 在批准电子邮件之前,必须填充from namefrom emailreply to emailsubject

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

取消批准

只能在批准的电子邮件上执行unapprove操作。

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

放弃

电子邮件必须处于草稿状态才能被丢弃。 无法丢弃已批准的电子邮件。

POST /rest/asset/v1/email/{id}/discardDraft.json
{
   "success":true,
   "warnings":[ ],
   "errors":[ ],
   "requestId":"182c0#14a1832af4f",
   "result":[
      {
         "id":1362
      }
   ]
}

删除

POST /rest/asset/v1/email/{id}/delete.json
{
   "success":true,
   "warnings":[ ],
   "errors":[ ],
   "requestId":"169cd#14a1832adba",
   "result":[
      {
         "id":1361
      }
   ]
}

克隆

Marketo提供了一种克隆电子邮件的简单方法。 此类请求是使用application/x-www-url-urlencoded POST发出的,并使用两个必需的参数(名称和文件夹),即具有ID和类型的嵌入式JSON对象。 description也是一个可选参数。 如果不存在批准的版本,则会克隆草稿版本。

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

发送示例

您可以通过api触发示例电子邮件,以发送到emailAddress查询参数。 您还可以选择添加一个leadId参数以模拟数据库中的特定潜在客户,添加一个textOnly参数以仅发送电子邮件的文本版本。

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

预览电子邮件

Marketo提供了获取电子邮件完整内容端点来检索将发送给收件人的电子邮件的实时预览。 此端点只能在1.0版本的电子邮件上使用。 有一个必需的参数,即id路径参数,该参数是要预览的电子邮件资源的id。 还有三个其他可选查询参数:

  • 状态:接受值“草稿”或“已批准”,该值将默认至已批准的版本(如果已批准)和未批准的草稿
  • 类型:接受“文本”或“HTML”,并默认为HTML
  • 商机ID:。 接受商机的整数ID。 设置后,预览电子邮件,就像是由指定的潜在客户收到一样
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>"
      }
   ]
}

替换HTML

Marketo提供更新电子邮件完整内容端点以替换电子邮件资源的全部内容。 此端点只能在1.0版本的电子邮件上使用,这些电子邮件具有用于它们的UI“编辑代码”功能,并且与父模板的关系已断开。 此API主要用于在已作为程序的一部分克隆的资产,并且无法使用标准内容端点进行修改。 不支持包含动态内容的电子邮件。 此外,如果您尝试在关系完整的电子邮件上替换HTML,则会返回错误。

此端点需要一个Content-Type : multipart/form-data,其中路径中包含ID参数,电子邮件的包含ID,正文中包含一个参数,content-Type为“text/html”的完整HTML电子邮件文档。 格式错误的HTML文档会发出警告,但可能不允许审批,而文档中包含JavaScript和/或<script>标记会导致调用失败并发出错误。

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