# document.save

Canonical URL: https://developers.iagenify.com/sdk/workflows/steps/document-save/
Language: en

`type: "document.save"`

Writes a document into a storage and indexes it, so a later semantic search can find it by meaning.

Status: storage and path required · indexes it · chunks reported

| Name | Type | Requirement | Description |
| --- | --- | --- | --- |
| `storage` | string | required | Where it goes. |
| `path` | string | required | The document's name. |
| `content` | any |  | Text content. |
| `contentBase64` | string |  | Bytes — a PDF, a DOCX. |

```javascript
{ id: "index", type: "document.save", config: {
    storage: "…", path: "digests/{{input.week}}.md",
    content: "{{steps.write.output.text}}" } }
```

## What indexing adds {#difference}

> **It closes a loop a chain could not close on its own**
>
> Semantic search only finds what was indexed. Without this step a workflow could produce a hundred reports and never be able to find one of them by what it says.

## Output {#output}

```javascript
{{steps.index.output.document}}   // its identifier
{{steps.index.output.chunks}}     // how many pieces were indexed
{{steps.index.output.bytes}}
```

## Finding it again {#finding}

```javascript
{ id: "recall", type: "storage.query", config: {
    storage: "…", action: "search", query: "{{input.question}}" } }
```

## What it costs {#cost}

The bytes count against the storage, as any file does. The search that later finds it costs a credit per call.

- [file.save](/sdk/workflows/steps/file-save): Writing without indexing.
- [storage.query](/sdk/workflows/steps/storage-query): Searching.
- [Workflow steps](/sdk/workflows/steps): The 23 types.

```python
{"id": "index", "type": "document.save", "config": {
    "storage": "…", "path": "digests/{{input.week}}.md",
    "content": "{{steps.write.output.text}}"}}
```

```python
"{{steps.index.output.document}}"   # its identifier
"{{steps.index.output.chunks}}"     # how many pieces were indexed
"{{steps.index.output.bytes}}"
```

```python
{"id": "recall", "type": "storage.query", "config": {
    "storage": "…", "action": "search", "query": "{{input.question}}"}}
```
