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

# Index Documents

> Index a task's files into a searchable document collection that any agent in the workspace can search and cite.

Indexes the current task's files into a **document collection**: a named set of documents that any agent in the workspace can then search (`retrieve_documents` with `scope: "collection"`), read page by page (`read_document`) and list (`list_documents`). Display name **"Index Documents"**.

Every page is kept as written. Nothing is summarised or truncated, so later questions can be answered from any page, with a citation to that page.

## Authentication and enablement

* No integration needed.
* Off by default. Add it to an agent's tools.
* The workspace must have document collections switched on (runtime flag `document_collections.enabled`). Until then the tool returns "Document collections are not enabled for this workspace."

## Inputs

* `collection` (required): the key to group the documents under, such as a case, account or project reference. It can be 1–200 characters and is matched case-insensitively. Reusing a key adds to the same collection, including when a different agent ingests.
* `files` (optional): file ids or exact file names of this task's files. Leave it out to index all of the task's files.
* `metadata` (optional): string key/value tags, for example `{"region": "west"}`. `retrieve_documents` and `list_documents` can filter on them.
* `replace` (optional, default `false`): when `true`, removes documents that this agent added to the collection earlier but that are not in this run. Documents added by other agents are never removed.
* `doc_types` (configuration only): the document types to classify into, each a `label` with an optional `description`. Set it in the tool's configuration; the model cannot set it. Without it, a general list is used: letter, email, form, report, invoice, contract, medical record, court filing, statement, spreadsheet, other.

## Output

Returns straight away with `job_id`, `collection` and `files_queued`. Indexing then runs in the background. Call `list_documents` with the same `collection` to see progress, plus every file that was skipped or failed and why.

## What gets indexed

* **Zip archives** are unpacked, including nested archives up to 3 levels deep.
* **Emails (`.eml` and Outlook `.msg`)** are split into the email itself (headers and body) plus each attachment as its own document, linked to the email. Zip attachments are unpacked, forwarded emails are indexed as emails, and emails in the same conversation share a `thread_id`.
* **PDFs, scans and images** are OCR'd page by page.
* **Word and PowerPoint** files are converted to PDF first, so citations point at a real page.
* **Excel and CSV** files are read one sheet per page, with rows kept as table rows.
* **Text, Markdown and HTML** are read as text.
* Each document is given a type, a date, a title and a one-sentence summary. It is then chunked along its pages and sentences, never splitting a table. Each chunk carries a short header (document, type, date, page, summary), so a passage that never names its subject still matches questions about it.
* Identical files are indexed once per workspace, however many collections they join.

## Limits and side effects

* Per uploaded file: at most 200 MiB uncompressed in all, counting every archive and email attachment inside it, 3 levels of nesting and 5,000 files. Anything over a limit is skipped with a reason.
* Encrypted entries, media files and system files are skipped with a reason. A file whose text cannot be stored is recorded as failed, and the other files still index.
* A read that fails for a temporary reason (an OCR or conversion service error, a storage timeout) is retried a few times before the file is recorded as failed. If the worker stops mid-job, for example during a deploy, the job resumes where it stopped and no file is marked failed. Indexing the same files again retries the ones that failed.
* A file that is skipped or fails leaves no stored copy behind.
* Re-indexing the same files adds nothing twice. It updates their metadata and source task.
* Files unpacked from archives or emails, and PDFs converted from Office files, are stored as workspace files. They are not added to the task's file list.
* Content is sent to the services already used for document processing: Google Vision for OCR, ConvertAPI for Office conversion, and the platform's embedding and language models.

## Expected errors

* Document collections not enabled for the workspace.
* `collection` empty or longer than 200 characters.
* A requested file is not in this task.
* The task has no files.


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