Skip to main content
The Query API provides REST endpoints for querying every structured destination — PostgreSQL, MongoDB, object store, Snowflake, and Databricks — plus natural language queries and AI-powered answers. These endpoints mirror the MCP tools, making the same retrieval capabilities available via HTTP.

Query PostgreSQL

Execute a read-only SQL SELECT query against PostgreSQL.

Request

Example

Response

Safety

The endpoint enforces multiple layers of protection:
  • SELECT-only — only queries starting with SELECT are allowed
  • Read-only connection — the JDBC connection is set to read-only mode
  • Statement blocklist — queries containing INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, GRANT, REVOKE, COPY, CALL, EXECUTE, or EXEC are rejected
  • No stacked queries — semicolons are not allowed
  • No SQL comments-- and /* */ are rejected to prevent obfuscation
  • LIMIT enforcement — if no LIMIT is present in the SQL, one is appended automatically using the request’s limit value (or the default 100). Pass limit: -1 to bypass the automatic append entirely — the caller’s SQL runs as-is.

Query MongoDB

Query a MongoDB collection with optional filter and projection.

Request

Example

Response

Safety

  • Blocked operators — filters containing $where, $function, or $accumulator are rejected, as these allow arbitrary JavaScript execution
  • Standard MongoDB query operators ($eq, $gt, $in, $regex, etc.) are safe and fully supported

Query Object Store

Read rows from a pipeline’s object store destination (MinIO or S3). The pipeline name selects the bucket, prefix, and credentials — the caller never supplies connection details.

Request

Example

Response

If the pipeline exists but no runs have written data yet, the endpoint returns an empty result ("count": 0) rather than an error.

Error Cases

Returns 400 Bad Request with {"error": "..."} when:
  • The pipeline is not found
  • The pipeline does not have an object store destination
  • The pipeline’s object store configuration is missing a prefix key
  • The read times out (default 90 seconds, tunable via the DATRIS_OBJECTSTORE_QUERY_TIMEOUT_SEC environment variable)

Query Snowflake

Execute a read-only query against the Snowflake account a pipeline loads into. The pipeline name selects the credentials, warehouse, database, and schema — credentials never leave the server.

Request

Example

Response

The sql field echoes the query that actually ran, including any automatically appended LIMIT.

Safety

  • Read-only allowlist — queries must start with SELECT, WITH, SHOW, DESCRIBE, or DESC. SHOW/DESCRIBE are allowed so agents can discover databases, schemas, tables, and columns.
  • Statement blocklist — queries containing INSERT, UPDATE, DELETE, DROP, ALTER, CREATE, TRUNCATE, GRANT, REVOKE, CALL, EXECUTE, EXEC, PUT, REMOVE, COPY, MERGE, or USE are rejected (USE is blocked so a query cannot re-point the session at another database or role)
  • No stacked queries — semicolons are not allowed
  • No SQL comments-- and /* */ are rejected to prevent obfuscation
  • LIMIT enforcement — if a SELECT/WITH query has no LIMIT, one is appended using the request’s limit value. SHOW/DESCRIBE output is row-capped at the same value.
  • Query timeout — 30 seconds, bounding both hung requests and warehouse spend. Not applied when limit: -1.

Error Cases

Returns 400 Bad Request with {"error": "..."} when:
  • The pipeline is not found
  • The pipeline does not have a Snowflake destination
  • The SQL fails validation (allowlist, blocklist, semicolons, comments)

Query Databricks

Execute a read-only query against the Databricks workspace a pipeline loads into. The pipeline name selects the credentials, SQL warehouse, catalog, and schema — credentials never leave the server.

Request

Example

Response

The sql field echoes the query that actually ran, including any automatically appended LIMIT.

Safety

Same protections as Query Snowflake, with the blocklist extended for Databricks-specific data-movement and maintenance verbs: OPTIMIZE, VACUUM, RESTORE, CLONE, REFRESH, MSCK, and DECLARE are also rejected.
If the SQL warehouse is stopped, opening the connection blocks while it auto-starts — this happens before the 30-second query timeout applies, so the first query after idle time can take longer.

Error Cases

Returns 400 Bad Request with {"error": "..."} when:
  • The pipeline is not found
  • The pipeline does not have a Databricks destination
  • The SQL fails validation (allowlist, blocklist, semicolons, comments)

Kill Job

Kill a running pipeline job by its pipeline token. The job thread is interrupted and the job is marked as cancelled.

Request

Example

Response

Error Cases

  • Job not found for the given pipeline token
  • Job is not in PROCESSING state (already completed or cancelled)
  • Job thread is no longer alive