Query Data 360 Data using Query API
Use the Data 360 Query API to execute SQL queries against your Data 360 data using Connect REST endpoints and Apex methods. This API supports Data 360 SQL syntax and is optimized for all Data 360 use cases, from simple data retrieval to complex analytics and integration scenarios.
The Query API enables you to:
- Execute SQL queries against unified data model, data lake, profile, and engagement objects
- Process large result sets with built-in pagination
- Access data through REST endpoints or Apex methods
- Integrate Data 360 data into external applications and workflows
Choose the method that best fits your integration scenario.
Use the Connect REST API for most integration scenarios. It provides comprehensive features and integrates seamlessly with Salesforce Platform capabilities.
-
- POST
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql - Execute SQL queries synchronously and asynchronously
- Returns query ID for tracking and result retrieval. You can pass this
queryIdtoresult_scanto query the cached results in a subsequent SQL statement.
- POST
-
- GET
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql/{queryId} - Check query execution status and metadata
- Monitor progress for long-running queries
- GET
-
- GET
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql/{queryId}/rows - Retrieve query results with pagination support
- Handle large datasets efficiently
- GET
-
- DELETE
https://{dne_cdpInstanceUrl}/services/data/v64.0/ssot/query-sql/{queryId} - Cancel running queries to free up resources
- Useful for query timeout management
- DELETE
The Data 360 REST API is an HTTP interface for executing SQL queries directly against your Data 360 data. It includes improved asynchronous execution, richer schema introspection, and consistent error reporting.
This API uses the dne_cdpInstanceUrl, which is separate from your standard Salesforce org URL. See Data Cloud API (also known as Direct API) for instructions on obtaining the instance URL and access token.
-
- POST
/api/v3/query - Execute queries in ASYNC or ADAPTIVE mode
- Returns a
queryIdin thestatusresponse header for polling.
- POST
-
- GET
/api/v3/query/{queryId} - Poll for query completion status
- Returns status, row count, chunk count, and execution statistics.
- GET
-
- GET
/api/v3/query/{queryId}/rows - Retrieve results using offset-based pagination.
- GET
-
- GET
/api/v3/query/{queryId}/chunks/{chunkId} - Retrieve results by chunk ID (preferred for large result sets).
- GET
-
- GET
/api/v3/query/{queryId}/metadata - Retrieve output schema without fetching data rows.
- GET
-
- DELETE
/api/v3/query/{queryId} - Cancel a running query and free server resources.
- DELETE
All Data 360 REST API endpoints return JSON by default. Apache Arrow IPC streaming format is also supported as a columnar binary format that reduces payload size and deserialization overhead, making it the better choice for large result sets. These endpoints support Apache Arrow as an alternative to JSON.
- Submit SQL Query
- Get SQL Query Rows
- Get SQL Query Chunks
- Get SQL Query Metadata.
To request an Arrow response, set the Accept header to application/vnd.apache.arrow.stream. The response body is a binary Arrow IPC stream rather than JSON. Use an Arrow-compatible client library (such as PyArrow or the Apache Arrow Java library) to read the stream.
For server-side integration within your Salesforce org, use the Apex ConnectAPI methods:
- Submit SQL Query - Execute SQL queries
- Get SQL Query Status - Check query status
- Get SQL Query Rows - Retrieve paginated results
- Cancel SQL Query - Cancel running queries
Authentication requirements vary by access method.
See OAuth 2.0 Client Credentials Flow for Server-to-Server Integration in Salesforce Help. All REST API calls require a valid OAuth 2.0 access token:
Apex methods use the current user’s session context and permissions automatically. See Getting Started with Apex in the Apex Developer Guide.
- Filter early: Use WHERE clauses to reduce data scanned
- Select specific columns: Avoid
SELECT *statements - Limit results: Use
LIMITfor large datasets - Optimize joins: Include key qualifiers and proper indexing
- Consider your data’s indexed field: Use the DMOs primary index or consider using a secondary index
- Implement asynchronous handling: Data 360 queries use both asynchronous and synchronous responses to optimize performance. Set up your application to handle both synchronous and asynchronous responses.
- Paginate result sets: Use the Connect API
getSqlQueryRowsendpoint withoffsetandrowLimit. You can query yourcreateSqlQueryresults for 24 hours without incurring more consumption charges. Because Data 360 stores results,getSqlQueryRowsreturns data faster than calls tocreateSqlQuery.
Include key qualifier fields in table joins for optimal performance:
When key qualifiers aren’t configured on data lake object fields, the value is null. Use IS NOT DISTINCT FROM for null-safe joins.
- Query Services Status Codes - Error handling reference
- Get Started With Data 360 SQL - SQL tutorial and examples
- Data 360 Metadata API - Explore available data objects
- API Limits and Guidelines - Usage limits and best practices
- Salesforce Developers Blog: Boost Data 360 Integrations with the New Query Connect API