---
title: "Execute Query"
method: POST
path: "/api/v1/insights/execute"
tags: ["Insights"]
---

# Execute Query

`POST /api/v1/insights/execute`

Executes an ad-hoc SQL query against the analytics database and returns columnar results.

## Request body

- ExecuteQueryRequest — Request body for executing an ad-hoc SQL query.
  - `sql` string, required — SQL query to execute.

## Response `200`

Query results

- ExecuteQueryResponse — Columnar result set from an executed query.
  - `columns` string[], required — Column names in the result set.
  - `rows` array[], required — Result rows, each an array of values matching the column order.
    - union[]
      - union
        - string
        - number
        - boolean
  - `elapsed` number, required — Query execution time in seconds.
  - `row_count` integer, required — Number of rows returned.

## Other responses

- `400` — Bad SQL or query error

---

[API](https://skmtc.net/fabro-sh/apis/fabro-run-api.md) · [All operations](https://skmtc.net/fabro-sh/apis/fabro-run-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/fabro-sh/fabro-run-api/versions/bee030053823/schema)
