# Documents

Fill a tagged .docx template and save it to Docs.

## Usage Instructions

Fill a pre-tagged Word template with a flat data map and publish the filled .docx to workspace Docs. Layout, logo, and boilerplate are preserved. Reads templates from workspace docs; future variants add URL, S3, SharePoint, and customer document services as new template sources.

## Tools

### `documents_render`

Fill a tagged .docx template with data and save the result to workspace Docs as a Word file. Layout, logo, and boilerplate are preserved because only \{placeholder} tags are substituted.

#### Input

| Parameter      | Type   | Required | Description                                                                                                                              |
| -------------- | ------ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| `templateFile` | file   | Yes      | Workspace .docx file (pre-tagged) to render.                                                                                             |
| `data`         | object | Yes      | Flat key/value map substituted into \{tag} placeholders. Missing keys render as empty (nullGetter).                                      |
| `validate`     | object | No       | Optional skeleton assertions — \{ checkName: "text that must still be present" }. Whitespace-normalized so run-split text still matches. |
| `fileName`     | string | No       | Workspace Docs file name. .docx is appended when omitted.                                                                                |
| `folderId`     | string | No       | Optional workspace Docs folder ID. Omit to create the doc at the top level.                                                              |

#### Output

| Parameter        | Type   | Description                                                                                            |
| ---------------- | ------ | ------------------------------------------------------------------------------------------------------ |
| `file`           | object | Published workspace Docs file (id, name, size, url).                                                   |
| `fileId`         | string | Workspace Docs file id.                                                                                |
| `fileName`       | string | Workspace Docs file name.                                                                              |
| `mimeType`       | string | Word processing document MIME type.                                                                    |
| `docxBase64`     | string | Compat: filled .docx as base64. Prefer file. Logs and Output show a short prefix plus ...\[truncated]. |
| `validation`     | object | Skeleton validation result — `pass` is false if any assertion failed.                                  |
| `templateSource` | string | Where the template was resolved from — "workspace" in v1.                                              |
| `templateFile`   | string | Display name of the template file.                                                                     |
| `templateFileId` | string | Source-native identity of the template.                                                                |
| `templateHash`   | string | sha256 of the template bytes — audit anchor for MLR flows.                                             |
| `bytes`          | number | Size of the filled .docx in bytes.                                                                     |
