---
title: "Preview a SQL query"
method: POST
path: "/v1/sources/sql/{connectionId}/test-query"
tags: ["Sources"]
---

# Preview a SQL query

`POST /v1/sources/sql/{connectionId}/test-query`

## Request

- Base URL: `https://api.talonic.com`
- URL: `https://api.talonic.com/v1/sources/sql/{connectionId}/test-query`
- Auth: HTTP bearer

Runs one read-only query and answers at most 100 rows, for previewing a saved query. It reads the database live, so it needs the right to configure the connection. A key that belongs to no person (one created before keys named their creator) is refused with 403.

**Scope:** `sources:write`. A key holding only the legacy `write` scope does not satisfy it.

## Path parameters

- `connectionId` string, uuid, required

## Request body

- object
  - `sql_text` string, required: The query.

## Response `200`

The preview.

- SqlQueryPreview
  - `columns` object[]
    - `name` string
    - `db_type` string
  - `rows` array[]
    - unknown[]
      - unknown
  - `truncated` boolean: Whether more rows exist than were returned.

## Other responses

- `400`: The request is invalid.
- `401`: Missing or invalid API key.
- `403`: The API key does not have the required scope.
- `404`: The requested resource was not found.
- `429`: Daily rate limit exceeded.

## Changes

- **2026-11-26** `622d429de7ea`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/talonic/apis/talonic-api/changes/v1/sources/sql/:connectionId/test-query/post.md)

---

[API](https://skmtc.dev/talonic/apis/talonic-api.md) - [All operations](https://skmtc.dev/talonic/apis/talonic-api/llms.txt) - [OpenAPI document](https://skmtc.dev/talonic/apis/talonic-api/revisions/9f6d53e2ab5e?raw)
