---
title: "Execute Agent Insights free-form SQL"
method: POST
path: "/v1/internal/analytics-queries/projects/{projectId}"
tags: ["System analytics queries"]
---

# Execute Agent Insights free-form SQL

`POST /v1/internal/analytics-queries/projects/{projectId}`

Runs Ollie-generated read-only SQL bounded to the caller's workspace and the requested project. Returns 501 when the Agent Insights toggle is off.

## Path parameters

- `projectId` string, uuid, required

## Request body

- AnalyticsQueryRequest
  - `query` string, required — Read-only ClickHouse SQL. Must return exactly one column named `result` produced via toJSONString(...)

## Response `200`

Query results

- AnalyticsQueryResponse
  - `results` JsonNode[]

## Other responses

- `400` — Bad Request
- `422` — Unprocessable Content
- `501` — Agent Insights queries are not enabled

## Changes

- **2026-06-17** `de1e3e19f7fc` — 1 info
  - endpoint added
- **2026-05-04** `d606e84c75e4` — 1 breaking
  - api path removed without deprecation

[Change history](https://skmtc.dev/comet-ml/apis/opik-rest-api/changes/v1/internal/analytics-queries/projects/:projectId/post.md)

---

[API](https://skmtc.dev/comet-ml/apis/opik-rest-api.md) · [All operations](https://skmtc.dev/comet-ml/apis/opik-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/comet-ml/opik-rest-api/revisions/1a1bcfd67f99/schema)
