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

# Execute SQL query

> Allows execution of arbitrary SQL queries against the Sample database. Supports parameterized queries.



## OpenAPI

````yaml https://app.stainless.com/api/spec/documented/samplehc/openapi.documented.yml post /api/v1/sql
openapi: 3.0.3
info:
  title: Sample Healthcare API
  description: API for Sample Healthcare
  version: 1.0.0
servers: []
security: []
paths:
  /api/v1/sql:
    post:
      tags:
        - v1
      summary: Execute SQL query
      description: >-
        Allows execution of arbitrary SQL queries against the Sample database.
        Supports parameterized queries.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  description: The SQL query to execute.
                params:
                  type: array
                  items: {}
                  default: []
                  description: >-
                    An array of parameters to be used in the SQL query. Use
                    placeholders like $1, $2, etc. in the query string.
                arrayMode:
                  type: boolean
                  description: >-
                    If true, rows will be returned as arrays of values instead
                    of objects. Defaults to false.
              required:
                - query
              additionalProperties: false
        required: true
      responses:
        '200':
          description: >-
            The result of the SQL query execution. On success, returns 'rows'.
            If the query had issues but was processed, may return an 'error'
            object within a 200 response.
          content:
            application/json:
              schema:
                anyOf:
                  - type: object
                    properties:
                      rows:
                        type: array
                        description: >-
                          An array of results from the query. Each item is an
                          object (default) or an array of values (if arrayMode
                          is true).
                    required:
                      - rows
                    additionalProperties: false
                  - type: object
                    properties:
                      error:
                        type: string
                        description: >-
                          An error message if the query was processed but
                          resulted in a recoverable error (e.g., syntax error in
                          SQL that was caught gracefully).
                    required:
                      - error
                    additionalProperties: false
        '400':
          description: >-
            Bad Request: The SQL query, parameters, or request format is
            invalid.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: A message describing the error.
                required:
                  - error
                additionalProperties: false
        '500':
          description: >-
            Internal Server Error: An unexpected error occurred while executing
            the SQL query.
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                    description: A message describing the error.
                required:
                  - error
                additionalProperties: false

````