---
title: "Sql Query Entity"
method: GET
path: "/api/v1/ontology/entities/{entity_id}/query"
tags: ["ontology-query"]
---

# Sql Query Entity

`GET /api/v1/ontology/entities/{entity_id}/query`

Run caller-authored SQL over this entity + its 2-hop closure.

## Path parameters

- `entity_id` string, uuid, required

## Query parameters

- `sql` string, required — Read-only DuckDB SQL; tables are entity names
- `limit` integer

## Response `200`

Successful Response

- EntityQueryResponse — Result of a raw-SQL query scoped to one entity's relationship neighbourhood. Columns are `ColumnSpec` objects where `type` is a display type from `domain.rules.duckdb_display_type` (`String` | `Number` | `Boolean` | `Date` | `Datetime`), not a raw DuckDB type.
  - `columns` ColumnSpec[], required
    - `name` string, required
    - `type` string, required
  - `rows` object[], required
  - `total_rows` integer, required
  - `truncated` boolean, required
  - `row_key_column` string, nullable
  - `row_key_injected` boolean

## Other responses

- `422` — Validation Error

## Changes

> 15 revisions in range; 1 not diffed.

- **2026-08-28** `eed6fb164abd` — 2 info
  - added the optional property `row_key_column` to the response with the `200` status
  - added the optional property `row_key_injected` to the response with the `200` status

[Change history](https://skmtc.dev/netter/apis/dmi-backend/changes/api/v1/ontology/entities/:entity_id/query/get.md)

---

[API](https://skmtc.dev/netter/apis/dmi-backend.md) · [All operations](https://skmtc.dev/netter/apis/dmi-backend/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/netter/dmi-backend/revisions/307ede8c429b/schema)
