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

# Run analytics query

> Runs a read-only ClickHouse SQL query against the current project's analytics dataset.



## OpenAPI

````yaml /openapi/server.json post /analytics/query
openapi: 3.1.0
info:
  title: Hexclave REST API
  version: 1.0.0
  description: >-
    The Hexclave REST API. All request headers are documented as canonical
    `X-Hexclave-*`; the equivalent `X-Stack-*` aliases are accepted on every
    endpoint for backwards compatibility. Response headers
    `X-Hexclave-actual-status`, `X-Hexclave-known-error`, and
    `X-Hexclave-request-id` are emitted alongside their legacy `X-Stack-*`
    equivalents.
servers:
  - url: https://api.hexclave.com/api/v1
    description: Hexclave REST API
security: []
paths:
  /analytics/query:
    post:
      tags:
        - Analytics
      summary: Run analytics query
      description: >-
        Runs a read-only ClickHouse SQL query against the current project's
        analytics dataset.
      parameters: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                include_all_branches:
                  type: boolean
                  example: false
                  description: >-
                    Reserved for future branch-wide analytics queries. Must be
                    false.
                  default: false
                query:
                  type: string
                  example: SELECT count() AS event_count FROM events
                  description: A read-only ClickHouse SQL query.
                params:
                  type: object
                  properties: {}
                  required: []
                  example:
                    event_type: $page-view
                  description: ClickHouse query parameters referenced by the query.
                  default: {}
                timeout_ms:
                  type: integer
                  example: 10000
                  description: >-
                    Maximum query execution time in milliseconds. The effective
                    timeout is also capped by the project's plan.
                  default: 10000
              required:
                - query
              example:
                include_all_branches: false
                query: SELECT count() AS event_count FROM events
                params:
                  event_type: $page-view
                timeout_ms: 10000
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  result:
                    type: array
                    items:
                      type: object
                    example:
                      - event_count: 42
                    description: Query result rows as plain JSON objects.
                  query_id:
                    type: string
                    example: >-
                      00000000-0000-0000-0000-000000000000:main:00000000-0000-0000-0000-000000000001
                    description: >-
                      The ClickHouse query ID. Use it to fetch query timing
                      stats.
                required:
                  - result
                  - query_id

````