diff_documents — Redline & Audit Two Document Versions

Runs two-level Myers O(ND) section/paragraph and inline word-and-punctuation diffing across two document versions, returning sectionBreadcrumb-tagged hunks, CriticMarkup ({--old--}{++new++}), inline HTML (<del>/<ins>), dedicated numericAndDateChanges alerts, and optional native .docx Track Changes.

Why buy vs. DIY: Eliminates 95% of unchanged context tokens on multi-section specs/RFPs/SOWs, catches every altered number/currency/duration/date deterministically, and packages valid ECMA-376 .docx Track Changes ZIP archives on the edge.

Pricing: $0.002 USD per document redline comparison (x402 instant micropayment) · REST: POST https://doc-redline.apikeg.com/v1/diff-documents · MCP: https://doc-redline.apikeg.com/mcp

Input Parameters

FieldTypeRequired / DefaultDescription & Constraints
original string Required Baseline/original document text or Markdown (e.g. RFP, SOW, specification, SLA, or policy v1). (maxLength: 900000)
revised string Required Revised/updated document text or Markdown to compare deterministically against original. (maxLength: 900000)
changedHunksOnly boolean Default: true When true (default), omits 100% identical sections from hunks, criticMarkup, and htmlRedline so multi-page documents shrink by 90-98% in tokens.
contextParagraphs integer Default: 0 Number of surrounding unchanged paragraphs to include around each changed hunk (0-5). (min: 0, max: 5)
ignoreWhitespace boolean Default: true Normalize repeated inline whitespace when aligning paragraphs while preserving exact text inside word-level diffs.
includeDocxTrackChanges boolean Default: false When true, generates a base64 OpenXML .docx archive containing native Microsoft Word Track Changes (<w:ins> and <w:del>/<w:delText>) for Accept/Reject review.
docxAuthor string Default: "API Keg Redline Engine" Author attribution recorded on OpenXML <w:ins> and <w:del> Track Changes tags when includeDocxTrackChanges is true. (maxLength: 120)
docxTitle string Optional Optional document title stored in .docx Dublin Core package metadata. (maxLength: 200)

REST Example (curl)

curl -X POST "https://doc-redline.apikeg.com/v1/diff-documents" \
  -H "Content-Type: application/json" \
  -d '{
  "original": "# Statement of Work\n\n## Section 4.2: Payment Terms\nCustomer shall pay all undisputed invoices within 30 days of receipt at $150/hour.",
  "revised": "# Statement of Work\n\n## Section 4.2: Payment Terms\nCustomer shall pay all undisputed invoices within 45 days of receipt at $175/hour.",
  "changedHunksOnly": true,
  "contextParagraphs": 0,
  "ignoreWhitespace": true,
  "includeDocxTrackChanges": true,
  "docxAuthor": "Procurement Ops Bot"
}'

MCP tools/call Payload

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "diff_documents",
    "arguments": {
      "original": "# Statement of Work\n\n## Section 4.2: Payment Terms\nCustomer shall pay all undisputed invoices within 30 days of receipt at $150/hour.",
      "revised": "# Statement of Work\n\n## Section 4.2: Payment Terms\nCustomer shall pay all undisputed invoices within 45 days of receipt at $175/hour.",
      "changedHunksOnly": true,
      "contextParagraphs": 0,
      "ignoreWhitespace": true,
      "includeDocxTrackChanges": true,
      "docxAuthor": "Procurement Ops Bot"
    }
  }
}