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

# Execute single SQL statement

> Internal endpoint on `d1-worker`. Executes a single parameterised
SQL statement against the D1 database. Only `SELECT`,
`INSERT`, `UPDATE`, `DELETE`, and `REPLACE` are allowed.
String literals and `UNION` are rejected.




## OpenAPI

````yaml /docs/openapi-minimal.yaml post /query
openapi: 3.0.3
info:
  title: Hoox API
  description: |
    REST API for the Hoox algorithmic trading platform.

    Ingest trade signals, check system health, and manage DeFi wallet
    operations on the Cloudflare edge. All requests are handled by the
    Hoox gateway worker (`workers/hoox`) running at the network edge.
  version: 1.0.0
  contact:
    name: Hoox Support
    email: support@hoox.sh
servers:
  - url: https://api.hoox.sh
    description: Production API
  - url: https://staging.hoox.sh
    description: Staging environment
security: []
paths:
  /query:
    post:
      tags:
        - Database
      summary: Execute single SQL statement
      description: |
        Internal endpoint on `d1-worker`. Executes a single parameterised
        SQL statement against the D1 database. Only `SELECT`,
        `INSERT`, `UPDATE`, `DELETE`, and `REPLACE` are allowed.
        String literals and `UNION` are rejected.
      operationId: executeQuery
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - query
              properties:
                requestId:
                  type: string
                  format: uuid
                  description: Optional correlation ID for tracing
                  example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                query:
                  type: string
                  description: Parameterised SQL statement
                  example: SELECT * FROM trades WHERE symbol = ? LIMIT ?
                params:
                  type: array
                  description: Bound parameters for the prepared statement
                  items: {}
                  example:
                    - BTCUSDT
                    - 5
      responses:
        '200':
          description: Query executed successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  requestId:
                    type: string
                    format: uuid
                    example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
                  results:
                    type: array
                    description: Rows returned by SELECT queries
                    items: {}
                  lastRowId:
                    type: integer
                    nullable: true
                    description: Row ID for INSERT/REPLACE
                  changes:
                    type: integer
                    nullable: true
                    description: Rows changed for INSERT/UPDATE/DELETE
        '400':
          description: Invalid SQL or parameter binding
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Internal authentication missing or invalid
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: |
            Table not in the allowlist, `UNION` detected, or subquery
            in `WHERE`/`HAVING` clause.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal D1 error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    ErrorResponse:
      type: object
      properties:
        success:
          type: boolean
          example: false
        requestId:
          type: string
          format: uuid
          description: Request trace identifier
          example: 9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d
        error:
          type: string
          description: Human-readable error description
          example: Invalid JSON payload structure.

````