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

# Run a SQL query

> Execute a read-only SQL query with RLS org isolation



## OpenAPI

````yaml /api-reference/openapi.json post /api/v1/orgs/{orgSlug}/sql
openapi: 3.0.3
info:
  title: Tolmo API
  version: 1.0.0
  description: >-
    The Tolmo REST API. Every endpoint is scoped to one organization and
    authenticated with an API token.
servers:
  - url: https://api.tolmo.com
    description: Production
security:
  - bearerAuth: []
paths:
  /api/v1/orgs/{orgSlug}/sql:
    post:
      tags:
        - sql
      summary: Run a SQL query
      description: Execute a read-only SQL query with RLS org isolation
      parameters:
        - schema:
            type: string
          in: path
          name: orgSlug
          required: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                query:
                  type: string
                  minLength: 1
                asOf:
                  type: string
                  minLength: 1
              required:
                - query
      responses:
        '200':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  rows:
                    type: array
                    items:
                      type: object
                      additionalProperties: {}
                  fields:
                    type: array
                    items:
                      type: object
                      properties:
                        name:
                          type: string
                        dataTypeID:
                          type: number
                      required:
                        - name
                        - dataTypeID
                      additionalProperties: false
                  metadata:
                    type: object
                    properties:
                      executionTimeMs:
                        type: number
                      rowCount:
                        type: number
                      truncated:
                        type: boolean
                    required:
                      - executionTimeMs
                      - rowCount
                      - truncated
                    additionalProperties: false
                required:
                  - rows
                  - fields
                  - metadata
                additionalProperties: false
        '400':
          description: Default Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  statusCode:
                    type: number
                  error:
                    type: string
                  message:
                    type: string
                required:
                  - statusCode
                  - error
                  - message
                additionalProperties: false
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        A Tolmo API token, sent as `Authorization: Bearer <token>`. Either a
        user token (`usr_tok.*`, minted by `tolmo auth login`, scoped to your
        own permissions) or an org API token created in the Tolmo app, for CI
        and automation.

````