> ## Documentation Index
> Fetch the complete documentation index at: https://docs.doconda.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How do I add tracked changes to a Word file programmatically?

> Upload the Word file and request the edit with operation edit and quality standard, asking for tracked changes: each change is marked in Word.

To add tracked changes to a Word file programmatically, upload it and request the edit with `operation: "edit"`,
saying in `prompt` that you want it "with tracked changes", and with `quality: "standard"` or `"best"`. Each change is
marked under "Doconda", so whoever opens it in Word can accept or reject it.

## Steps

1. Store your API key in `DOCONDA_API_KEY` and install the SDK (`pip install doconda` or `npm install @doconda/sdk`).
2. Upload the Word file with `files.upload`.
3. Request the edit with tracked changes and download the result.

<CodeGroup>
  ```python Python theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  from pathlib import Path
  from doconda import Doconda

  doconda = Doconda()  # reads the key from DOCONDA_API_KEY
  file = doconda.files.upload("contract.docx")
  edited = doconda.documents.create(
      operation="edit",
      file=file["id"],
      prompt="With tracked changes: change the notice period to 60 days and add a confidentiality clause",
      quality="standard",
  )
  Path("contract-with-changes.docx").write_bytes(doconda.documents.download(edited["id"], "docx"))
  ```

  ```ts TypeScript theme={"theme":{"light":"github-light","dark":"github-dark-dimmed"}}
  import { readFile, writeFile } from "node:fs/promises"
  import { Doconda } from "@doconda/sdk"

  const doconda = new Doconda()
  const file = await doconda.files.upload(await readFile("contract.docx"), "contract.docx")
  const edited = await doconda.documents.create({
    operation: "edit",
    file: file.id,
    prompt: "With tracked changes: change the notice period to 60 days and add a confidentiality clause",
    quality: "standard",
  })
  await writeFile("contract-with-changes.docx", await doconda.documents.download(edited.id, "docx"))
  ```
</CodeGroup>

## What you get back

* The same Word file with each change marked as a revision under "Doconda". The rest of the document stays identical.
* New content copies the document's formatting: an added clause follows the numbering and look of the existing ones.
* Its PDF, and a report (`documents.report(id)`): the result is reviewed just like in [Review](/en/guides/review).
* `status`: `ready`, `ready_with_warnings`, `needs_review` or `failed`. If the request can't be turned into changes,
  it ends in `failed` with `edit_not_understood` and isn't charged.

## Limits

* Tracked changes and comments need `standard` or `best`; `fast` doesn't do them.
* 50 pages maximum.
* `.doc` is accepted too: the result comes out as `.docx`.

## FAQ

<AccordionGroup>
  <Accordion title="Can I add comments instead of changes?">
    Yes. In Word you can ask for tracked changes, add comments or accept pending changes, in the same `prompt`
    sentence.
  </Accordion>

  <Accordion title="Can I accept all pending changes in a Word file?">
    Yes, ask for it in the `prompt` ("accept all pending changes") with `operation: "edit"`.
  </Accordion>

  <Accordion title="Can I edit a document Doconda already made?">
    Yes: pass its id (`doc_…`) in `file` instead of uploading it.
  </Accordion>

  <Accordion title="How do I read a Word file with tracked changes as text?">
    With [`extract`](/en/guides/extract) it comes out as Markdown, with the changes accepted.
  </Accordion>
</AccordionGroup>

## Keep reading

* [Edit](/en/guides/edit) and [quality levels](/en/guides/create#quality-levels).
* [Quickstart](/en/quickstart).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.