# Execute free-form analytics SQL

**POST** `/v1/internal/analytics-queries`

Runs read-only SQL bounded to the caller's workspace. Supply project_id to restrict traces, spans, feedback scores and trace threads to one project, or omit it to cover the whole workspace. Experiments, experiment items and dataset items always cover the whole workspace.

Base URL: `https://www.comet.com/opik/api`

Tags: `System analytics queries`

## Authorization

This operation requires no authorization.

## Request body

Optional. Media type: `application/json`

### Example request body

```json
{
  "project_id": "00000000-0000-0000-0000-000000000000",
  "query": "string"
}
```

## Responses

| Status | Description | Media type |
| --- | --- | --- |
| `200` | Query results | `application/json` |
| `400` | Bad Request | `application/json` |
| `422` | Unprocessable Content | `application/json` |
| `501` | Agent Insights is disabled, or Custom Charts is not enabled for this workspace | — |

### Example response: 200 — Query results

```json
{
  "results": [
    {}
  ]
}
```

### Example response: 400 — Bad Request

```json
{
  "code": 0,
  "details": "string",
  "message": "string"
}
```

### Example response: 422 — Unprocessable Content

```json
{
  "code": 0,
  "details": "string",
  "message": "string"
}
```

## Related pages

- [Activate a pairing session](./activatepairingsession.md)
- [Add blueprint to existing config](./updateagentconfig.md)
- [Add items to annotation queue](./additemstoannotationqueue.md)
- [Add span comment](./addspancomment.md)
- [Add span feedback score](./addspanfeedbackscore.md)
- [Add thread comment](./addthreadcomment.md)
- [Add trace comment](./addtracecomment.md)
- [Add trace feedback score](./addtracefeedbackscore.md)
- [Agent Configs](./tags/agent-configs.md)
- [Agent Insights](./tags/agent-insights.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
