---
schema_version: "1"
id: 047a9811efababbb5094ddb0cf316af91d74b3db5d397426b937ec225058b0ea
title: Request Data With Query V2
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-query-api-reference/query-services/query-api-v2/c360a-api-query-v2.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/data-cloud-query-api-reference/c360a-api-query-v2.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 592e2cb8f30d467e47735c325f2554cd8f44f9284736c0b54f714d0104fb2bb6
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# 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.

**note:** A newer version of the Query API is available. We recommend using the newest [Query API](https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/c360a-api-queryservices-overview.md).

## Syntax

- **HTTP Method**: POST
- **Availability**: Data 360 v2.0, Salesforce 54.0
- **format**: REST
- **URI**: `/api/v2/query`

## Request Body

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. |

## 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
- `nextBatchId`: Identifier for the next batch of results
- `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 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 |

## Examples

### Request

```http
POST https://{TSE}.360a.salesforce.com/api/v2/query
Authorization: Bearer {{cdpAuthToken}}
Content-Type: application/json

{
  "sql": "select * from Orders__dll"
}
```

### Response

```json
{
  "data": [
    [
      "s3://dev1-uswest2-cdp001-test-data/sbothra/Orders.csv",
      "aws",
      null,
      null,
      "Office Supplies",
      "0019-01-03",
      null,
      "Philadelphia",
      "United States",
      "MB-18085",
      "Mick Brown",
      "0.200000000000000000",
      "570907236",
      "0019-01-05 00:00:00.000 UTC",
      "0019-01-05",
      "CA-NEW-2014-141817",
      "19143.000000000000000000",
      "OFF-AR-10003478",
      "Avery Hi-Liter EverBold Pen Style Fluorescent Highlighters 4/Pack",
      "4.884000000000000000",
      "3.000000000000000000",
      "East",
      "1760",
      "19.536000000000000000",
      "Consumer",
      "0019-01-12 00:00:00.000 UTC",
      "0019-01-12",
      "Standard Class",
      "Pennsylvania",
      "Art"
    ]
  ],
  "startTime": "2024-05-08T13:30:31.241168Z",
  "endTime": "2024-05-08T13:30:35.571609Z",
  "rowCount": 1,
  "queryId": "20240508_133031_00088_p25a7",
  "nextBatchId": "09151b49-54ed-4948-8139-1f4c7c3a9581",
  "done": false,
  "metadata": {
    "state__c": {
      "type": "VARCHAR",
      "placeInOrder": 28,
      "typeCode": 12
    },
    "sales__c": {
      "type": "DECIMAL",
      "placeInOrder": 23,
      "typeCode": 3
    },
    "productid__c": {
      "type": "VARCHAR",
      "placeInOrder": 17,
      "typeCode": 12
    }
  }
}
```

## Notes

- Use the `done` flag to determine if more results are available
- When `done` is false, use the `nextBatchId` 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

## Related Resources

- [Query Services Status Codes](https://developer.salesforce.com/docs/data/data-cloud-query-guide/c360a-api-queryservices-statuscodes.md)
- [Data Cloud Query Guide](https://developer.salesforce.com/docs/data/data-cloud-query-guide/guide/query-guide-get-started.html)
