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.
Overview
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
API Access Methods
Choose the method that best fits your integration scenario.
Connect REST API
Use the Connect REST API for most integration scenarios. It provides comprehensive features and integrates seamlessly with Salesforce Platform capabilities.
Execute SQL queries synchronously and asynchronously
Returns query ID for tracking and result retrieval. You can pass this queryId to result_scan to query the cached results in a subsequent SQL statement.
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.
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.
Apex Methods
For server-side integration within your Salesforce org, use Apex methods to query Data 360 data.
sfsqlquery Namespace
The sfsqlquery namespace provides object-oriented Apex classes for managing Data 360 SQL query execution with iterators and asynchronous queueables. It includes classes like SqlStatement, SqlRowIterator, Row, QueryHandle, and SqlQueueable for structured query lifecycle management. This namespace is the recommended approach for querying Data 360 data with Apex.
Apex methods use the current user’s session context and permissions automatically. See Getting Started with Apex in the Apex Developer Guide.
Best Practices
Filter early: Use WHERE clauses to reduce data scanned
Select specific columns: Avoid SELECT * statements
Limit results: Use LIMIT for 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 getSqlQueryRows endpoint with offset and rowLimit. You can query your createSqlQuery results for 24 hours without incurring more consumption charges. Because Data 360 stores results, getSqlQueryRows returns data faster than calls to createSqlQuery.
Query Optimization
1-- ✅ Good: Use WHERE clauses to filter data2SELECT ssot__FirstName__c, ssot__LastName__c3FROM ssot__Individual__dlm4WHERE ssot__CreatedDate__c >= '2024-01-01'5AND ssot__IsActive__c = true6LIMIT 100078-- ❌ Avoid: Selecting all data without filters9SELECT * FROM ssot__Individual__dlm
Key Qualifiers in Joins
Include key qualifier fields in table joins for optimal performance:
1SELECT * FROM ssot__ContactPointEmail__dlm email2LEFT JOIN ssot__Individual__dlm individual3ON email.ssot__PartyId__c = individual.ssot__Id__c4AND email.KQ_PartyId__c IS NOT DISTINCT FROM individual.KQ_Id__c5LIMIT 10
When key qualifiers aren’t configured on data lake object fields, the value is null. Use IS NOT DISTINCT FROM for null-safe joins.