電子郵件

電子郵件端點參考提供了一整組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
        }
    ]
}

注意:如果電子郵件中內嵌的程式碼片段停用「自動複製至文字」 ,接著會更新程式碼片段的HTML值,然後更新電子郵件中其他區段的文字版本,然後電子郵件的文字版本會包含反映程式碼片段HTML更新值的文字,而非停用「自動複製」時所預期的先前版本。

模組

在電子郵件編輯器1.0中,模組是您在範本中定義的電子郵件區段。 模組可包含任何元素、變數和其他HTML內容的組合,如此處所述。 Marketo提供一組用於管理電子郵件中模組的API。 針對需要HTTP POST方法的模組相關端點,本文會格式化為「application/x-www-form-urlencoded」(而非JSON)。

大部分模組相關端點都需要「moduleId」做為路徑引數。 這是說明模組的字串。 Get Email Content端點傳回moduleIds為「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
free-image
1
視訊
2
任意文字
3
CTA
4
小時
5
兩篇文章
6
頁尾
7

新增

從使用中的電子郵件範本中所包含的其中一個現有模組進行選取,以將模組新增至電子郵件。 若要這麼做,請指定電子郵件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
        }
    ]
}

變數

在電子郵件編輯器1.0中,變數可用來儲存電子郵件中元素的值。 每個變數的定義方式,都是將Marketo專屬語法新增至您的HTML,如此處所述。 Marketo提供一組管理電子郵件中變數的API。

查詢

將電子郵件ID指定為路徑引數,以擷取電子郵件的變數

以下範例根據範本選擇器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 path引數,這是您要預覽的電子郵件資產的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,以及內文中有一個引數,內容才會成為完整HTML電子郵件檔案,且內容型別為「text/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