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

# Ask your filing cabinet

> Index every document a workflow parses, then ask questions across all of them and get answers cited back to the page

<Note>
  The [Knowledge](/guides/nodes/knowledge) node is in **alpha** and appears in the palette once the feature is switched on for your organization. Ask us to enable it.
</Note>

Extraction answers "what is on this document". This answers "what do these documents say about X", across every document the workflow has ever parsed. Add a [Knowledge](/guides/nodes/knowledge) node and the corpus builds itself; then ask it questions over the API. Every answer comes back with the quotes it rests on, each resolved to a page and a region of the original PDF.

<div className="af-payoff">
  <div className="af-payoff-pane">
    <div className="af-payoff-cap">You ask</div>

    <div className="af-payoff-line">
      {'Which invoices are in this file,'}
    </div>

    <div className="af-payoff-line">
      {'who issued each one, and what is'}
    </div>

    <div className="af-payoff-line">
      {'the total of each?'}
    </div>
  </div>

  <div className="af-payoff-arrow">→</div>

  <div className="af-payoff-pane">
    <div className="af-payoff-cap">It answers</div>

    <div className="af-payoff-line">
      <b>
        {'INV-2026-1000'}
      </b>

      {'  Acme Industries  $1,810.50'}
    </div>

    <div className="af-payoff-line">
      <b>
        {'INV-2026-1001'}
      </b>

      {'  Globex Corp.     $932.45'}
    </div>

    <div className="af-payoff-line">
      <b>
        {'INV-2026-1002'}
      </b>

      {'  Initech LLC      $5,648.15'}
    </div>

    <div className="af-payoff-line">
      {'plus a shipping label and a boarding pass'}
    </div>

    <div className="af-payoff-line">
      <span className="af-cite">
        {'↳ 9 citations, each with a page and a box'}
      </span>
    </div>
  </div>
</div>

<div className="af-cost">
  <span><b>Nodes</b><strong>{'Parse → Knowledge'}</strong></span>
  <span><b>Credits</b><strong>27 per page</strong>{' (Parse 25 + index 2), then per question'}</span>
  <span><b>You get</b>{' an answer you can show a customer'}</span>
</div>

## The workflow

The node has no options. Its presence is the switch: every document this workflow parses is folded into one corpus.

<CodeGroup>
  ```json API theme={null}
  {
    "name": "Ask the supplier file",
    "description": "Index every document the workflow parses, then ask it questions",
    "nodes": [
      { "id": "parse_1", "type": "parse" },
      { "id": "knowledge_1", "type": "knowledge" }
    ],
    "edges": [{ "source": "parse_1", "target": "knowledge_1" }]
  }
  ```

  ```python Python theme={null}
  import os

  from anyformat.sdk import Client

  client = Client(api_key=os.environ["ANYFORMAT_API_KEY"])

  workflow = (
      client.workflow("Ask the supplier file", "Index every document the workflow parses")
      .parse()
      .knowledge()
      .create()
  )
  ```
</CodeGroup>

The corpus is **workflow-scoped, not version-scoped**. It accumulates the latest parse of every live file across every run and every version, so a document parsed months ago under an older version is still answerable.

## Ask it

Upload and run documents as you would with any workflow. Then ask.

<CodeGroup>
  ```bash curl theme={null}
  curl -X POST "https://api.anyformat.ai/v3/workflows/$WORKFLOW_ID/knowledge/ask" \
    -H "Authorization: Bearer $ANYFORMAT_API_KEY" \
    -H 'Content-Type: application/json' \
    -d '{"question": "Which invoices are in this file, who issued each one, and what is the total of each?"}'
  ```

  ```python Python theme={null}
  answer = workflow.ask("Which invoices are in this file, who issued each one, and what is the total of each?")

  print(answer.answer)
  for citation in answer.citations:
      print(citation.quote, "page", citation.page)
  ```
</CodeGroup>

## Response

The `answer` is markdown, written to be shown to a person. The `citations` are the point: each one carries the exact `quote`, the `page`, and a `bbox` in normalized page coordinates, so you can draw the box on the PDF instead of asking anyone to trust the answer. `path` shows which tools the agent used to get there, and `steps_used` how many it took.

```json theme={null}
{
  "answer": "The document `2026-08/mixed_partition.md` contains three invoices:\n\n*   **INV-2026-1000**, issued by **Acme Industries**, with a total of **$1,810.50**.\n*   **INV-2026-1001**, issued by **Globex Corporation**, with a total of **$932.45**.\n*   **INV-2026-1002**, issued by **Initech LLC**, with a total of **$5,648.15**.\n\nThe file also includes a shipping label and a boarding pass.",
  "citations": [
    {
      "path": "2026-08/mixed_partition.md",
      "quote": "Invoice #: INV-2026-1000",
      "file_id": "06a95794-11f6-77e1-8000-f49fa028d98e",
      "block_id": "p1_b1",
      "page": 1,
      "bbox": { "x0": 0.113, "x1": 0.325, "y0": 0.132, "y1": 0.21 }
    },
    {
      "path": "2026-08/mixed_partition.md",
      "quote": "**TOTAL: $1,810.50**",
      "file_id": "06a95794-11f6-77e1-8000-f49fa028d98e",
      "block_id": "p1_b9",
      "page": 1,
      "bbox": { "x0": 0.584, "x1": 0.756, "y0": 0.431, "y1": 0.483 }
    }
  ],
  "path": [
    { "tool": "kb_ls",   "args": { "folder": "." } },
    { "tool": "kb_read", "args": { "path": ["INDEX.md", "2026-08/mixed_partition.md"] } }
  ],
  "steps_used": 2,
  "thread_id": null
}
```

## Follow-up questions

Mint a `thread_id` yourself, starting with `kb-`, and pass it to ask in the context of what came before. Reuse the same id to continue the conversation; omit it and every question stands alone.

```json theme={null}
{ "question": "Which of those is the largest?", "thread_id": "kb-invoices-review-1" }
```

## When it goes wrong

**`409 KNOWLEDGE_NOT_ENABLED`.** The workflow has no Knowledge node. This is permanent until you add one: do not retry.

**`409 KNOWLEDGE_NOT_READY`.** The first index is still building after your first run. Retry in a few seconds. Expect this on the very first question against a new workflow.

**The answer is right but you cannot prove it.** Read the citations, not the prose. Each `bbox` is normalized to the page, so multiply by the rendered page size to draw it. An answer whose citations do not support it is the one to escalate.

**It answers about the wrong document.** The corpus holds every file the workflow ever ran, which is the feature and occasionally the surprise. Give the question the scope you mean: name the supplier, the month or the file.

**The bill is bigger than you expected.** Questions are metered on the text the agent actually reads, so a broad sweep over a large corpus costs more than a narrow question. Ask narrowly.

## Next steps

<CardGroup cols={2}>
  <Card title="Knowledge" icon="book" href="/guides/nodes/knowledge">
    The node, the corpus, and what it costs
  </Card>

  <Card title="Ask" icon="comment" href="/api-reference-v3/knowledge/ask">
    The endpoint, its errors and its rate limit
  </Card>
</CardGroup>
