Bulk Custom Object Extract

Bulk Custom Object Extract Endpoint Reference

The Bulk Custom Object Extract set of REST APIs provides a programmatic interface for retrieving large sets of custom object records out of Marketo.  This the recommended interface for use cases which require continuous interchange of data between Marketo and one or more external systems, for ETL, data warehousing, and archival purposes.

This API supports exporting first-level Marketo custom object records that are linked directly to a lead.  You pass in the name of the custom object, and a list of leads to which the object is linked.  For each lead in the list,  the linked custom object records that match the specified custom object name are written as rows to the export file.  Custom object data is viewable in the Custom Object tab of the lead’s detail page in the Marketo UI.

Permissions

The Bulk Custom Object Extract APIs require that the owning API user have a role with one or both of the Read-Only Custom Object, or Read-Write Custom Object permissions.

Filters

Custom object extract supports several filter options used to specify a list of leads that are linked to the custom object.  If a lead in the list is linked to custom object records that match a given custom object name, then the records are written to the export file.  Only one filter type may be specified per export job.

Filter Type Data Type Notes
staticListName String Accepts the name of a static list.  Jobs with this filter type will return all accessible records which are members of the static list at the time that the job begins processing.

Retrieve static list names using the Get Lists endpoint.

staticListId Integer Accepts the id of a static list. Jobs with this filter type will return all accessible records which are members of the static list at the time that the job begins processing.

Retrieve static list ids using the Get Lists endpoint.

smartListName* String Accepts the name of a smart list.  Jobs with this filter type will return all accessible records which are members of the smart lists at the time that the job begins processing.

Retrieve smart list names using the Get Smart Lists endpoint.

smartListId* Integer Accepts the id of a smart list.  Jobs with this filter type will return all accessible records which are members of the smart lists at the time that the job begins processing.

Retrieve smart list ids using the Get Smart Lists endpoint.

* Filter type is 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.

Options

The Create Export Custom Object Job endpoint provides several formatting options.  These options give the user the ability to:

  • Specify the fields to include within the exported file
  • Rename column headers of these fields
  • Specify the format of the exported file
Parameter Data Type Required Notes
fields Array[String] Yes Array of strings containing value of custom object attribute name as returned by the Describe Custom Object endpoint.  The listed fields will be included in the exported file.
columnHeaderNames Object  No A JSON object containing key-value pairs of field and column header names.  The key must be the name of a field included in the export job.  The value will be the name of the exported column header for that field.
 format String No Accepts one of: CSV, TSV, SSV.  The exported file will be rendered as a comma-separated values, tab-separated values, or space-separated values file, respectively if set.  Defaults to CSV if unset.

Creating a Job

The parameters for the job are defined before kicking off the export using the Create Export Custom Object Job endpoint.

The required apiName path parameter is the custom object name as returned by the Describe Custom Object endpoint.  This specifies which Marketo custom object to export.  CRM custom objects are not allowed.  The required filter parameter contains the list of leads that are linked to the custom object.  This can reference a static list, or a smart list.  The required fields parameter contains the API names of the custom object attributes to include in the export file.  Optionally we can define the format of the file, and the columnHeaderNames.

As an example, let’s assume that we have created a custom object named “Car” with the following fields : Color, Make, Model, VIN.  The link field is lead ID, and the deduplication field is VIN.

Custom Object Definition

 

 

 

 

 

 

 

 

 

 

 

Custom Object Fields

We can call Describe Custom Object to programmatically inspect the custom object attributes which are appear in the fields attribute in the response.

Now let’s create several custom object records and link each to a different lead using the Sync Custom Objects endpoint.  Note that one lead can be linked to many custom object records.  This is known as a “one to many” relationship.

Each of the 3 leads referenced above belong to a static list named “Car Buyers” whose id is 1081 as can be seen below by calling the Get Leads by List Id endpoint.

Now let’s create an export job to retrieve these records.  Using the Create Export Custom Object Job endpoint, we specify custom object attributes in the fields parameter and a static list id in the filter parameter.

This returns a status in the response indicating that the job has been created.  The job has been defined and created, but it hasn’t yet been kicked off.  To do so, the Enqueue Export Custom Object Job endpoint must be called using the apiName, and the exportId from the creation status response.

This will respond with an initial status of “Queued” after which it will be set to “Processing” when there is an available export slot.

Polling Job Status

Note: Status can only be retrieved for jobs which were created by the same API user.

Since this is an asynchronous endpoint, after creating the job we need to poll its status to determine its progress.  Poll using the Get Export Custom Object Job Status endpoint.  The status is only updated once every 60 seconds, so a polling frequency lower than this is not advised, and in nearly all cases is still excessive.  The status field may respond with any one of: Created, Queued, Processing, Cancelled, Completed, or Failed.

Let’s take a quick look at polling.

The status endpoint responds indicating that the job is still processing, so the file is not yet available for retrieval.  Once the job status changes to “Completed” it will be available for download.

Retrieving Your Data

To retrieve the file of a completed custom object export, simply call the Get Export Custom Object File endpoint with your apiName and exportId.

The response will contain a file formatted in the way that the job was configured.  The endpoint will respond with the contents of the file.  If a requested custom object attribute is empty (contains no data), then null will be placed in the corresponding field in the export file.

To support partial and resumption-friendly retrieval of extracted data, the file endpoint optionally supports the HTTP header Range of the type bytes.  If the header is not set, the whole of the contents will be returned.  You can read more about using the Range header with Marketo Bulk Extract files here.

Cancelling a Job

If a job was configured incorrectly, or becomes unnecessary, it can be easily cancelled using the Cancel Export Custom Object Job endpoint.  This will respond with a status indicating that the job has been cancelled.