# Explore API

Source: https://userguide.qualytics.io/explore/api/

You can manage your Explore workspaces, run read-only SQL and page through its result, read a container's rows as its **Explore** tab shows them, read the run history, and load the SQL keywords and functions a datastore accepts.

All endpoints use the base URL of your Qualytics deployment (e.g., `https://your-instance.qualytics.io/api`) and require a Personal API Token, sent as a Bearer token in the `Authorization` header.

> **Tip**
>
> For complete API documentation, including request/response schemas, visit the [API docs](https://userguide.qualytics.io/api/docs).

> **Note: Permissions**
>
> Every endpoint on this page requires the **Member** role or above. Workspaces and results belong to the user who created them: nobody else can read or change them, Admins included. Running SQL needs the **Author** or **Editor** team permission on every datastore the query reads. Reading a container needs **Viewer**, and custom columns need **Author** or **Editor**. Admins act as **Editor** on every datastore and read everyone's runs. See [Explore Permissions](https://userguide.qualytics.io/explore/deep-dive/permissions/) for the full matrix.

---

## Result States

A query runs once, and its rows are kept as a result you read page by page. Reading more rows never runs the query again. Each result reports a `state`:

| State | Meaning |
| --- | --- |
| `running` | The query is still producing rows. A page can come back short while more are on their way. |
| `completed` | The query finished and every row is available. |
| `partial` | The result stopped early, for example at the size limit set for your deployment, or at the `max_rows` you asked for. The rows kept so far are available, and `message` says why it stopped. |
| `failed` | The query failed. `message` holds the reason. |
| `cancelled` | The result was closed while the query was still running. |
| `expired` | The result was closed for you: nobody read it for 30 minutes, or a newer result of yours took its place. |

Each user keeps up to three open results. Opening another closes the one read least recently. Masked values come back as `***MASKED***` unless you reveal them.

---

## SQL Workspaces

A SQL workspace holds a name, an optional datastore, the SQL, and the SQL mode: `source` runs on the datastore in its own SQL, `spark` runs in Qualytics with Spark SQL over the datastore's containers.

### List Your Workspaces

**Endpoint:** `GET /explore/workspaces`

**Permission:** Member role or above. Returns your own workspaces, oldest first.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/explore/workspaces" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response**:
>
> ```json
> [
>   {
>     "id": 41,
>     "name": "Orders by month",
>     "datastore_id": 12,
>     "sql": "SELECT date_trunc('month', created_at) AS month, COUNT(*) AS orders FROM orders GROUP BY 1 ORDER BY 1",
>     "sql_mode": "source",
>     "chat_session_id": 903,
>     "last_run": {
>       "result_id": "b1f0c6a2-3d4e-4f5a-8b9c-0d1e2f3a4b5c",
>       "sql": "SELECT date_trunc('month', created_at) AS month, COUNT(*) AS orders FROM orders GROUP BY 1 ORDER BY 1",
>       "sql_mode": "source",
>       "datastore_id": 12,
>       "read_datastore_ids": [12],
>       "ran_at": "2026-11-18T14:02:11Z",
>       "elapsed_ms": 812.4
>     },
>     "created": "2026-11-10T13:00:00Z",
>     "updated_at": "2026-11-18T14:02:12Z"
>   }
> ]
> ```

### Create a Workspace

**Endpoint:** `POST /explore/workspaces`

**Permission:** Member role or above, and the **Viewer** team permission on `datastore_id` when you set one.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | Yes | From 1 to 255 characters. Spaces around it are trimmed. |
| `datastore_id` | `integer` | No | The datastore the workspace queries. |
| `sql` | `string` | No | The SQL, up to 1,000,000 characters. Defaults to empty. |
| `sql_mode` | `string` | No | `source` or `spark`. Defaults to `source`. |

> **Example: Example request**
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/explore/workspaces" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "name": "Orders by month",
>     "datastore_id": 12,
>     "sql": "SELECT status, COUNT(*) AS orders FROM orders GROUP BY status",
>     "sql_mode": "source"
>   }'
> ```

### Update a Workspace

Changes only the fields you send. Sending `null` for `name`, `datastore_id`, `sql`, or `sql_mode` changes nothing, so a workspace's datastore cannot be cleared this way.

**Endpoint:** `PATCH /explore/workspaces/{id}`

**Permission:** Member role or above, on your own workspace. **Viewer** on a new `datastore_id`.

| Field | Type | Description |
| --- | --- | --- |
| `name` | `string` | A new name. |
| `datastore_id` | `integer` | A new datastore. |
| `sql` | `string` | The SQL. |
| `sql_mode` | `string` | `source` or `spark`. |
| `chat_session_id` | `integer` | Your own AgentQ chat to link as the workspace's **Explore Assistant** chat. `null` unlinks it. |
| `last_run` | `object` | The run the workspace reopens: `result_id` (one of your results), `sql`, `sql_mode`, `datastore_id`, `read_datastore_ids`, `ran_at`, `elapsed_ms`. `null` forgets it. |

> **Example: Example request**
>
> ```bash
> curl -X PATCH "https://your-instance.qualytics.io/api/explore/workspaces/41" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{ "name": "Orders by status" }'
> ```

### Delete a Workspace

Deletes the workspace permanently. Its runs stay in the history, with the name they ran under.

**Endpoint:** `DELETE /explore/workspaces/{id}`

**Permission:** Member role or above, on your own workspace. Returns `204 No Content`.

> **Example: Example request**
>
> ```bash
> curl -X DELETE "https://your-instance.qualytics.io/api/explore/workspaces/41" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

---

## Container Workspaces

A container workspace stores what a container's **Explore** tab shows: hidden columns, custom columns, and a filter. Each user has a default workspace named `Preview` on every container, created the first time the list is read.

### List a Container's Workspaces

**Endpoint:** `GET /containers/{id}/workspaces`

**Permission:** Member role or above, and **Viewer** on the container. Returns your own workspaces on it, with `Preview` first.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/containers/300/workspaces" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response**:
>
> ```json
> [
>   {
>     "id": 7,
>     "name": "Preview",
>     "container_id": 300,
>     "datastore_id": 12,
>     "hidden": [],
>     "custom": [],
>     "filter": "",
>     "is_default": true,
>     "chat_session_id": null,
>     "created": "2026-11-18T10:00:00Z",
>     "updated_at": "2026-11-18T10:00:00Z"
>   }
> ]
> ```

### Create a Container Workspace

**Endpoint:** `POST /containers/{id}/workspaces`

**Permission:** Member role or above, and **Viewer** on the container.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `name` | `string` | Yes | The workspace name. |
| `hidden` | `list of strings` | No | Columns hidden from the results. |
| `custom` | `list of objects` | No | Custom columns, each with a `name` (up to 255 characters) and a Spark SQL `expression` (up to 10,000 characters). They are stored as written and checked when the workspace runs. |
| `filter` | `string` | No | A `WHERE` clause for the rows. |

> **Example: Example request**
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/containers/300/workspaces" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "name": "Open orders in USD",
>     "custom": [{ "name": "total_usd", "expression": "total * fx_rate" }],
>     "filter": "status = '\''open'\''"
>   }'
> ```

### Update a Container Workspace

Changes only the fields you send: `name`, `hidden`, `custom`, `filter`, or `chat_session_id`. The `Preview` workspace keeps its name.

**Endpoint:** `PATCH /container-workspaces/{id}`

**Permission:** Member role or above, on your own workspace.

> **Example: Example request**
>
> ```bash
> curl -X PATCH "https://your-instance.qualytics.io/api/container-workspaces/8" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{ "filter": "status = '\''shipped'\''" }'
> ```

### Delete a Container Workspace

The `Preview` workspace cannot be deleted.

**Endpoint:** `DELETE /container-workspaces/{id}`

**Permission:** Member role or above, on your own workspace. Returns `204 No Content`.

> **Example: Example request**
>
> ```bash
> curl -X DELETE "https://your-instance.qualytics.io/api/container-workspaces/8" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

---

## Results

### Run a Query

Runs a read-only query once and answers with its first page. Every run that passes the checks is recorded in the run history, whether or not it names a workspace.

**Endpoint:** `POST /result-sessions`

**Permission:** Member role or above, and **Author** or **Editor** on every datastore the query reads. The datastores are taken from the SQL.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `datastore_id` | `integer` | Yes | The datastore the query runs through. |
| `query` | `string` | Yes | One read-only query, up to 1,000,000 characters. A trailing `;` is removed. The SQL runs as written: `{{ name }}` placeholders are not filled in. |
| `sql_mode` | `string` | No | `source` (default) or `spark`. A file datastore runs `spark` only. |
| `first_page_rows` | `integer` | No | Rows to return with the answer, from 0 to 1,000. Defaults to 100. |
| `max_rows` | `integer` | No | The most rows the result holds, from 1 to 1,000, for a sample. The query stops at that many rows instead of running to its end, and a result cut there ends as `partial` with the message `Stopped at <max_rows> rows: the most the query asked for`. Without it, the result holds every row, up to the size limit. |
| `reveal_masked` | `boolean` | No | `true` returns the values of masked columns. You need the right to reveal every masked field the result shows, and each reveal is recorded in the masking audit log. Defaults to `false`. |
| `workspace_id` | `integer` | No | One of your SQL workspaces, so the run is listed on its **History** tab. Ignored when the workspace is not yours. |
| `session_id` | `string` | No | An id you pick for the result: 16 to 64 letters, digits, `_` or `-`, unused. Knowing it up front lets you close the result before this call answers. Without it, an id is picked for you. |

The call waits up to about 20 seconds for the first rows. A slower query answers with `state` `running` and fewer rows, or none; read the rest with [Read Rows](https://userguide.qualytics.io/explore/api/#read-rows).

In the response, `columns` describes each column:

- `name`, `type`, and whether it is `masked`.
- `source`, when the column shows a field unchanged: the field's `container_id`, `field_id`, and `field_name`, its `active_anomaly_count` and `active_check_count` at the time of the run, and its latest profile as `field_profile_id` (`null` when the field was never profiled).
- `role`, what the column is to the query's own grouping: `group` for a key of the outermost `GROUP BY` (written the same, by its alias, or by its position), `aggregate` for an aggregate the outermost `SELECT` computes over each group, such as `SUM(total)` or `COUNT(*)`, or `null`. An aggregate inside a subquery or a window function does not count. Every column is `null` when the query has no single outermost `SELECT` to read, such as a `UNION` or a `SELECT *`.

`total_rows` is known once the query reached its end, and `next_offset` is `null` when no rows are left. `can_reveal` says whether you may reveal the masked columns.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/result-sessions" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "datastore_id": 12,
>     "query": "SELECT o.id, o.email FROM orders o ORDER BY o.id",
>     "sql_mode": "source",
>     "first_page_rows": 100,
>     "workspace_id": 41,
>     "session_id": "orders-export-0001"
>   }'
> ```
>
> **Response** (abbreviated):
>
> ```json
> {
>   "session_id": "orders-export-0001",
>   "datastore_id": 12,
>   "state": "running",
>   "columns": [
>     {
>       "name": "id",
>       "type": "Integral",
>       "masked": false,
>       "source": {
>         "container_id": 300,
>         "field_id": 5512,
>         "field_name": "id",
>         "active_anomaly_count": 2,
>         "active_check_count": 4,
>         "field_profile_id": 88120
>       },
>       "role": null
>     },
>     { "name": "email", "type": "String", "masked": true, "source": null, "role": null }
>   ],
>   "rows_written": 100,
>   "total_rows": null,
>   "message": null,
>   "revealed": false,
>   "can_reveal": true,
>   "offset": 0,
>   "rows": [ { "id": 1, "email": "***MASKED***" } ],
>   "next_offset": 100
> }
> ```

> **Example: Example request for a sample of 25 rows**
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/result-sessions" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "datastore_id": 12,
>     "query": "SELECT o.id, o.status, o.total FROM orders o",
>     "sql_mode": "source",
>     "first_page_rows": 25,
>     "max_rows": 25
>   }'
> ```
>
> When the query has more than 25 rows, the result ends as `partial`, with `"message": "Stopped at 25 rows: the most the query asked for"`.

### Read a Container's Rows

Reads a container's rows as its **Explore** tab shows them: the fields you choose, custom columns computed over each row, and a filter. The first page holds 100 rows. When the source supports it, `next_offset` is `100` and the result stays open for [Read Rows](https://userguide.qualytics.io/explore/api/#read-rows). Otherwise the answer holds the whole result, limited to the first 100 rows, and the result closes at once. These reads are not recorded in the run history.

**Endpoint:** `POST /containers/{id}/result-sessions`

**Permission:** Member role or above, **Viewer** on the container, and **Author** or **Editor** on its datastore when `custom_columns` is not empty.

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `fields` | `list of strings` | No | Fields to show, in order. Every field when omitted. Unknown names are skipped. |
| `custom_columns` | `list of objects` | No | Up to 50 columns, each with a `name` (letters, digits and `_`, not starting with a digit, unlike any field) and a Spark SQL `expression` over the row (up to 10,000 characters). A later column can read an earlier one. |
| `filter` | `string` | No | A `WHERE` clause: the datastore's own SQL for a database, Spark SQL otherwise. It cannot read computed fields. |
| `reveal_masked` | `boolean` | No | `true` returns masked values you may reveal. Each reveal is recorded in the masking audit log. |

> **Example: Example request**
>
> ```bash
> curl -X POST "https://your-instance.qualytics.io/api/containers/300/result-sessions" \
>   -H "Authorization: Bearer YOUR_TOKEN" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "fields": ["id", "status", "total"],
>     "custom_columns": [{ "name": "total_usd", "expression": "total * fx_rate" }],
>     "filter": "status = '\''open'\''"
>   }'
> ```

### Get a Result's Status

Returns the result's state, columns, and row counts, without rows.

**Endpoint:** `GET /result-sessions/{session_id}`

**Permission:** Member role or above, on your own result.

> **Example: Example request**
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/result-sessions/orders-export-0001" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

### Read Rows

Returns a page of the result by row offset, from the stored result. Your permissions are checked again on every call.

**Endpoint:** `GET /result-sessions/{session_id}/rows`

**Permission:** Member role or above, on your own result, with the same team permissions the run needed.

| Query Parameter | Type | Description |
| --- | --- | --- |
| `offset` | `integer` | The first row to return, from 0. Defaults to 0. |
| `limit` | `integer` | Rows to return, from 1 to 1,000. Defaults to 100. A page can also end early when its rows are very large. |

The call waits up to 30 seconds for rows the query has not produced yet. A short page with `state` `running` means more rows may follow. Read until `next_offset` is `null`.

> **Example: Example request**
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/result-sessions/orders-export-0001/rows?offset=100&limit=1000" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

### Follow Status Changes

Streams the result's status as server-sent events. Each change arrives as an `event: status` message with the status JSON. A keep-alive comment is sent every 15 seconds, and the stream ends when the result ends, or after 30 minutes.

**Endpoint:** `GET /result-sessions/{session_id}/events`

**Permission:** Member role or above, on your own result.

> **Example: Example request and stream**
>
> **Request**:
>
> ```bash
> curl -N "https://your-instance.qualytics.io/api/result-sessions/orders-export-0001/events" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Stream** (abbreviated):
>
> ```text
> event: status
> data: {"session_id": "orders-export-0001", "state": "running", "rows_written": 30000, ...}
>
> : keep-alive
>
> event: status
> data: {"session_id": "orders-export-0001", "state": "completed", "rows_written": 48210, "total_rows": 48210, ...}
> ```

### Refresh Anomaly Counts

Reads again the active anomalies of the fields the result's columns show. The counts in `columns` are those at the time of the run; this call refreshes them, also after the result is closed. Fields with no active anomalies are left out.

**Endpoint:** `GET /result-sessions/{session_id}/anomaly-counts`

**Permission:** Member role or above, on your own result, with the same team permissions the run needed.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/result-sessions/orders-export-0001/anomaly-counts" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response** (field ID to active anomalies):
>
> ```json
> { "counts": { "5512": 2 } }
> ```

### Close or Stop a Result

Closes a result and frees its rows. A result still running ends as `cancelled`; a finished one keeps its state. To stop a query before its first page arrives, send a `session_id` when you [run the query](https://userguide.qualytics.io/explore/api/#run-a-query) and close that id from another request: the run then answers `410` with `The query was stopped`.

**Endpoint:** `DELETE /result-sessions/{session_id}`

**Permission:** Member role or above, on your own result. Returns `204 No Content`.

> **Example: Example request**
>
> ```bash
> curl -X DELETE "https://your-instance.qualytics.io/api/result-sessions/orders-export-0001" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

> **Note: Source records endpoints**
>
> `GET /containers/{id}/source-records` and `GET /datastores/{id}/source-records` are deprecated. Use [Read a Container's Rows](https://userguide.qualytics.io/explore/api/#read-a-containers-rows) and [Read Rows](https://userguide.qualytics.io/explore/api/#read-rows) instead.

---

## Run History

Every SQL run that passes the checks is recorded when its result opens, through the UI or the API, and kept for 90 days. Queries refused before they run and container reads are not recorded. Members, Managers, and Admins read their own runs; Admins read everyone's.

### List Runs

**Endpoint:** `GET /explore/runs`

**Permission:** Member role or above.

| Query Parameter | Type | Description |
| --- | --- | --- |
| `workspace_id` | `integer` | Only the runs of this workspace. |
| `users` | `list of integers` | Only the runs of these users. Repeat the parameter for several values. Admins only; ignored for other users. |
| `start_date`, `end_date` | `string` (`YYYY-MM-DD`) | Run dates to include, both inclusive. |
| `datastore_id` | `integer` | Only the runs through this datastore. |
| `outcome` | `string` | `succeeded` or `failed`. Stopped runs count as neither. |
| `search` | `string` | Text the run's SQL contains, ignoring case. |
| `sort_ran`, `sort_duration`, `sort_rows`, `sort_user` | `asc` / `desc` | Sort order. Without one, the newest runs come first. |
| `page`, `size` | `integer` | Page number, from 1, and page size, up to 100. Defaults to 50 per page. |

Each run carries the user, the workspace and its name at the time of the run, the datastore it ran through, `read_datastore_ids` (the other datastores it read), the `query`, the `sql_mode`, the `state`, the failure `message`, `row_count`, `elapsed_ms` (from the start to the first rows), and whether masked values were `revealed`. `row_count_final` is `false` when the count holds only the rows read so far. `workspace_id` is `null` once the workspace is deleted, and `workspace_name` keeps its name.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/explore/runs?outcome=failed&start_date=2026-11-01&end_date=2026-11-18" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response** (abbreviated):
>
> ```json
> {
>   "items": [
>     {
>       "id": 812,
>       "user": { "id": 4, "name": "Jane Doe", "email": "jdoe@example.com", "role": "Member" },
>       "workspace_id": 41,
>       "workspace_name": "Orders by month",
>       "datastore_id": 12,
>       "read_datastore_ids": [15],
>       "query": "SELECT o.id, c.segment FROM orders o JOIN crm.customers c ON c.id = o.customer_id",
>       "sql_mode": "source",
>       "state": "failed",
>       "message": "column c.segment does not exist",
>       "row_count": 0,
>       "row_count_final": true,
>       "elapsed_ms": 412,
>       "revealed": false,
>       "created": "2026-11-18T14:02:11Z"
>     }
>   ],
>   "total": 1,
>   "page": 1,
>   "size": 50,
>   "pages": 1
> }
> ```

### Summarize Runs

Totals for every run the filters match, across all pages. Takes the same filters as [List Runs](https://userguide.qualytics.io/explore/api/#list-runs), without sorting or paging.

**Endpoint:** `GET /explore/runs/summary`

**Permission:** Member role or above.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/explore/runs/summary?start_date=2026-11-01" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response**:
>
> ```json
> {
>   "runs": 120,
>   "failed": 9,
>   "stopped": 3,
>   "people": 4,
>   "datastores": 6,
>   "average_elapsed_ms": 1543.2,
>   "rows": 98213
> }
> ```

### List Users Who Ran Queries

Returns the users who ran something between the dates: everyone for an Admin, yourself for other users.

**Endpoint:** `GET /explore/runs/users`

**Permission:** Member role or above.

| Query Parameter | Type | Description |
| --- | --- | --- |
| `start_date`, `end_date` | `string` (`YYYY-MM-DD`) | Run dates to include, both inclusive. |

> **Example: Example request**
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/explore/runs/users?start_date=2026-11-01&end_date=2026-11-18" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```

---

## SQL Vocabulary

Returns the keywords and functions a datastore accepts in a mode, as the editor's autocomplete uses them. Only what works in a read-only query is listed. The list is a suggestion: the checks at run time decide what may run.

**Endpoint:** `GET /datastores/{id}/sql-vocabulary`

**Permission:** Member role or above, and any team permission on the datastore.

| Query Parameter | Type | Description |
| --- | --- | --- |
| `sql_mode` | `string` | `source` (default) or `spark`. |

In the response, `source` says where the list comes from: `snapshot` (a list bundled for the engine), `approximation` (keywords only, for engines without a bundled list), or a list of the Spark SQL functions Qualytics allows. Each function carries a `kind` (`scalar`, `aggregate`, `window`, or `table`), a `signature`, and a `description` when known.

> **Example: Example request and response**
>
> **Request**:
>
> ```bash
> curl -X GET "https://your-instance.qualytics.io/api/datastores/12/sql-vocabulary?sql_mode=source" \
>   -H "Authorization: Bearer YOUR_TOKEN"
> ```
>
> **Response** (abbreviated):
>
> ```json
> {
>   "dialect": "postgres",
>   "source": "snapshot",
>   "version": "PostgreSQL 17.10",
>   "keywords": [ { "name": "SELECT", "reserved": true } ],
>   "functions": [
>     {
>       "name": "date_trunc",
>       "kind": "scalar",
>       "signature": "date_trunc(text, timestamp)",
>       "description": "Truncate to specified precision",
>       "group": null,
>       "since": null
>     }
>   ]
> }
> ```

---

## Error responses

| Status | Message | Cause |
| --- | --- | --- |
| `400 Bad Request` | `Spark SQL reads at most 10 containers at once` | A Spark SQL query names more than 10 containers. |
| `400 Bad Request` | `<name> is not a container of <datastore>. Spark SQL reads the datastore's containers by name` | A Spark SQL query names something that is not one of the datastore's containers. |
| `400 Bad Request` | `Computed fields [<names>] cannot be used in filter clause` | A container read's filter names a computed field. |
| `401 Unauthorized` |  | Missing or invalid API token. |
| `403 Forbidden` | `Running SQL needs Editor or Author permission on <datastore>` | You lack **Author** or **Editor** on a datastore the query reads. |
| `403 Forbidden` | `Custom columns need Editor or Author permission on <datastore>` | A container read with custom columns, without **Author** or **Editor**. |
| `403 Forbidden` | `Only a read-only query can run here: it cannot create, change or delete data.` | The SQL writes, changes, or deletes data. |
| `403 Forbidden` | `<name> is not a table Qualytics has synced in <datastore>. Query the datastore's synced tables, or sync it to add a new one.` | The query reads a table Qualytics has not synced. |
| `403 Forbidden` | `<name> is not in a datastore you can query here. ...` | The query reads a table outside the datastores of the connection you can access. |
| `403 Forbidden` | `<function>() can't be read here. Queries read the tables of datastores you have access to.` | The query calls a blocked function, or a function that does more than turn its arguments into rows where a table goes. |
| `403 Forbidden` | A masking refusal, such as `A result column computed from a masked field needs a name, so its values can be masked. Name it with AS.` | The query reads masked fields in a way that cannot be traced to its result columns. |
| `403 Forbidden` | `You may not reveal every masked field this result shows. Run it without revealing masked values` | `reveal_masked` is `true` but you cannot reveal one of the masked fields. |
| `403 Forbidden` | `You may no longer reveal the masked values of this result. Run it again without revealing them` | Your right to reveal was withdrawn after the run. The result closes. |
| `404 Not Found` | `Workspace not found` | The workspace does not exist or is not yours. |
| `404 Not Found` | `Result <id> not found` | The result does not exist or is not yours. |
| `404 Not Found` | `Datastore id: <id> not found` / `Container id: <id> not found` | The datastore or container does not exist. |
| `404 Not Found` | `Chat session not found` | A workspace update links a `chat_session_id` that is not one of your own AgentQ chats. |
| `404 Not Found` | `Result not found` | A workspace update sends a `last_run` whose `result_id` is not one of your results. |
| `409 Conflict` | `A file datastore runs Spark SQL only` | `sql_mode` is `source` on a file datastore. |
| `409 Conflict` | `<datastore> is on another connection. A query reads one connection's datastores` | The query reads datastores of two connections. |
| `409 Conflict` | `<name> is a computed join, which Spark SQL cannot read here` | A Spark SQL query names a computed join. |
| `409 Conflict` | `A result with this id already exists. Pick another id` | The `session_id` you sent is in use. |
| `409 Conflict` | `Preview keeps its name` / `Preview cannot be deleted` | A rename or delete of the default container workspace. |
| `409 Conflict` | `<datastore> holds a table Qualytics cannot tie to the source container it was written from, so it cannot tell which of its fields to mask. Link the source datastore to it again to query it with SQL` | The query reads an enrichment datastore table whose source container is unknown. |
| `410 Gone` | `The query was stopped` | The result was closed before the run answered. |
| `410 Gone` | `This result expired. Run the query again` | Nobody read the result for 30 minutes. |
| `410 Gone` | `A field this result shows was masked after it ran. Run the query again` | A field in the result was masked after the run. The result closes. |
| `410 Gone` | `Closed` | Reading a result you closed with `DELETE`. |
| `410 Gone` | `Closed to make room for a newer result` | The result was closed when you opened a fourth one. |
| `410 Gone` | `This result is closed. Run the query again` | Reading a result that closed for another reason. |
| `422 Unprocessable Entity` | `The query could not be read near line <line>, column <column>. Check its syntax, then run it again.` | The SQL has a syntax error. |
| `422 Unprocessable Entity` | `The query is nested too deeply to be checked. Write it with fewer levels.` | The SQL nests about 50 levels or more. |
| `422 Unprocessable Entity` | `Run one query at a time.` | The SQL holds more than one statement. |
| `422 Unprocessable Entity` | `<name> is already a column of this result. Give the custom column another name` | A custom column has the name of one of the container's fields or of another custom column. |
| `422 Unprocessable Entity` | `A custom column reads its own row only, so it cannot hold a query` | A custom column's expression holds a subquery. |
| `422 Unprocessable Entity` | `The record column holds masked source rows and cannot be used to filter or sort.` | A read of an enrichment table filters or sorts by its `RECORD` column. |
| `422 Unprocessable Entity` | The database's message | The database refused the query. When the query reads a table with masked fields, the message is hidden, because it could quote masked values. |
| `422 Unprocessable Entity` | `start_date must be on or before end_date` | The run history dates are reversed. |

Refusals of what a query reads answer `403`. SQL that cannot be read at all (a syntax error, too many levels, several statements, or `TABLE name` inside a `WITH` clause) answers `422`, as a mistake to fix in the request.

When the database refuses SQL you wrote (a query, a filter, or a custom column) because a table or column it names does not exist, the error's `fault_context` reads `The SQL or filter expression is invalid` with the hint `Review and correct it, then try again.`, since the name is most likely mistyped. A plain container read, which names only synced fields, still asks you to sync the datastore again when its table or a column is missing.

The check messages are the same in the UI. See [SQL Modes](https://userguide.qualytics.io/explore/deep-dive/sql-modes/) for the full list of rules.

---

## Related

- [Getting Started with Explore](https://userguide.qualytics.io/explore/deep-dive/getting-started/)
- [How Explore Works](https://userguide.qualytics.io/explore/deep-dive/how-it-works/)
- [SQL Modes](https://userguide.qualytics.io/explore/deep-dive/sql-modes/)
- [Results](https://userguide.qualytics.io/explore/deep-dive/results/)
- [History](https://userguide.qualytics.io/explore/deep-dive/history/)
- [Explore Permissions](https://userguide.qualytics.io/explore/deep-dive/permissions/)
- [Explore FAQ](https://userguide.qualytics.io/explore/faq/)

*Last updated: November 24, 2026.*
