Request Data With Query V2
Use the POST endpoint of Query API V2 to make the first request with the SQL query. The POST endpoint returns data along with batchId for the next batch.
A newer version of the Query API is available. We recommend using the newest Query API.
- HTTP Method: POST
- Availability: Data Cloud v2.0, Salesforce 54.0
- format: REST
- URI:
/api/v2/query
The request body must contain a JSON object with these fields:
Field Name | Field Type | Description |
---|---|---|
sql | string | The SQL query to execute. Must be a valid ANSI standard SQL query. |
The response includes:
data
: Array of record objects containing the requested datastartTime
: ISO 8601 timestamp indicating when the query started executingendTime
: ISO 8601 timestamp indicating when the query finished executingrowCount
: Number of rows returned by the queryqueryId
: Unique identifier for the querynextBatchId
: Identifier for the next batch of resultsdone
: boolean indicating if all results have been returnedmetadata
: Object containing metadata about the fields in the result set
The metadata object contains information about each field on the result set:
Field Name | Field Type | Description |
---|---|---|
type | string | SQL data type of the field |
placeInOrder | integer | Position of the field on the result set |
typeCode | integer | Numeric code representing the SQL data type |
- Use the
done
flag to determine if more results are available - When
done
is false, use thenextBatchId
to retrieve the next set of records - All queries are executed synchronously
- The API supports cursor-based pagination via
nextBatchId
- You must fetch the complete result set within one hour
- The time interval between batch calls must not exceed three minutes