Reference
For the complete documentation index optimized for AI agents, see llms.txt.Send a dynamic query to
POST /v2/query on a local or Helix Cloud instance. You can supply the query as a raw JSON request (--file/--json) or write it in the TypeScript DSL (-e/--ts/--ts-file) and let the CLI build the request for you.
Usage
--file or --json) or a TypeScript DSL expression (-e/--ts or --ts-file). The four input flags are mutually exclusive.
Arguments
Available flags
Exactly one input flag is required (--file, --json, -e/--ts, or --ts-file).
Request body
The JSON request must include:request_type— lowercase"read"or"write". Anything else is rejected withrequest_type must be lowercase 'read' or 'write'.query_name— optional top-level query name for gateway logs and query diagnostics. Use exactlyquery_name;nameandqueryNameare not accepted aliases. Missing ornullfalls back to__dynamic__.query— exactly one typedreadorwritebatch containingentriesandreturns. Missingqueryis rejected withdynamic query request must include query.parametersandparameter_types— optional typed runtime values and their schemas.
helix init local scaffolds examples/request.json with a runnable read request:
count.
Use --file for checked-in or reusable requests, and --json for quick one-off requests from a shell. Quote inline JSON so your shell passes it as one argument.
Query warming
--warm sends the same read body with X-Helix-Warm: true. Helix Cloud fans the
request out to every eligible database backend and discards their response bodies.
The command succeeds silently on 204 No Content after at least one backend
succeeds; partial backend failure does not fail the warm-up. If every target fails,
the gateway returns the normal deterministic error. A standalone local instance
warms its single process; the v0.0.4 runtime returns 200 OK with the normal
query body. A managed cluster with no eligible warming target returns
503 Service Unavailable.
Warm writes are rejected with 400 Bad Request before backend execution. At the
HTTP/SDK layer, combine X-Helix-Warm: true with
X-Helix-Require-Writer: true when only the authoritative writer should be warmed.
Authentication, read rate limits, retries, and normal query timeouts still apply.
TypeScript DSL input
Instead of hand-writing JSON, you can pass a TypeScript DSL expression and let the CLI build the request — the same waymysql -e runs SQL from the shell:
- The expression must evaluate to a
readBatch()orwriteBatch()builder.g,readBatch,writeBatch,defineParams, andparamare auto-imported and already in scope — you write only the expression, no imports. - The CLI evaluates it locally with Node using the forthcoming v3
@helix-db/helix-dbSDK, calls.toQueryJson(), and posts the resulting operation-tree request to/v2/query. The builders are pure (no I/O), so no instance needs to be running to build the request — only to run it. There is no separate compile step. request_typeis inferred automatically from whether you usedreadBatch()orwriteBatch().
- Node.js 20+ on
PATH(npm ships with it). On first use the CLI installs the SDK once into its cache directory; later runs reuse it. - For inline
-euse, write a single expression with no TypeScript type annotations (it is evaluated as an expression, not compiled). Put more elaborate queries in a--ts-file.
--json/--file. For the full DSL surface, see the helix-query-typescript skill.
Validation rules
Helix Cloud targets
For a Helix Cloud instance,helix query reads [enterprise.<instance>] in helix.toml and:
- Posts to
<gateway_url>/v2/query. - Sends an auth header named by
query_auth_header(defaultAuthorization) with the value read from the environment variablequery_auth_env(defaultHELIX_API_KEY). The value is read from your shell environment or from a.envfile in the project root (whichever is set), so you can keep the key out of your shell history.
gateway_url is missing, the CLI returns:
Environment variable <NAME> is required for Enterprise query auth.
Connection errors
If the CLI cannot reach the instance, it reportscannot reach Helix instance '<instance>' at <endpoint> with a recovery hint tailored to the instance kind:
- Local —
Start it with helix start <instance> and check it with helix status <instance>. If it runs on another host/port, pass --host/--port. - Enterprise —
Check the gateway_url for '<instance>' in helix.toml and your network connection. helix sync <instance> refreshes the gateway metadata from Helix Cloud.
Output
- A non-empty JSON response is pretty-printed by default; pass
--compactto print on a single line. 204 No Content(returned by Helix Cloud after at least one warm target succeeds) produces no output and exits successfully.- A standalone local warm read can return
200 OK; its normal JSON body is printed. - Non-2xx responses produce
Query failed with HTTP <status>: <body>and exit with a non-zero status.
Examples
Related
helix start— start a local instance to query againsthelix sync— refresh Helix Cloud gateway/auth metadata