Skip to main content

POST /v1/ask

POST /v1/ask asks a natural-language question over every document in your workspace and returns a cited, checked answer. 100 credits per question, flat.

POST /v1/ask answers a natural-language question from your own documents. You get back a markdown answer in which every load-bearing claim cites the document and passage it came from, plus a verdict on whether the answer holds up against those sources. It is for developers and agents who want answers over a document corpus without building and running their own search stack.

Only one field is required: question, up to 20,000 characters. The optional fields narrow, shape, or thread the turn: scope restricts it to a slice of the workspace as a hard filter, conversation_id continues a thread, model and model_class pick a processing option allowed by your AI policy, output_format shapes the answer, and on_behalf_of applies a named user's visibility. All of them are covered in Scope, Models & Access. The endpoint answers 202 Accepted immediately with an ask_id, a poll_url, a stream_url, and the conversation_id the turn threads into. Collect the answer with GET /v1/ask/:id or stream it with GET /v1/ask/:id/stream. A turn typically takes 10 to 60 seconds, which is why the endpoint is asynchronous. Authenticate with a workspace-scoped tlnc_ Bearer key that has the read scope; asks are isolated per workspace.

What an answer gives you

Every document you ingest with ingestion_target: "ingest" (the default on POST /v1/run) is askable, and a question runs over the whole workspace, not a sample of it. Questions about a single value ("what is the notice period in the Globex agreement?"), comparisons across documents ("which suppliers raised prices this year?") and counts or totals ("how many of our contracts auto-renew?") all work, because Talonic answers from the values it already read out of each document as well as from the document text.

Answers are grounded and checkable. Each claim links to its source document and passage, a negative answer ("no agreement contains an exclusivity clause") states how many documents it covered, and the completed response includes a verification verdict saying whether the claims match the cited evidence. See Citations & Verification for how to use both.

An ask never modifies your workspace. The turn runs with read-only permissions: documents, Specs, Runs and settings cannot be changed by a question, and any action that would change something is refused before it runs.
POST/v1/ask

Request body (JSON)

question*stringThe natural-language question, up to 20,000 characters. Markdown is fine.
scopeobjectRestrict the turn to a slice of the workspace: document_ids (max 1000), schema_id, pipeline_id, data_product_id, document_type, source_id, tags (max 100), ingested_after, ingested_before. Present fields are ANDed and enforced, not treated as a hint. An empty document_ids array matches nothing.
conversation_iduuidContinue this conversation; the answer takes the earlier turns into account. Absent, a fresh conversation is created and its id returned.
modelstringIdentifier of a specific processing option, as listed by GET /v1/ai/models. An option the workspace AI policy denies fails loudly; it is never silently substituted.
model_classstringA processing class, e.g. complex. Used when model is absent.
output_formatobjectShape the final answer: instruction (free-text format instruction, max 4,000 chars), template (a markdown skeleton the answer keeps, max 20,000 chars). Constrains form only, never grounding.
on_behalf_ofuuidAnswer as this workspace user would see it, applying that user's compartment and classification visibility. Opt-in per request; the default reads workspace-wide. See Scope, Models & Access.

curl

curl -s -X POST https://api.talonic.com/v1/ask \
  -H "Authorization: Bearer $TALONIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"question": "Which of our agreements auto-renew, and what notice period does each one require?"}'

Node (fetch)

const res = await fetch('https://api.talonic.com/v1/ask', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.TALONIC_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    question: 'Which of our agreements auto-renew, and what notice period does each one require?',
  }),
});
const { ask_id, poll_url, stream_url, conversation_id } = await res.json();

Response (202)

{
  "ask_id": "7c2f0a4e-9d31-4b8a-b3e6-2f1c5d9a8e07",
  "status": "processing",
  "poll_url": "/v1/ask/7c2f0a4e-9d31-4b8a-b3e6-2f1c5d9a8e07",
  "stream_url": "/v1/ask/7c2f0a4e-9d31-4b8a-b3e6-2f1c5d9a8e07/stream",
  "conversation_id": "8c4f2a1e-0b6d-4e2f-9a3c-5d7e1f2a3b4c"
}

Conversations

Every ask belongs to a conversation. Pass conversation_id to continue a thread, and follow-ups like "and only the ones above 50,000 EUR?" are answered in the context of the earlier turns. Omit it and Talonic creates a fresh conversation, returning its id on the 202, so the first ask of a session already gives you the handle for the next one. Conversations are listed, read, renamed and deleted through the Conversations endpoints.

Pricing

Each accepted ask charges one flat agent_ask unit: 100 credits, or 0.10 EUR (1,000 credits = 1 EUR). The charge is taken when the ask is accepted and is keyed to the turn, so a network retry of the same submission, or polling and streaming the result any number of times, never bills twice. A question over 10 documents and a question over 10,000 cost the same. The completed response reports the charge in usage.credits_charged, and the full catalog is public at GET /v1/pricing.

When your balance cannot cover one unit, the ask is rejected up front with 402 insufficient_credits before any work starts. The 402 body names the unit, the shortfall and a buy_credits_url, so an automated integration can top up and resubmit without a person reading the error.

Rate limits

Ask submissions are counted in their own daily rate-limit namespace, ask, separate from extraction and platform reads. Polling GET /v1/ask/:id counts against the general read namespace, never the ask budget. Stream connects are counted in the separate ask_stream namespace, sized above ask to leave room for reconnects, and direct tool invocations in agent_tools; see Streaming and Invoke a Tool.

Daily ask caps by plan

freetier200 asks per day.
individualtier100 asks per day.
protier5,000 asks per day.
enterprisetierUnlimited.

Getting a key and documents to ask

If your workspace already has documents, any read-scoped key works immediately. A new self-serve workspace starts with two example documents, a Northwind invoice and an Acme/Globex master services agreement, so your first POST /v1/ask has something real to answer against; see the Quickstart. To make your own documents askable, ingest them via POST /v1/run with the default ingestion_target: "ingest".

Errors

Error responses

400validation_errorMissing or over-length question, a scope field over its cap, or the API key is not workspace-scoped.
401unauthorizedMissing or invalid API key.
402insufficient_creditsBalance cannot cover one agent_ask unit. Body includes the shortfall and a buy_credits_url.
403insufficient_scopeThe key lacks the read scope.
429rate_limit_exceededDaily ask cap for your plan exhausted. Retry after the period in the Retry-After header.

Frequently asked questions

What kinds of questions can I ask?+
Questions about a single value, comparisons across documents, and counts or totals over the whole workspace. Every claim in the answer cites its source document, and negative answers state how many documents they covered.
What does an ask cost?+
One flat agent_ask unit per accepted question: 100 credits, or 0.10 EUR. The charge is keyed to the turn, so retries, polling and streaming never double-bill, and the price does not depend on how many documents the question covers.
Why is there no synchronous mode?+
A turn takes 10 to 60 seconds, which exceeds common proxy and gateway timeouts. Submit, get a 202 with an ask_id, then poll GET /v1/ask/:id roughly every 2 seconds or hold GET /v1/ask/:id/stream open for server-sent events.
Can I restrict a question to specific documents or a Run?+
Yes. Pass a scope object: document_ids, schema_id, pipeline_id, data_product_id, document_type, source_id, tags and ingestion-date bounds. The scope is enforced on everything the turn reads, and an empty document_ids array matches nothing rather than meaning unscoped.
How do multi-turn conversations work?+
Every ask threads into a conversation. Pass conversation_id to continue one; omit it and a fresh conversation is created, with its id returned on the 202. Conversations are managed via the /v1/agent/conversations endpoints.
Can an ask change anything in my workspace?+
No. The turn runs with read-only permissions, and any action that would change something is refused before it runs. Documents, Specs, Runs and settings are never modified by a question.
Which documents can an ask see?+
Every document in the workspace the API key belongs to, and only those; an ask_id from another workspace reads as 404. Documents become askable when ingested with ingestion_target "ingest" (the default on POST /v1/run); markdown-only ingestion ("extract") keeps them out.