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

# Query

> Execute a single statement classified as read-only SQL with a database read-only transaction, five-second timeout, cancellation id, and hard row and byte limits.



## OpenAPI

````yaml /openapi.json post /v1/orgs/{orgId}/projects/{projectId}/databases/{databaseId}/query
openapi: 3.1.0
info:
  title: Korve API
  version: 0.1.0
  description: >-
    Typed control plane for deploying applications and explicitly provisioning
    their managed infrastructure.
servers:
  - url: https://api.korve.dev
security: []
paths:
  /v1/orgs/{orgId}/projects/{projectId}/databases/{databaseId}/query:
    post:
      tags:
        - databases
      summary: Query
      description: >-
        Execute a single statement classified as read-only SQL with a database
        read-only transaction, five-second timeout, cancellation id, and hard
        row and byte limits.
      operationId: databases.query
      parameters:
        - name: orgId
          in: path
          required: true
          schema:
            type: string
          description: The organization's id (UUID) or slug — either form is accepted.
        - name: projectId
          in: path
          required: true
          schema:
            type: string
          description: The project's id (UUID) or slug — either form is accepted.
        - name: databaseId
          in: path
          required: true
          schema:
            type: string
          description: The database's id (UUID), from databases.list.
      requestBody:
        required: true
        x-korve-max-bytes: 1048576
        content:
          application/json:
            schema:
              type: object
              properties:
                queryId:
                  type: string
                  description: Caller-generated UUID used for cancellation.
                sql:
                  type: string
                  description: >-
                    One SELECT, VALUES, SHOW, EXPLAIN, or WITH ... SELECT
                    statement.
                limit:
                  type: integer
                  description: Maximum rows from 1 to 500. Defaults to 500.
              required:
                - queryId
                - sql
              additionalProperties: false
      responses:
        '200':
          description: Bounded query results and measurements.
          content:
            application/json:
              schema:
                type: object
                properties:
                  columns:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        dataType:
                          type: string
                      required:
                        - name
                        - dataType
                  rows:
                    type: array
                    items:
                      type: object
                      additionalProperties:
                        anyOf:
                          - type: 'null'
                          - type: string
                          - type: number
                          - type: boolean
                          - type: object
                            additionalProperties: true
                          - type: array
                            items: {}
                  nextCursor:
                    type:
                      - string
                      - 'null'
                  durationMs:
                    type: number
                  rowCount:
                    type: integer
                  bytes:
                    type: integer
                  truncated:
                    type: boolean
                    description: >-
                      True when the server row or byte ceiling stopped
                      collection.
                required:
                  - columns
                  - rows
                  - nextCursor
                  - durationMs
                  - rowCount
                  - bytes
                  - truncated
        '404':
          description: No ready database in this project.
        '409':
          description: The query id already exists for this database.
        '422':
          description: >-
            Empty, multi-statement, locking, data-modifying, or otherwise unsafe
            SQL.
        '429':
          description: Database explorer concurrency or rate limit reached.
        '504':
          description: Read-only query exceeded its statement timeout.
      security:
        - apiKey: []
        - session: []
components:
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      bearerFormat: korve_api_key
    session:
      type: apiKey
      in: cookie
      name: korve.session_token

````