Query Objects in Marketing Cloud Growth Using Bulk API 2.0

For complex queries, or queries that you expect to produce a large set of results, use Bulk API 2.0. Queries in Bulk API 2.0 are executed asynchronously.

Before you issue a query request, create a SOQL statement that specifies the data that you want to retrieve. Remove any line breaks from your SOQL statement. For more information, see Understand SOQL Queries.

Bulk queries don’t support the complete set of SOQL clauses and functions. For more information, see Create a Query Job in the Bulk API 2.0 and Bulk API Developer Guide.

To create a bulk query job, issue a POST request to the /services/data/v61.0/jobs/query endpoint. For more information about the properties of the request body, see Create a Query Job in the Bulk API 2.0 and Bulk API Developer Guide.

If the request is successful, the response includes the job ID (id), which you use to check the status of the request and to retrieve the resulting data.

To check the status of a bulk query, issue a GET request to the /data/v61.0/jobs/query/JOB_ID endpoint, replacing JOB_ID with the unique ID of the query job.

When the status of the query job is JobComplete, the query has finished running and your data is ready to retrieve.

To retrieve the query results, issue a GET request to the /data/v61.0/jobs/query/JOB_ID/results endpoint.

If the request is successful, the response includes the resulting data in the requested format, as shown in this example.