We are often asked how to use Marketo’s API to get a list of all custom objects (COs). Querying for COs requires more than its name: some a priori knowledge about each CO is also required. The methods to get that knowledge may not be obvious since the API provides no method for querying it directly. As with many goals in Marketo Engage, Smart Lists provide an answer for COs linked to Persons (Leads). Smart Lists work differently with Companies and you’ll end up with a list of all Persons whose Companies are linked to the type of object for the filter so you may find it necessary to deduplicate companies depending on your goals.
Anytime a new Custom Object is approved, an associated filter is created. It will be named in the format “Has CO NAME“. In the example below, the custom object name is “Conference Track Subscription” and its filter is named “Has Conference Track Subscription“.
Once you have created the Smart List, you can retrieve the information necessary to query for associated COs using the custom objects endpoint. Export the list ensuring the linked field is included (either ID or email address). You can export using the Bulk Lead Extract API filtering by the smartListName or smartListId (1) filter or export from the UI. You’ll use each linked field value to query associated custom objects individually in the next step.
The custom object’s name is “Conference Track Subscription” in this example, and its API name is conferenceTrackSubscription_c. You’ll find the API name both in the UI as “API Name” and via the API as “name“.
Here it is in the UI:
And here’s a fragment returned by the List Custom Objects API endpoint:
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 |
{ "name": "conferenceTrackSubscription_c", "displayName": "Conference Track Subscription", "description": "Track subscription for conference attendees", "createdAt": "2020-01-13T19:50:06Z", "updatedAt": "2020-01-13T19:50:06Z", "idField": "marketoGUID", "dedupeFields": [ "subscriptionID" ], "searchableFields": [ [ "subscriptionID" ], [ "marketoGUID" ], [ "leadID" ] ], "relationships": [ { "field": "leadID", "type": "child", "relatedTo": { "name": "Lead", "field": "Id" } } ] } |
To retrieve the custom objects associated one to one (1:1) or one to many (1:N) with the Persons in your Smart List, make a request like this:
1 |
GET /rest/v1/customobjects/conferenceTrackSubscription_c.json?filterType=leadID&filterValues=1000302,1000303,1000304,1000306,1000307 |
In this example, this custom object is linked to Persons by the leadID field so the filter type is “leadID“. The filter values parameter is a comma-separated list of of the IDs taken from the Smart List export. The request may include as many filter values as you can fit in a single request URI: up to 8K characters. Requests exceeding this length will return a 414 HTTP-level error code. The response may be returned in more than one chunk. If so, moreResult will be true and a nextPageToken will be included. You will then need to page through the results until moreResult is false.
Here’s part of the result for the above API request:
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 |
"result": [ { "seq": 0, "marketoGUID": "d6b3ed3d-4eb8-4066-a9cd-184c8d385cfe", "leadID": "1000302", "subscriptionID": "4ad59184-6bf1-4eeb-a583-d82aeee68210", "createdAt": "2020-01-13T21:24:04Z", "updatedAt": "2020-01-13T21:24:04Z" }, { "seq": 1, "marketoGUID": "e5e0aba4-f27f-494d-93ed-9cb580989bf3", "leadID": "1000303", "subscriptionID": "fc5596d5-6fa2-4848-b4a2-89d96e245c59", "createdAt": "2020-01-13T21:24:04Z", "updatedAt": "2020-01-13T21:24:04Z" }, { "seq": 2, "marketoGUID": "e65007cd-86b1-4c17-8d55-057c96e1788a", "leadID": "1000304", "subscriptionID": "7e54b8a0-2170-4d81-a809-4eac349508d0", "createdAt": "2020-01-13T21:24:04Z", "updatedAt": "2020-01-13T21:24:04Z" }, { "seq": 3, "marketoGUID": "39d956b2-85e2-4c24-94e7-e9fa5a09d3d0", "leadID": "1000306", "subscriptionID": "644c8e5b-fc0c-4d4a-80f8-358a65ce0a68", "createdAt": "2020-01-13T21:24:04Z", "updatedAt": "2020-01-13T21:24:04Z" }, { "seq": 4, "marketoGUID": "a2151350-50c8-437f-bc71-7a054bb601f0", "leadID": "1000307", "subscriptionID": "bf14218c-ae6a-42b3-a14e-f7182903cbcd", "createdAt": "2020-01-13T21:24:04Z", "updatedAt": "2020-01-13T21:24:04Z" } |
You now have the values for each custom object directly associated with the Persons in your Smart List and beyond retrieving the values, you can use the marketoGUID to Update or Delete these objects.
For custom objects associated with Persons in a many to many relationship (N:N), the above technique will return the first level object which is the intermediary object connecting each Person to multiple second level COs. To retrieve those 2nd level COs, start a new set of queries for the 2nd level CO type by filtering on the link field and the values extracted from the 1st level intermediary object. For example, the above “Conference Track Subscription” object could have another level of objects representing sessions called “Session” which would probably be linked by the subscriptionID. The request to retrieve Sessions linked to the above Conference Track Subscriptions would then look like this:
1 |
GET /rest/v1/customobjects/session_c.json?filterType=subscriptionID&filterValues=4ad59184-6bf1-4eeb-a583-d82aeee68210,e5e0aba4-f27f-494d-93ed-9cb580989bf3,e65007cd-86b1-4c17-8d55-057c96e1788a,39d956b2-85e2-4c24-94e7-e9fa5a09d3d0,bf14218c-ae6a-42b3-a14e-f7182903cbcd |
Footnote
1) smartListName and smartListId filter types are unavailable for some subscriptions. If unavailable for your subscription, you will receive an error when calling the Create Export Lead Job endpoint (“1035, Unsupported filter type for target subscription”). Customers may contact Marketo Support to have this functionality enabled in their subscription.