> ## Documentation Index
> Fetch the complete documentation index at: https://usenaive.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Query

> POST /v1/brain/query — ask the knowledge base and get a grounded answer with citations.

Ask the company knowledge base a question and receive a grounded answer with citations mapped to your ingested documents. **Cost: 10 credits.** Rate-limited to 120 requests/minute per company.

<ParamField body="question" type="string" required>
  The natural-language question (1–4000 chars).
</ParamField>

<ParamField body="knowledge_base_id" type="string">
  Specific KB to query (defaults to the company's default brain).
</ParamField>

<ParamField body="session_id" type="string">
  Continue a previous conversation thread (echoed back in each response).
</ParamField>

<ParamField body="filters" type="object">
  Optional retrieval filters: `{ "source": "...", "since": "ISO-8601" }` (honored by the Postgres spine).
</ParamField>

<RequestExample>
  ```bash theme={"theme":"css-variables"}
  curl -X POST https://api.usenaive.ai/v1/brain/query \
    -H "Authorization: Bearer nv_sk_live_..." \
    -H "Content-Type: application/json" \
    -d '{ "question": "What is our refund policy?" }'
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={"theme":"css-variables"}
  {
    "answer": "Our refund policy allows returns within 30 days of purchase...",
    "citations": [
      { "document_id": "doc-uuid", "title": "refunds.md", "snippet": "Refunds are accepted within 30 days..." }
    ],
    "knowledge_base_id": "kb-uuid",
    "answer_mode": "synthesized",
    "session_id": "sess-uuid"
  }
  ```
</ResponseExample>

Citations are scoped to the calling company + KB; any citation that can't be mapped to one of your documents is dropped so answers never leak another tenant's sources. `answer_mode` is `synthesized` when an LLM answerer is configured, otherwise grounded chunks are returned.

**Cost:** 10 credits
