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

# Query

> Ask a one-shot question against your collections — the fastest way to integrate.

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.doctly.ai/api/v1/query \
    -H "Authorization: Bearer YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "collection_ids": ["8f14e45f-ceea-467f-a34e-cbb17b0dbe1b"],
      "query": "What is the warranty period?"
    }'
  ```
</RequestExample>

**POST** `/api/v1/query`

Answers a single question against one or more collections. No conversation state is created — for multi-turn conversations, use [Chat Sessions](/api-reference/chat/create-session).

## Request

<ParamField body="collection_ids" type="string[]" required>
  Collections to retrieve from. Your account must have access to every listed collection.
</ParamField>

<ParamField body="query" type="string" required>
  The question to answer. Maximum 32,000 characters.
</ParamField>

<ParamField body="file_ids" type="string[]">
  Restrict retrieval to these file IDs.
</ParamField>

<ParamField body="stream" type="boolean" default="false">
  Stream the response as [Server-Sent Events](/api-reference/chat/streaming).
</ParamField>

## Response

<ResponseField name="answer" type="string">
  The generated answer, in Markdown. May contain inline citation markers of the form `[citation:{id}]` referencing entries in `citations`.
</ResponseField>

<ResponseField name="citations" type="array">
  Source [citation objects](#the-citation-object) backing the answer.
</ResponseField>

```json Response theme={null}
{
  "answer": "The warranty period is 24 months from delivery [citation:3:12].",
  "citations": [
    {
      "id": "3:12",
      "file_id": "3c9d2f6e-6a5b-4a37-9f0d-2e8a7d4c1b90",
      "collection_id": "8f14e45f-ceea-467f-a34e-cbb17b0dbe1b",
      "filename": "supply-agreement.pdf",
      "page_start": 12,
      "page_end": 12
    }
  ]
}
```

## The Citation object

<ResponseField name="id" type="string">
  Marker ID. Inline markers in the answer text (`[citation:3:12]`) reference this value.
</ResponseField>

<ResponseField name="file_id" type="string">
  UUID of the source file. Resolve details with [Get File](/api-reference/collection-files/get).
</ResponseField>

<ResponseField name="collection_id" type="string">
  UUID of the collection the file belongs to.
</ResponseField>

<ResponseField name="filename" type="string">
  Source filename.
</ResponseField>

<ResponseField name="page_start" type="integer">
  First page of the cited range (1-indexed). When the answer cites a specific page, `page_start` equals `page_end`.
</ResponseField>

<ResponseField name="page_end" type="integer">
  Last page of the cited range.
</ResponseField>
