Himani Goel
Himani Goel

Reputation: 21

Marketo REST API to get emails of a program

I am trying to access assets of the program in Marketo but there is no API for the same in Marketo docs.

Also how to map the tokens and emails with the corresponding email templates as I have to generate a preview of the email.

Upvotes: 2

Views: 1038

Answers (2)

Denys Kurochkin
Denys Kurochkin

Reputation: 1497

Actually, Program in Marketo is a Folder with type Program
So you can get program contents using getEmailUsingGET endpoint
Just specify folder parameter as a json object: {"id"="1156";"type"="Program"}

GET https://123-FOO-456.mktorest.com/rest/asset/v1/emails.json?folder={"id"="1156";"type"="Program"}

If your program has inner folders you have to query their contents separately using this folder's id and type. Type of inner folder can be either Folder or Program - some kind of programs might contain other programs.

You can do the same with Forms and Landing Pages

Another way to get Program contents is to use getFolderContentUsingGET
It returns only ids and types of assets and you have to request each asset details separately with its id:

GET https://123-FOO-456.mktorest.com/rest/asset/v1/folder/1290/content.json?type=Program

{
   "success": true,
   "warnings": [],
   "errors": [],
   "requestId": "12efa#15c4562480b",
   "result":    [
            {
         "type": "Folder",
         "id": 517
      },
            {
         "type": "Landing Page Form",
         "id": 1580
      },
            {
         "type": "Landing Page",
         "id": 2305
      },
            {
         "type": "Email",
         "id": 3010
      }
   ]
}

Upvotes: 1

Matt Dearing
Matt Dearing

Reputation: 9386

Unfortunately I don't believe there is a way to query for email assets under a specific program using something like the program id. Many of the Marketo API calls are dependent on using names. For pulling email you can use the Email Query By Name API

The name of the email will be <programname>.Email (assuming the name of your Email asset in marketo is "Email").

Here is an example of a GET request for the email if Marketo Program Name is "TestProgram" and the email name is "Email".

GET /rest/asset/v1/email/byName.json?name=TestProgram.Email

Upvotes: 1

Related Questions