edit_document
Apply validated operations to a named Word document in one call, resolving text or paragraph targets and saving only after every edit passes.
Instructions
Edit a document the user named by source, in one call: registers it, resolves targets, and applies the operations - use this instead of register_document + find_in_document + apply_plan. planJson is an operations array [ … ] or { "operations": [ … ] }, the same operations preview_plan documents. Targets may name text directly instead of a paragraph id, so no lookup call is needed first: { "op": "changeText", "target": { "find": "Acme Corp" }, "with": "Globex Inc." } If that text matches more than once the call fails with 'ambiguous-anchor' and lists each candidate with its context; re-issue with { "find": "Acme Corp", "match": 2 } (zero-based) or use more surrounding text. Text that matches nothing fails with 'anchor-not-found'. Anchors resolved from inspect_document/find_in_document ({ "paraId": …, "expect": … }) work here too, and can be mixed in the same plan. saveMode and newName behave as in apply_plan. Nothing is written unless every operation validates. Returns the apply_plan shape plus sourceDocumentId - the id of the document that was opened, usable for follow-up calls even when the edit failed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | ||
| newName | Yes | ||
| planJson | Yes | ||
| saveMode | Yes | Replace | |
| connectionId | Yes |