programmatically redline a contract: tracked changes in ooxml and python-docx limitations

domain: legal-general · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Understand that python-docx does not natively support inserting OOXML tracked-change revision marks (w:ins, w:del); to produce true redlines you must manipulate the underlying XML directly via python-docx's element access or use a library like docx2python or a DOCX manipulation API.
  2. For deletions, wrap the run XML in a w:del element with w:id, w:author, and w:date attributes; the run content moves inside a w:delText element.
  3. For insertions, wrap new run XML in a w:ins element with the same required attributes; this signals to Word and compatible viewers that the text is an addition.
  4. Set the w:author attribute to a meaningful name (e.g., the AI reviewer or the user) and w:date to an ISO 8601 datetime so the change is attributed correctly in the revision pane.
  5. Validate the output by opening the file in Microsoft Word or LibreOffice and confirming that Track Changes shows the expected insertions and deletions before delivering to end users.

Known gotchas

Related routes

Implement a contract redlining round-trip workflow: export a PandaDoc document to DOCX, apply tracked changes externally, and re-import the redlined version
pandadoc.com · 5 steps · unrated
Generate a contract document from a template using the PandaDoc API
pandadoc.com · 6 steps · unrated
Trigger a multi-party contract signing workflow via the DocuSign CLM API and transition the contract to executed status
developers.docusign.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans