Snippets

Snippets are reusable HTML components which can be embedded into Emails and Landing Pages and which can be segmented for dynamic content. Snippets don’t have associated templates, and can be created and deployed within other assets within Marketo.

Query

Querying snippets follows the standard pattern for assets, except it does not have a By Name method. Both the By Id and Browse methods allow the use of the status field to retrieve either approved or draft versions of the snippet.

Query Content

The content of a given snippet can be retrieved based on the snippet id.

Request

1

GET/rest/asset/v1/snippet/{id}/content.json

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"5c50#14b04376159",

"result":[

{

"type":"HTML",

"content":"draft testUpdateSnippetContent1 HTML Content"

},

{

"type":"Text",

"content":"draft testUpdateSnippetContent1 Text Content"

}

]

}

The call will return a list of content sections, which consist of sections of type HTML or type DynamicContent, and optionally a section with a type of Text.

Create and Update

Snippets follow the complex asset creation pattern, where the call to create snippet, and its content are made separately, so the first call needs to be to the create endpoint, with an optional description. Data is passed as x-www-form-urlencoded, not as JSON.

Adding or replacing content in a snippet is done by id. The content can be of the types Text, HTML, or DynamicContent. If the type is Text, then the content parameter is just plain text endpoint, while if it is HTML, then it is the desired markup text. If the type is set to DynamicContent, then the content parameter should be set to the id of the segmentation to be associated with the snippet.

Dynamic Content

Snippets follow the standard pattern for dynamic content, but they only represent one whole content section by themselves, so each snippet may contain only one dynamic section, with a list of internal sections optionally for each segment in the used segmentation. Dynamic content can be queried by snippet id alone, since there may only be one dynamic content section in a snippet.

Request

1

GET/rest/asset/v1/snippet/{id}/dynamicContent.json

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"ae3#14c2b499111",

"result":[

{

"createdAt":"2015-03-13T06:24:35Z+0000",

"updatedAt":"2015-03-17T20:29:42Z+0000",

"id":70,

"segmentation":1001,

"content":[

{

"id":"Nzk*",

"segmentId":1001,

"segmentName":"Area",

"content":"Sample HTML for Area",

"type":"HTML"

},

{

"id":"Nzk*",

"segmentId":1001,

"segmentName":"Area",

"content":"Sample Text for Area",

"type":"Text"

},

{

"id":"Nzk*",

"segmentId":1002,

"segmentName":"Default",

"content":"Sample HTML for Default",

"type":"HTML"

},

{

"id":"Nzk*",

"segmentId":1002,

"segmentName":"Default",

"content":"Sample Text for Default",

"type":"Text"

}

]

}

]

}

Approval

Snippets have endpoints available for approving, unapproving and discarding drafts, which follow the standard asset pattern. A snippet must be in draft status for it to be approved.

Approve

Request

1

POST/rest/asset/v1/snippet/{id}/approveDraft.json

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"11903#14db1af2f6c",

"result":[

{

"id":3,

"name":"Test Snippet 02 - deverly",

"description":"hey this is a test snippet!",

"createdAt":"2015-06-02T00:32:37Z+0000",

"updatedAt":"2015-06-02T00:32:37Z+0000",

"url":"https://app-abm.marketo.com/#SN3B2ZN395",

"folder":{

"type":"Folder",

"value":395,

"folderName":"Snippets"

},

"status":"approved",

"workspace":"Default"

}

]

}

Unapprove

The unapprove endpoint can only be used on approved snippets.

Request

1

POST/rest/asset/v1/snippet/{id}/unapprove.json

Response

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"7d20#14db1c7a2a9",

"result":[

{

"id":89,

"name":"Test Snippet 01 - deverly",

"description":"",

"createdAt":"2015-05-15T19:01:22Z+0000",

"updatedAt":"2015-05-15T19:07:07Z+0000",

"url":"https://app-abm.marketo.com/#SN1B2ZN395",

"folder":{

"type":"Folder",

"value":395,

"folderName":"Snippets"

},

"status":"draft",

"workspace":"Default"

}

]

}

Discard Draft

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

Request

1

POST/rest/asset/v1/snippet/{id}/discardDraft.json

Response

1

2

3

4

5

6

7

8

9

10

11

{

"success":true,

"warnings":[],

"errors":[],

"requestId":"674c#14b043760de",

"result":[

{

"id":88

}

]

}

Clone

Cloning a snippet with the API is simple and follows the standard pattern, with a required name, id of the original snippet and folder, as well as an optional description. If no approved version exists, then the draft version will be cloned.

Latest Blog Posts

Keep up with what's new in the developer world

Important Change to Activity Records in Marketo APIs March 1, 2017 Note: This post will be updated to reflect changes made to activity records returned by the API due to migration to new infrastructure.
With the rollout of Marketo’s next-generation Activity Service beginning in September 2017, we will be unable to enforce the uniqueness or presence of the integer “id” field in activities, data value changes, or lead ... Read More >

Spring 2018 Updates June 29, 2018 In the Spring 2018 release we are releasing new REST APIs, and web tracking privacy enhancements. See the full list of updates below.
REST API
Static List CRUD
Allows users to remotely Create, Read, Update, and Delete Static List Records. Enables management of the entire lifecycle of a static list through REST APIs, including populating and maintaining membership. ... Read More >

Winter 2018 Updates March 2, 2018 In the Winter 2018 release, we are releasing a few enhancements to our APIs. See the full list of updates below.
Asset APIs
Activate/Deactivate Trigger Campaigns
We have added the ability to activate and deactivate trigger campaigns, which can simplify the process of automating your program templates. This is achieved by calling two newly added endpoints: Activate Smart Campaign, Deactivate ... Read More >