按名称
对于按名称,您可以选择传递文件夹以仅在该文件夹中进行搜索。
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浏览端点类似,并且允许对status
、folder
、earliestUpdatedAt
/latestUpdatedAt
、maxReturn
和offset
进行可选筛选。 status
已批准或已草稿。 folder
是包含id
和type
的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"
}
]
}
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创建电子邮件时,会根据模板以及传递的任何其他元数据创建记录。 成功创建电子邮件调用需要以下参数:名称、模板、文件夹。
创建时可以选择以下参数: subject
、fromName
、fromEmail
、replyEmail
、operational
、isOpenTrackingDisabled
。 如果未设置,subject
将为空,fromName
、fromEmail
和replyEmail
将设置为实例默认值,operational
和isOpenTrackingDisabled
将为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。 数据以x-www-form-urlencodedPOST传递,而不是以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参数是一个包含节的文本版本的字符串。 数据以x-www-form-urlencodedPOST传递,而不是以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更新值的文本,而不是禁用自动复制时应有的先前版本。