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

# Add a document

> Upload a single new document to a live agent without interrupting conversations

## Example use case

Your product team publishes a new integration guide for the inbound support line, or a prospect emails a technical specification to your sales agent. The agent should learn the new file while live conversations keep running.

## Setup

Upload the file via multipart [POST`/v2/agents/{agent_id}/threads/{thread_id}/observe`](https://www.sapientpriors.com/docs/api-reference/v2/threads/learn-messages-or-files) on an existing thread or a dedicated ingestion thread:

* Store the returned `observation_id` and `file_id` for tracking and future replacement.
* Poll [GET`.../observe/{observation_id}`](https://www.sapientpriors.com/docs/api-reference/v2/threads/get-learning-status) until `status` reaches `committed`.
* If the agent is already reading another file, Priors queues the new upload automatically (polled `status` reads `queued`) and starts it next.
* Answering calls (`respond`, `observe-and-respond`, `recall`, `observe-and-recall`) continue running normally while the upload is processed.

## Benefit with Priors

* **Zero downtime:** new documents merge into the agent's live index without re-indexing existing files.
* **Immediate citations:** once `committed`, every thread on the agent can retrieve facts from the file and cite it with a download link.
* **Safe deduplication:** re-uploading identical bytes in the same thread returns `duplicate` as `true` and bills nothing.

## What goes wrong

> [!WARNING]
>
> Assuming a file is searchable as soon as `observe` returns `202` produces answers that miss the new document because learning runs asynchronously. Uploading identical bytes into a different thread of the same agent returns `409 document_already_ingested` unless `allow_duplicate` is set, which creates duplicate memories that compete during retrieval.

## Recommendation

Upload documents to one dedicated ingestion thread per agent, record each `file_id` in your own database for updates or removal, and poll until `committed` before surfacing the document as live.

## Calls used

* Guides: [Learning](https://www.sapientpriors.com/docs/concepts/learning.md), [Files](https://www.sapientpriors.com/docs/concepts/files.md), [Walkthrough 3: teach from a document](https://www.sapientpriors.com/docs/walkthroughs/teach-from-a-document.md)
* API reference: [Learn messages or a file](https://www.sapientpriors.com/docs/api-reference/v2/threads/learn-messages-or-files.md), [Get learning status](https://www.sapientpriors.com/docs/api-reference/v2/threads/get-learning-status.md), [Get file](https://www.sapientpriors.com/docs/api-reference/v2/files/get-file.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.