Retrieve Data with Query V2

Use Query API V1 to query Data 360 data lake across data model, data lake, unified, and linked objects.

A newer version of the Query API is available. We recommend using the newest Query API.

Note

Syntax 

  • HTTP Method: POST
  • Availability: Data 360 v1.0, Salesforce v51.0
  • format: REST
  • URI: /api/v1/query

Query Parameters 

ParameterTypeDescription
limitintegerMaximum number of records to return. Default: 49,999. Example: 10
offsetintegerNumber of records to skip before returning results. Example: 100
orderbystringComma-separated values to sort the results in ascending or descending order. Example: GenderId__c ASC, Occupation__c DESC

Request Body 

The request body must contain a JSON object with these fields:

Field NameField TypeDescription
sqlstringThe SQL query to execute. Must be a valid ANSI standard SQL query.

Response Structure 

The response includes:

  • data: Array of record objects containing the requested data
  • startTime: ISO 8601 timestamp indicating when the query started executing
  • endTime: ISO 8601 timestamp indicating when the query finished executing
  • rowCount: Number of rows returned by the query
  • queryId: Unique identifier for the query
  • done: boolean indicating if all results have been returned
  • metadata: Object containing metadata about the fields in the result set

Metadata Object 

The metadata object contains information about each field on the result set:

Field NameField TypeDescription
typestringSQL data type of the field
placeInOrderintegerPosition of the field on the result set
typeCodeintegerNumeric code representing the SQL data type

Examples 

Request 

1POST https://{TSE}.360a.salesforce.com/api/v1/query
2Authorization: Bearer {{cdpAuthToken}}
3Content-Type: application/json
4
5{
6  "sql": "select BirthDate__c, DataSourceId__c, DataSourceObjectId__c, ExternalRecordId__c, FirstName__c, GenderId__c, Id__c, InternalOrganizationId__c, LastName__c from Individual__dlm where Id__c='100470169'"
7}

Response 

1{
2  "data": [
3    {
4      "Id__c": "100470169",
5      "GenderId__c": "M",
6      "FirstName__c": "Joshua",
7      "LastName__c": "Carrier",
8      "BirthDate__c": "2022-07-12T06:41:47.865044Z",
9      "ExternalRecordId__c": "003f200002a3227163",
10      "DataSourceId__c": "SubscribedUsers",
11      "InternalOrganizationId__c": "",
12      "DataSourceObjectId__c": "Subscribers_for_CDP"
13    }
14  ],
15  "startTime": "2020-12-19T06:50:05.251Z",
16  "endTime": "2020-12-19T06:50:05.251Z",
17  "rowCount": 1,
18  "queryId": "3442db1a-ecef-42b3-b0d8-971ee459efa4",
19  "done": true,
20  "metadata": {
21    "BirthDate__c": {
22      "type": "TIMESTAMP WITH TIME ZONE",
23      "placeInOrder": 3,
24      "typeCode": 93
25    },
26    "LastName__c": {
27      "type": "VARCHAR",
28      "placeInOrder": 2,
29      "typeCode": 12
30    },
31    "FirstName__c": {
32      "type": "VARCHAR",
33      "placeInOrder": 1,
34      "typeCode": 12
35    },
36    "InternalOrganizationId__c": {
37      "type": "VARCHAR",
38      "placeInOrder": 5,
39      "typeCode": 12
40    },
41    "Id__c": {
42      "type": "VARCHAR",
43      "placeInOrder": 0,
44      "typeCode": 12
45    },
46    "DataSourceObjectId__c": {
47      "type": "VARCHAR",
48      "placeInOrder": 6,
49      "typeCode": 12
50    },
51    "DataSourceId__c": {
52      "type": "VARCHAR",
53      "placeInOrder": 4,
54      "typeCode": 12
55    },
56    "GenderId__c": {
57      "type": "VARCHAR",
58      "placeInOrder": 7,
59      "typeCode": 12
60    },
61    "ExternalRecordId__c": {
62      "type": "VARCHAR",
63      "placeInOrder": 8,
64      "typeCode": 12
65    }
66  }
67}

Notes 

  • The maximum number of rows returned is 49,999
  • Use the done flag to determine if more results are available
  • When done is false, use the orderby parameter with offset to retrieve the next set of records
  • The API supports ANSI standard SQL queries
  • All queries are executed synchronously
  • Pagination supports limit, offset, and orderby parameters:
    • When the done flag is true in the response, there are no more records to query
    • When the done flag is false, use orderby with offset to retrieve the next set of records

Related Resources