---
cuppy_hub: salesforce
cuppy_path: reference/official/data360/connectapi/guide/query-use-case.md
cuppy_section: docs
cuppy_doc: 347K-63MZ
cuppy_doc_uuid: 950f7de1-ae3f-43a7-8d3c-cf0620f1e0ed
cuppy_permalink: https://cuppy.io/salesforce/d/347K-63MZ
cuppy_version: 1
cuppy_updated: 2026-10-23T16:16:52.575Z
cuppy_canonical: https://cuppy.io/salesforce/docs/reference/official/data360/connectapi/guide/query-use-case
cuppy_mcp: https://cuppy.io/mcp
cuppy_body_sha256: bbc7261e99fb515b001f7242ce429c6b7c9a42bd83be7101bbfb124da9191b9e
# cuppy_body_sha256 is over the document body ALONE, excluding both generated blocks.
---

> Mirror of <https://developer.salesforce.com/docs/data/connectapi/guide/query-use-case.html> (Salesforce, Data 360 Connect REST API Guide), read 2026-10-23. Salesforce's own page is the authority; this copy exists because that site refuses non-browser readers.

## Query: Retrieve Campaign Engagement Records

**Business Goal:** Perform a comprehensive audit of data ingestion, verify data integrity, and analyze user activity related to customer interactions. This data examination ensures regulatory compliance and enables reliable, data-driven decisions regarding customer strategy.

**Use Case:** A data specialist needs to retrieve all campaign engagement records since January 1, 2025, from the `CampaignEngagement__dll` Data Lake Object (DLO). The total number of records is expected to be very large, for example, 100,000 records.

The Query Connect API is designed to make this kind of massive data retrieval manageable and efficient. First, submit the query, then check its status as it processes, and finally retrieve the full results by using pagination.

For limit information, see [Data 360 Limits and Guidelines](https://help.salesforce.com/s/articleView?id=data.c360_a_limits_and_guidelines.htm).

![Image 1: Sequence diagram showing the requests for querying data with the Query Connect API.](https://a.sfdcstatic.com/developer-website/sfdocs/data-cloud/media/connectapi/query-seq-diag.png)

Use the [create SQL query](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=createSqlQuery) endpoint to initiate the query execution in Data 360.

**Query parameters:**

*   `dataspace=default`: The data space where the query is to be executed.
*   `workloadName=connect-engagement-records`: A description of the scenario, task, or application name that the query handles. Set this value to help Salesforce Customer Support assist with debugging issues.

In the body of the request, pass the `sqlParameters` array for parameterized queries. In the query, `:startDate` is a placeholder for the actual date value from the parameters. See [Data 360 SQL Syntax](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/syntax.html) for more information on SQL statements.

The API call immediately returns a `queryId` to track the query’s progress, metadata about the result columns, and the first chunk of data (for example, 2000 rows). The `completionStatus` is `Running` because the first chunk is ready, but `rowCount` indicates that more data is available.

Query results are subject to results caching, which serves identical queries submitted within a specific timeframe much faster. Cached results have a 24-hour expiration time, ensuring that they remain available for repeated access and optimized performance for frequently run queries.

Because the initial response indicated that the `rowCount` is 100,000 but only 2,000 rows were returned, the query is still running in the background. You need to periodically check its status using the [get SQL query](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=getSqlQuery) endpoint.

**Query parameters:**

*   `dataspace=default`: The data space where the query is to be executed.
*   `workloadName=connect-engagement-records`: A description of the scenario, task, or application name that the query handles. Set this value to help Salesforce Customer Support assist with debugging issues.
*   `waitTimeMs`: This parameter allows you to perform long polling. The request blocks for up to `waitTimeMs` (for example, 10,000 ms = 10 seconds) if the status hasn’t changed or return immediately if it has. Adjust this number as needed if you encounter Apex resource limit issues.

The client polls every five seconds until the query `completionStatus` is `Finished`. Pass the `queryId` obtained in the previous response as part of the URL for this status check.

The `progress` field indicates how much of the query has been processed.

When `completionStatus` is `Finished` (or `progress` is 1.0), all data is ready for retrieval.

After confirming that the initial query is complete, you fetch the remaining 98,000 rows by using the [get SQL query rows](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=getSqlQueryRows) endpoint.

**Query parameters:**

*   `rowLimit`: The maximum number of rows to return in this chunk (for example, 2000).
*   `offset`: The row number at which to start retrieving the next chunk of query results.
*   `omitSchema=true`: This parameter, when set to `true`, tells the request _not_ to return the metadata (`metadata` array) with each subsequent chunk. Omitting the metadata reduces the amount of data returned for faster performance.

Get the next 2000 rows, starting from row 2000 (since you already received the first 2000 rows).

The response contains the next chunk of data.

For queries that are no longer needed due to user cancellation or to cancel a long-running query, use the [cancel SQL query](https://developer.salesforce.com/docs/data/connectapi/references/spec?meta=cancelSqlQuery) endpoint.


---
<!-- cuppy -->
You are reading one file. The same content is free over MCP at https://cuppy.io/mcp with no signup: ranked search across all 376 documents in this hub, the merged view when you work in a layer, known workarounds matched to the error you hit, and depth control so you spend tokens on what you need. Start with the `_hello` tool. How to connect: https://cuppy.io/salesforce/ Something wrong in this document? Report it with the `session feedback` tool on the same endpoint.
<!-- /cuppy -->
