Use this file to discover all available pages before exploring further.
Convert markdown to Word documents (DOCX) with support for track changes, insertions, deletions, and comments. This is useful for generating legal documents, contracts with redlines, and collaborative review documents.
A contract with insertions, deletions, and reviewer comments:
import requests, json, time, base64, osheaders = {"X-API-Key": os.getenv("DATALAB_API_KEY")}markdown = """# Service Agreement## PartiesThis agreement is between <ins data-revision-author="Legal" data-revision-datetime="2024-06-01T09:00:00Z">Acme Corporation ("Provider")</ins> and <del data-revision-author="Legal" data-revision-datetime="2024-06-01T09:00:00Z">the Client</del><ins data-revision-author="Legal" data-revision-datetime="2024-06-01T09:00:00Z">GlobalTech Inc. ("Client")</ins>.## TermsThe service period begins on <comment data-comment-author="Reviewer" text="Confirm start date with finance">January 1, 2025</comment> and continues for <del data-revision-author="Legal" data-revision-datetime="2024-06-01T10:00:00Z">12</del><ins data-revision-author="Legal" data-revision-datetime="2024-06-01T10:00:00Z">24</ins> months.## PaymentThe total contract value is <ins data-revision-author="Finance" data-revision-datetime="2024-06-02T14:00:00Z">$150,000</ins> payable in quarterly installments."""response = requests.post( "https://www.datalab.to/api/v1/create-document", json={"markdown": markdown, "output_format": "docx"}, headers=headers)check_url = response.json()["request_check_url"]while True: result = requests.get(check_url, headers=headers).json() if result["status"] == "complete": docx_bytes = base64.b64decode(result["output_base64"]) with open("service_agreement.docx", "wb") as f: f.write(docx_bytes) print(f"Document saved ({result['page_count']} pages)") break time.sleep(2)
The generated DOCX file opens in Microsoft Word with native track changes visible, allowing reviewers to accept or reject each change.