# document

Canonical URL: https://developers.iagenify.com/sdk/agent/tools/document/
Language: en

`document({ action: "add" | "list" | "remove", path?, storage?, document? })`

Index a document so that semantic search can find it by meaning. Without it, that search only ever finds what a human uploaded.

Status: read on list, write otherwise · feeds query_storage search · workspace files

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `action` | string | required | `add` · `list` · `remove`. |
| `path` | string |  | The workspace file to index — a PDF, a DOCX, text. |
| `storage` | string |  | By label. The account's default otherwise. |
| `document` | string |  | The id, from `list`. |

## What it is for {#why}

> **It closes a loop the agent could not close on its own**
>
> query_storage { action: "search" } finds documents by meaning — but only ones that were indexed. Without this tool an agent could produce a report and never be able to find it again by what it says.

## The pair {#pair}

```javascript
document({ action: "add", path: "Reports/q3.pdf" })
query_storage({ action: "search", query: "what did we say about churn" })
```

## What it costs {#cost}

Indexing uploads the file and consumes the storage's space. The search itself is a credit per call.

## list is free {#list}

The category is computed from the action: listing is a read, adding and removing are writes.

- [query_storage](/sdk/agent/tools/query-storage): The search this feeds.
- [search](/sdk/ref/connected-storage/run/search): The action itself.
- [Agent tools](/sdk/agent/tools): The 35, by family.

```python
# The calls the model makes:
document = {"action": "add", "path": "Reports/q3.pdf"}
query_storage = {"action": "search", "query": "what did we say about churn"}
```
