---
name: "documents_fill_template"
area: "documents"
title: "Fill a Word template"
price: "$0.02"
method: "POST"
url: "https://api.conecto.chat/v1/tools/documents_fill_template"
mcp_server: "https://api.conecto.chat/mcp/documents"
auth: "Authorization: Bearer <conecto_sk_ key>"
docs_url: "https://conecto.chat/tools/documents/documents_fill_template"
---

# Fill a Word template (`documents_fill_template`)

Makes a new Word file from a .docx template, its placeholders filled from data.

A new Word file from a .docx template in the store, its {{ placeholders }} filled from data. Templates use Jinja: {{ name }}, {% if paid %}...{% endif %}, and {%tr for row in rows %} to repeat a table row. Turn the result into a PDF with documents_convert_to_pdf.

Price: $0.02 a call. A call that fails costs nothing.

## Use it when

The same document is made again and again with different details: delivery notes, contracts.

## Say this to your agent

> Fill in the delivery note template for Café Lotte's espresso machine, delivered on Friday.

## Inputs

| Name | Type | Required | Description | Allowed values | Default |
|---|---|---|---|---|---|
| `file_id` | string | yes | A file in the store (files_upload or files_list give its file_id). Exactly 36 characters. |  |  |
| `data` | object | yes | The values, e.g. {"customer": "Acme", "items": [{"name": "Combi steamer", "price": "€9,800"}]}. |  |  |
| `name` | string | no | Name for the new file, e.g. "Quote 1042.pdf". 1 to 200 characters. |  |  |
| `link_hours` | integer | no | 1 to 168. |  | `24` |

## Example

Written for Hansen & Voss, a restaurant-equipment wholesaler in Hamburg with 60 staff.

MCP: call `documents_fill_template` on the MCP server `https://api.conecto.chat/mcp/documents` with these arguments:

```json
{
  "file_id": "6c8e0a2b-4d6f-4b8a-9c0e-1f3a5c7e9b2d",
  "name": "Delivery note Café Lotte.docx",
  "data": {
    "customer_name": "Café Lotte",
    "address": "Eppendorfer Weg 120, 20259 Hamburg",
    "delivery_date": "Friday, October 23",
    "items": [
      {
        "name": "Espresso machine, 2 groups",
        "quantity": 1
      }
    ]
  }
}
```

REST:

```bash
curl https://api.conecto.chat/v1/tools/documents_fill_template \
  -H "Authorization: Bearer $CONECTO_KEY" \
  -H "Content-Type: application/json" \
  -d '{"file_id": "6c8e0a2b-4d6f-4b8a-9c0e-1f3a5c7e9b2d", "name": "Delivery note Café Lotte.docx", "data": {"customer_name": "Café Lotte", "address": "Eppendorfer Weg 120, 20259 Hamburg", "delivery_date": "Friday, October 23", "items": [{"name": "Espresso machine, 2 groups", "quantity": 1}]}}'
```

## Response

```json
{
  "call_id": "5f0c8a2e-3b7d-4c1e-9a64-2d8e1f7b0c93",
  "tool": "documents_fill_template",
  "status": "succeeded",
  "replayed": false,
  "cost_usd": "$0.02",
  "balance_usd": "$19.75",
  "result": {
    "file": {
      "file_id": "262c83f1-e073-4381-b79a-cd6e6a4383eb",
      "name": "Delivery note Café Lotte.docx",
      "content_type": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
      "size": "35.9 KB",
      "size_bytes": 36723,
      "sha256": "ee834ae38089ef77623566aa7976b872d06b70882a454c9b10520a77360a3030",
      "created_at": "2026-10-14T08:00:00+00:00",
      "download_url": "https://cncto.co/d/262c83f1-e073-4381-b79a-cd6e6a4383eb?t=eyJmIjoiMjYyYzgzZjEtZTA3My00MzgxLWI3OWEtY2Q2ZTZhNDM4M2ViIiwiZXhwIjoxNzkyMTYxNjAzfQ:1xHMcl:KX7LuueC9lDjkylkG_jMv0fVDNC8gV1OaofPoKekjEk",
      "link_expires_in_hours": 24
    }
  }
}
```

`result`: file: the filled Word file with its file_id, name, size and download link.

## Errors

| Code | Status | When | Fix |
|---|---|---|---|
| `not_found` | 404 | No file in the store has that file_id. | Find it with files_list, or upload it first. |
| `unsupported_type` | 400 | The file is not a Word .docx file. | Use a .docx template. |
| `template_error` | 422 | The template could not be filled; the message says where. | Fix the template or give the data it asks for. |
| `template_too_slow` | 422 | Filling took too long. | Simplify the template's loops. |
| `storage_full` | 409 | The file store has no room for the new file. | Delete files with files_delete, or add room with files_add_storage. |
| `too_large` | 413 | The result would be over 25 MB. | Make it smaller, or split it. |

The refusals every tool can give (401 key, 402 balance, 429 limits) are on the errors page: https://conecto.chat/docs/errors.md

## Related

- [documents_create_pdf](https://conecto.chat/tools/documents/documents_create_pdf.md): Makes a PDF from Markdown or HTML and saves it in the file store with a download link. $0.02 a call.
- [documents_convert_to_pdf](https://conecto.chat/tools/documents/documents_convert_to_pdf.md): Turns a Word, Excel, PowerPoint, OpenDocument, RTF, CSV, text, Markdown or HTML file into a PDF; the original stays. $0.02 a call.
- [documents_template_fields](https://conecto.chat/tools/documents/documents_template_fields.md): The placeholders in a Word (.docx) template, so you know what data filling it needs. Free up to 1,000,000 reads a month.
- [documents_merge_pdfs](https://conecto.chat/tools/documents/documents_merge_pdfs.md): Makes one PDF from several in the store, in the order given. $0.01 a call.
- [documents_read_pdf](https://conecto.chat/tools/documents/documents_read_pdf.md): The text of a PDF in the store, page by page, up to 50 pages a call. Free up to 1,000,000 reads a month.
- [documents_page_images](https://conecto.chat/tools/documents/documents_page_images.md): The pages of a scanned PDF or a photo of a document as images to look at, up to 10 pages a call. $0.005 a call.
- [documents_create_deck](https://conecto.chat/tools/documents/documents_create_deck.md): A PowerPoint deck from your slides, plain or in the business's template, with editable charts, tables and each slide's sources. $0.10 a call.
