Run a read-only HQL query
POST /Platform/query/hql
Run a read-only HQL query. Returns JSON-safe rows.
HQL is the Hilus Query Language; its grammar and examples come from the
query syntax operation. This operation only reads: a DELETE
statement goes to the query service's delete operation, and targeted
writes or tool runs to the entities delete / jobs execute-tool
operations.
The default return_mode="llm_safe" makes every value a JSON-native
scalar: binary dtypes become their hash plus a metadata excerpt (via
.summary()), datetimes become ISO strings, and strings longer than
max_chars are cut with a self-announcing …[truncated, N more chars] marker. When anything was cut, the response also carries
truncated_values (a count) and a hint; rerun with a larger
max_chars, or read the one full field with a single-field read
(get with paths) on the entities service.
A query can also read a list inside a stored value (a tool result or
report that came back as a handle) as a table:
handle('<ref>', '<path>', headers='<path>') | .... Its rows can be
exploded (explode a, b makes one row per line of multi-line cells,
lined up by position), filtered, grouped by several keys with
min/max/count/collect and as names, filtered after
grouping with having, sorted by several keys and paged with
offset. Dates (M/D/YYYY, ISO) and phone numbers compare as
dates and numbers. x not in handle('<ref>', '<path>', column='<name>') excludes the values of a second handle. Unknown
columns are refused with the list of columns. The query syntax
operation documents every clause.
Query cost lives in two places. Projection: without select a
query returns every column — large text and binary payloads included —
and can time out on wide types (Call, Conversation,
Document) even at limit 1; select the fields you need (field
names per type: the entities describe operation). Search
operator: ~* (fulltext), ~= (vector), ~~ (hybrid) use
indexes; ILIKE gives exact substring/wildcard semantics but scans
unindexed, so reserve it for when those semantics matter and other
filters are narrow.
Log reads log lines. A member of an organization sees only their
organization's own lines (errors that need them and what their agents
did outside Hilus) and only the fields the query syntax operation lists
for Log, over the last 7 days unless a timestamp filter says
otherwise (at most 90).
Body parameters
hql: str. Full HQL expression, e.g.Call | limit 10 | select id, statusorhandle('tree-abc', '/rows') | status = 'open' | limit 10.return_mode: optional "llm_safe" or "matches" or "entity" or "graph" or "typed"."llm_safe"(default),"matches"(raw rows, still HTTP-safe),"entity"/"graph"(hydrated entity objects), or"typed"for clients that render values: the response addscolumns(per columnname,kind,nullableand, where they apply,dtype,entity_cls,enum_values,is_datetime, from the schema), binary values become handles{dtype, hash, summary, meta}(meta: cached header metadata such as duration or page count), entity refs become{entity_type, id, name}and datetimes ISO 8601 with offset.max_charsdoes not apply.params: optional dict. Named parameter dict for parameterised queries (from_number = :phone).branch: optional str. Branch to query against (default: current thread branch).max_chars: optional int. Per-string truncation cap inllm_safemode (default 200).timeout: optional int. Statement timeout in seconds (default 5, clamped to 1..60). Raise it for genuinely heavy queries (e.g.count(*)over long windows) — a timeout on a plain lookup usually means a missingselector an unindexedILIKEinstead.
Returns
QueryRows
rows: List[Dict[str, JsonValue]]. JSON-safe projected rows.columns: optional List[QueryColumn] or null. Schema type per column; present only with return_mode="typed".truncated_values: optional int. Number of values shortened to the requested character limit.hint: optional str or null. Guidance for reading truncated values.warnings: optional List[str]. Query compiler and execution notices.row_count: optional int or null. Rows in this response.total_rows: optional int or null. Rows the query matched before offset and limit; set for handle(...) sources.
Example request
curl -X POST "https://api.hilus.ai/Platform/query/hql" \
-H "Authorization: Bearer $HILUS_API_KEY" \
-H "Content-Type: application/json" \
-d '{}'