Automate a DOCX from the CLI
Accept tracked changes and save a separate DOCX from a shell or CI job.
Use the CLI when a shell script or CI job already knows which document operation to run. This guide accepts every tracked change in a DOCX and writes the result to a separate file.
1. Install the CLI
pnpm add --global @superdoc/cli@latestThe package installs the matching native command for your platform. Published builds support macOS on Apple Silicon and Intel, Linux on ARM64 and x64, and Windows on x64.
Confirm that the command is available:
superdoc --version2. Prepare a document
Download the tracked-changes fixture and save it as contract.docx in your working
directory. It contains one tracked change.
3. Accept the changes and save
Create accept-changes.sh:
#!/usr/bin/env bash
set -euo pipefail
superdoc open ./contract.docx
trap 'superdoc close --discard >/dev/null 2>&1 || true' EXIT
superdoc track-changes list
superdoc track-changes accept-all
superdoc save --out ./contract.accepted.docx
Run it from the directory containing contract.docx:
bash accept-changes.shopen creates an active document session. The review command changes that session, and save --out writes a separate
DOCX. The EXIT trap closes the session whether the script succeeds or fails. The source file is not overwritten.
4. Verify the output
Open contract.accepted.docx in Microsoft Word or the SuperDoc editor. Every tracked change should be accepted. The
original contract.docx should remain unchanged.
Use the Node.js SDK or Python SDK when application code needs to own the workflow, errors, and output paths. For the operation and receipt model shared by every surface, continue with the Document API mental model.