Agent Query (Legacy)
POST /v1/agent/query is the legacy alias of POST /v1/ask: same read-only turn, same flat charge, with ?wait=<seconds> for a bounded synchronous 200 answer.
POST /v1/agent/query is the legacy alias of POST /v1/ask: it answers a natural-language question over your workspace with cited documents, for integrations built against the original surface. Both endpoints run the same read-only turn and charge the same flat agent_ask unit (100 credits per accepted question, charged once per turn). The difference is the result: the ask endpoints return the full payload with the verification verdict and usage, while the query poll returns a compact {status, answer, tier, citations} body. Scoping, conversations, processing-option selection, output formatting and streaming exist only on /v1/ask. Use /v1/ask for new integrations.
The request body carries one field, query (up to 20,000 characters). By default the submission answers 202 Accepted with a turnId; poll GET /v1/agent/query/:id roughly every 2 seconds until status leaves processing. The alias requires a workspace-scoped key with the read scope, runs read-only with the document visibility of the user who created the key, and is isolated per workspace: a turn started by another workspace reads as 404.
Bounded synchronous mode: ?wait
?wait=<seconds> opts into a bounded synchronous answer. Simple lookup and total questions are often answered within a couple of seconds; when the answer is ready inside your budget, the request returns 200 OK with the completed payload (turnId, status: "completed", answer, tier, citations[]) and you skip the poll. Anything else, including an answer that overran the budget and every question that needs a longer turn, returns the same 202 {turnId} as without wait.
wait is capped by a configured ceiling (10 seconds by default): a value that is not a number between 0 and the ceiling is rejected with 400 naming the valid range, so a typo never silently falls back to async. Overrunning the budget costs nothing: the answer is saved the moment it is ready, so your first poll returns it. Longer turns take 10 to 60 seconds and are never held open by wait; treat the 202 as the normal case and the 200 as a latency bonus for simple questions.
answer is markdown prose that states the answer, the documents it covered, and a source line per cited value. When the turn produced tables or ranked lists, they are included in answer as markdown, so a headless consumer receives the whole result.
/v1/agent/queryQuery parameters
Request body (JSON)
/v1/agent/query/:idcurl: synchronous when possible (?wait)
curl -s -X POST "https://api.talonic.com/v1/agent/query?wait=5" \
-H "Authorization: Bearer $TALONIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "What is the total gross amount across June invoices?"}'Response (200, answered within the wait budget)
{
"turnId": "7c2f1e04-51ab-4b8e-9d2f-3a6c8e0b4d21",
"status": "completed",
"answer": "The total gross amount across June invoices is EUR 48,200.00...",
"tier": "retrieval_fast_path",
"citations": [
{
"quote": "48,200.00",
"document_id": "c3d4e5f6-a7b8-9012-cdef-123456789012",
"kind": "cell",
"reference": "bruttobetrag",
"filename": "invoice-0847.pdf",
"app_url": "https://app.talonic.com/documents/c3d4e5f6-..."
}
]
}curl: asynchronous (default 202 + poll)
TURN_ID=$(curl -s -X POST https://api.talonic.com/v1/agent/query \
-H "Authorization: Bearer $TALONIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "Summarize our open invoices by vendor."}' | jq -r '.turnId')
curl -s https://api.talonic.com/v1/agent/query/$TURN_ID \
-H "Authorization: Bearer $TALONIC_API_KEY"Poll response fields
Errors
Error responses