POST /query - queries Knowledge (documents and app sources), Memories (user preferences, conversation history, inferred content), or both. Three signals drive relevance: dense-vector similarity, BM25 keyword matching, and context-graph traversal. The parameters below control all of it.
For the full request and response schema, see Query - API Reference.
1. Use-case recipes
Pick the row that matches your goal and use the parameters as a starting point:2. Parameter reference
Follow this for when to usedatabase and collection
The database field was formerly tenant_id and collection was formerly sub_tenant_id; the old names remain accepted as deprecated aliases.
Scope
Graph
Shaping results
3. Tuning heuristics
Most of the time the defaults are right. When they aren’t, here’s where to start:mode- If omitted, defaults to"auto": it scores the query before retrieval and routes to"fast"or"thinking"(defaulting to"thinking"when the signal is inconclusive), and overridesgraph_contextto match whichever it picks. Pick"fast"or"thinking"explicitly instead when you know your traffic shape and want a deterministic pipeline.alpha- Start at0.8. Lower toward0.3–0.5when the query contains literal tokens (error codes, SKUs, product names). Raise toward0.9for conceptual questions. Use"auto"when query shape varies across calls.max_results- Start at10. Drop to5for tight context windows; raise to20if you rerank downstream.additional_context- Use it when the query alone is ambiguous. Keep it short and factual.graph_context- Set totruewhen answers benefit from entity relationships (multi-hop questions, “how does X relate to Y”). Pair withmode: "thinking"- in"fast"mode the graph slice is shallow.query_apps- Set totruewhen querying ingested app data (Slack, Gmail, Confluence, Jira, Salesforce) to activate exact ID and actor lookups, same-thread expansion, and parent/child hierarchy traversal. This adds better app-aware retrieval on top of the normal knowledge query; it does not filter out non-app knowledge. Pair withmode: "thinking".
4. Minimal working example
The canonical personalized-answer flow takes a single call:POST /query with type: "all" returns merged knowledge and per-user memory in one ranked result set.
Setup
One call - Knowledge and Memories together
Merge into the LLM prompt
The response is a singleRetrievalResult containing chunks[], sources[], and - when applicable - graph_context and additional_context. Chunks from Knowledge and Memories are already interleaved and ranked by relevance, so no manual merging is required. Pass the result through the helper in How to Use API Results to turn it into a context string for your prompt:
collections. A list gives every scope equal normalized weight; an object applies relative ranking weights with at most one decimal place before the final merged ranking. When max_results is set, it caps the final merged response across all selected collections:
/query twice in parallel with type: "knowledge" and type: "memory", then merge client-side.
Production checklist
- Default to
type: "all"for personalized answers - one call instead of two, scoped withcollections. - Set per-call timeouts. Generous for
thinking(3–5 s), tight forfast(≤500 ms). Formode: "auto", size the timeout for thethinkingcase - it can resolve to either pipeline and defaults towardthinkingwhen the routing signal is inconclusive. - Enable
query_apps: truewhen querying app sources to activate app-aware retrieval and thread/relation traversal. - Pass
additional_contextwith known session state (page, feature, role). It sharpens retrieval without extra calls.
5. Common mistakes
6. Advanced patterns
Hybrid + text in two parallel calls. When a query mixes a literal token (error code, SKU, function name) with natural-language intent, runquery_by: "hybrid" and query_by: "text" in parallel, dedupe by chunk ID, and treat text hits as a “must include” floor.
Recall-then-rerank. Ask for more chunks than you actually need (max_results: 20) and apply your own reranker - recency windows, compliance filters, business rules - before picking the final top-k for the prompt.
Cache the prompt context. If the same query repeats inside a session, cache the RetrievalResult keyed by (database, collection, query, type, query_by). Recall is fast, but skipping it entirely is faster.
Related
- Knowledge - shared document context
- Memories - user-scoped dynamic context
- Metadata - designing filterable fields
- Context Graphs - how graph traversal enriches recall
- How to Use API Results - turning
RetrievalResultinto an LLM prompt - Query - API Reference - full parameter and response schema