> For the complete documentation index, see [llms.txt](https://docs.kognitos.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kognitos.com/guides/platform/integrations/docx.md).

# DOCX

Overview of the Docx integration.

{% hint style="info" %}
The following documentation is for **Docx v1.16.0**.
{% endhint %}

## Overview

This integration provides automation capabilities for Docx, enabling streamlined workflows and enhanced productivity. Connect your processes with Docx to automate routine tasks and improve operational efficiency.

## Setup

The following integrations need to be connected to your Kognitos workspace:

* **Docx**

### Steps

Follow these steps to connect the integration in Kognitos:

{% stepper %}
{% step %}

#### Navigate

Using the left navigation menu, go to **Integrations** → **Explore Integrations**.
{% endstep %}

{% step %}

#### Find

Search for the integration and click on it.
{% endstep %}

{% step %}

#### Connect

Click on <kbd>**Connect**</kbd> to add a connection to the integration.
{% endstep %}

{% step %}

#### Configure

Add a name for the connection. You'll be prompted for [**authentication**](#authentication) details if needed. Then, click on <kbd>**Connect**</kbd>.
{% endstep %}
{% endstepper %}

## Actions

The following actions are available in the **Docx** integration:

### 1. Accept a track change in a docx

Accepts a single tracked change by its revision ID.

### 2. Accept all track changes in a docx

Accepts all tracked changes in a DOCX file.

### 3. Add a tracked deletion to a docx

Marks a range of text as deleted in a DOCX via track changes.

### 4. Add a tracked insertion to a docx

Inserts new text into a DOCX as a tracked change.

### 5. Apply tracked replacements to a docx

Finds all occurrences of a text string and replaces with track changes.

### 6. Build a docx from blocks

Builds a DOCX file from a list of typed content blocks.

### 7. Convert a docx file

Legacy: prefer `convert_docx_to_pdf` for new automations.

### 8. Convert a docx file to a thumbnail

Renders a single page of a DOCX file as a PNG thumbnail.

### 9. Convert a docx file to html

Converts a DOCX file to an HTML file.

### 10. Convert a docx file to pdf

Converts a DOCX file to a PDF file.

### 11. Create a docx from markdown

Creates a DOCX file from a Markdown string.

### 12. Enable track changes in a docx

Enables track changes mode in a DOCX file.

### 13. Fill a docx template

Fills in a DOCX template with provided data.

### 14. Get a docx's page count

Gets the total number of pages in a DOCX file.

### 15. Get a docx's word count

Counts whitespace-separated words across paragraphs and table cells.

### 16. Get some template fields

Retrieves all placeholder fields from a DOCX template.

### 17. List the track changes in a docx

Lists all tracked changes in a DOCX file.

### 18. Merge docx files

Merges multiple DOCX files into a single document.

### 19. Read a docx file as markdown

Reads a DOCX file as a Markdown string.

### 20. Read a docx file as text

Reads the plain text content of a DOCX file.

### 21. Read docx headings

Reads the heading outline of a DOCX file.

### 22. Read docx metadata

Reads the core properties of a DOCX file.

### 23. Read docx paragraphs

Reads every body paragraph of a DOCX file with its style.

### 24. Read docx tables

Reads every table from a DOCX file as nested lists.

### 25. Reject a track change in a docx

Rejects a single tracked change by its revision ID.

### 26. Reject all track changes in a docx

Rejects all tracked changes in a DOCX file.

### 27. Replace text in a docx

Replaces text in a DOCX file across paragraphs, tables, headers, and footers.

### 28. Update docx metadata

Updates the core properties (author, title, etc.) of a DOCX file.

## Concepts

### Docx block

A typed content block for `build_docx_from_blocks`.The `type` field selects the block kind. Per-type fields (every other attribute) are optional and only the ones relevant to `type` are read: - `heading`: uses `text`, `level` (0-9, defaults to 1) - `paragraph`: uses `text`, optional `style` (Word style name) - `list`: uses `items` (list of strings) and `ordered` (bool) - `table`: uses `rows` (list of cell-lists), optional `headers` - `page_break`: uses no extra fields

| Field Name | Description                                                  | Type                     |
| ---------- | ------------------------------------------------------------ | ------------------------ |
| `type`     | One of `heading`, `paragraph`, `list`, `table`, `page_break` | `text`                   |
| `text`     | Text content for `heading` and `paragraph` blocks            | `optional[text]`         |
| `level`    | Heading level (0-9) for `heading` blocks                     | `optional[number]`       |
| `style`    | Word style name for `paragraph` blocks                       | `optional[text]`         |
| `items`    | List items for `list` blocks                                 | `optional[list of text]` |
| `ordered`  | True for numbered lists, False for bullets                   | `optional[boolean]`      |
| `headers`  | Header row for `table` blocks                                | `optional[list of text]` |
| `rows`     | Data rows for `table` blocks (list of cell-lists)            | `optional[list of text]` |

### Docx metadata

Core properties of a DOCX file.Mirrors the Dublin Core / OOXML core-properties surface exposed by python-docx. Every field is optional so the same concept doubles as a read-result (populated from the file) and as an update payload (only the fields you set are written). Date fields (`created`, `modified`, `last_printed`) are returned as datetimes when read, and accept either a `datetime` or an ISO 8601 string when used as input. `revision` is an integer.

| Field Name         | Description                             | Type                 |
| ------------------ | --------------------------------------- | -------------------- |
| `author`           | Document author / creator               | `optional[text]`     |
| `category`         | Category classification                 | `optional[text]`     |
| `comments`         | Free-form comments                      | `optional[text]`     |
| `content_status`   | Workflow status (e.g. "Draft", "Final") | `optional[text]`     |
| `created`          | Creation timestamp                      | `optional[datetime]` |
| `identifier`       | External identifier                     | `optional[text]`     |
| `keywords`         | Comma-separated keywords                | `optional[text]`     |
| `language`         | BCP 47 language tag (e.g. "en-US")      | `optional[text]`     |
| `last_modified_by` | Last editor                             | `optional[text]`     |
| `last_printed`     | Last print timestamp                    | `optional[datetime]` |
| `modified`         | Last modification timestamp             | `optional[datetime]` |
| `revision`         | Revision number                         | `optional[number]`   |
| `subject`          | Subject line                            | `optional[text]`     |
| `title`            | Document title                          | `optional[text]`     |
| `version`          | Version string                          | `optional[text]`     |

### Docx track change

A tracked change (revision) in a DOCX file.Represents an insertion, deletion, or formatting change recorded in a .docx file via the OOXML track-changes mechanism.

| Field Name    | Description                                                   | Type             |
| ------------- | ------------------------------------------------------------- | ---------------- |
| `revision_id` | The unique revision identifier for this change.               | `text`           |
| `change_type` | The type of change: `insertion`, `deletion`, or `formatting`. | `text`           |
| `author`      | The name of the person who made this change.                  | `optional[text]` |
| `date`        | The ISO 8601 timestamp when the change was made.              | `optional[text]` |
| `text`        | The text content affected by this change.                     | `optional[text]` |

### Docx heading

A heading entry from a DOCX file.

| Field Name | Description                                       | Type     |
| ---------- | ------------------------------------------------- | -------- |
| `text`     | The heading text                                  | `text`   |
| `level`    | Heading level (0 for Title, 1-9 for Heading 1..9) | `number` |

### Docx paragraph

A single body paragraph of a DOCX file.`level` is set only for heading-styled paragraphs: 0 for `Title` and 1-9 for `Heading 1` through `Heading 9`. Body paragraphs leave it None.

| Field Name | Description                                               | Type               |
| ---------- | --------------------------------------------------------- | ------------------ |
| `text`     | The paragraph text                                        | `text`             |
| `style`    | The Word style name (e.g. "Normal", "Heading 1")          | `optional[text]`   |
| `level`    | Heading level for headings (0=Title, 1-9), None otherwise | `optional[number]` |
