> ## Documentation Index
> Fetch the complete documentation index at: https://docs.isofold.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Submit Query

> Submits a query to Isofold for optimization and execution.

Submit a SQL query to Isofold. The query will be analyzed, rewritten, and executed against the configured data warehouse. This is the primary entrypoint for using Isofold programmatically.

***

## Request

Send a JSON payload like the following:

```json theme={null}
{
  "query": "SELECT * FROM users WHERE created_at >= '2024-01-01'",
  "warehouse": "bigquery"
}
```

### Fields

| Field       | Type   | Required | Description                                          |
| ----------- | ------ | -------- | ---------------------------------------------------- |
| `query`     | string | ✅        | The raw SQL to execute                               |
| `warehouse` | string | ✅        | Target warehouse (`bigquery`, `snowflake`, `aurora`) |

***

## Response

```json theme={null}
{
  "trace_id": "abc123",
  "rewritten_query": "SELECT id, email, created_at FROM users WHERE created_at >= '2024-01-01'",
  "duration_ms": 142,
  "rows": 1024
}
```

### Fields

| Field             | Type    | Description                              |
| ----------------- | ------- | ---------------------------------------- |
| `trace_id`        | string  | Unique identifier for this request       |
| `rewritten_query` | string  | The version Isofold actually executed    |
| `duration_ms`     | number  | Total end-to-end latency in milliseconds |
| `rows`            | integer | Row count in the result set              |

***

## Authorization

All requests must include a Bearer token:

```bash theme={null}
Authorization: Bearer YOUR_API_KEY
```

***

Next: [Estimate Cost](/api-reference/endpoint/cost)


## OpenAPI

````yaml POST /query
openapi: 3.1.0
info:
  title: Isofold API
  description: >-
    Programmatic interface for sending queries, estimating cost, and verifying
    outputs using Isofold.
  version: 1.0.0
servers:
  - url: https://api.isofold.com
security:
  - bearerAuth: []
paths:
  /query:
    post:
      description: Submits a query to Isofold for optimization and execution.
      requestBody:
        description: The SQL query to run
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/QueryRequest'
      responses:
        '200':
          description: Query completed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/QueryResponse'
components:
  schemas:
    QueryRequest:
      type: object
      properties:
        query:
          type: string
        warehouse:
          type: string
          enum:
            - bigquery
            - snowflake
            - aurora
      required:
        - query
        - warehouse
    QueryResponse:
      type: object
      properties:
        trace_id:
          type: string
        rewritten_query:
          type: string
        duration_ms:
          type: number
        rows:
          type: integer
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````