Skip to main content
SuperDoc SDKs let you open, read, and edit .docx files from Node.js or Python. They manage the CLI process for you and expose typed methods for every operation.
The SDKs are in alpha. The API surface matches the Document API and will evolve alongside it.

Installation

npm install @superdoc-dev/sdk
The CLI is bundled with the SDK — no separate install needed.

Quick start

The Node SDK supports both ESM and CommonJS:
// ESM
import { createSuperDocClient } from '@superdoc-dev/sdk';

// CommonJS
const { createSuperDocClient } = require('@superdoc-dev/sdk');
import { SuperDocClient } from '@superdoc-dev/sdk';

const client = new SuperDocClient({
  defaultChangeMode: 'tracked',
});

// Open a document
await client.doc.open({ doc: './contract.docx' });

// Find and replace text with query + mutation plan
const match = await client.doc.query.match({
  select: { type: 'text', pattern: 'ACME Corp' },
  require: 'first',
});

const ref = match.items?.[0]?.handle?.ref;
if (ref) {
  await client.doc.mutations.apply({
    expectedRevision: match.evaluatedRevision,
    atomic: true,
    steps: [
      {
        id: 'replace-acme',
        op: 'text.rewrite',
        where: { by: 'ref', ref },
        args: { replacement: { text: 'NewCo Inc.' } },
      },
    ],
  });
}

// Save and close
await client.doc.save();
await client.doc.close();
Set defaultChangeMode: 'tracked' (Node) or default_change_mode='tracked' (Python) to make mutations use tracked changes by default. If you pass changeMode on a specific call, that explicit value overrides the default. The Python SDK also exposes synchronous SuperDocClient with the same doc.* operations when you prefer non-async code paths.

User identity

By default the SDK attributes edits to a generic “CLI” user. Set user on the client to identify your automation in comments, tracked changes, and collaboration presence:
const client = new SuperDocClient({
  user: { name: 'Review Bot', email: 'bot@example.com' },
});
The user is injected into every doc.open call. If you pass userName or userEmail on a specific doc.open, those per-call values take precedence.

Collaboration sessions

Use this when your app already has a live collaboration room (Liveblocks, Hocuspocus, or SuperDoc Yjs).

Join an existing room

Pass collabUrl and collabDocumentId to doc.open:
import { SuperDocClient } from '@superdoc-dev/sdk';

const client = new SuperDocClient();
await client.connect();

await client.doc.open({
  collabUrl: 'ws://localhost:4000',
  collabDocumentId: 'my-doc-room',
});

await client.doc.insert({
  target: { type: 'end' },
  content: 'Added by the SDK',
});

Start an empty room from a local .docx

If the room is empty, pass doc together with collaboration params:
await client.doc.open({
  doc: './starting-template.docx',
  collabUrl: 'ws://localhost:4000',
  collabDocumentId: 'my-doc-room',
});
What happens when you pass doc:
Room stateResult
Room already has contentSDK joins the room. doc is ignored.
Room is empty and doc is providedSDK seeds the room from doc, then joins.
Room is empty and no doc is providedSDK starts a blank document.

Control empty-room behavior

ParameterTypeDefaultDescription
collabUrlstringWebSocket URL for your collaboration provider.
collabDocumentIdstringsession IDRoom/document ID on the provider.
docstringLocal .docx used only when the room is empty.
onMissingstringseedFromDocseedFromDoc, blank, or error.
bootstrapSettlingMsnumber1500Wait time (ms) before seeding to avoid race conditions.
The three onMissing values:
ValueWhen the room is emptyUse when
seedFromDoc (default)Seeds from doc if provided, otherwise seeds a blank document.First-time opens where you provide a .docx template.
blankAlways seeds a blank document.You want an empty starting document regardless of doc.
errorThrows an error instead of seeding.Reopening existing ydocs — prevents accidental overwrites.
If you reopen an existing ydoc without providing a doc file, the default seedFromDoc will seed a blank document if the room appears empty during sync. This overwrites your existing content. Always use onMissing: 'error' when reopening documents that were previously created or populated.
// Safe reopen — throws if the room is unexpectedly empty
await client.doc.open({
  collabUrl: 'ws://localhost:4000',
  collabDocumentId: 'my-doc-room',
  onMissing: 'error',
});

Check if the SDK seeded or joined

doc.open returns bootstrap details in collaboration mode:
const result = await client.doc.open({
  doc: './starting-template.docx',
  collabUrl: 'ws://localhost:4000',
  collabDocumentId: 'my-doc-room',
});

console.log(result.bootstrap);
// { roomState, bootstrapApplied, bootstrapSource }

Available operations

The SDKs expose all operations from the Document API plus lifecycle and session commands. The tables below are grouped by category.

Core

OperationCLI commandDescription
doc.getgetRead the full document as an SDDocument structure.
doc.findfindSearch the document for text or node matches using SDM/1 selectors.
doc.getNodeget-nodeRetrieve a single node by target position.
doc.getNodeByIdget-node-by-idRetrieve a single node by its unique ID.
doc.getTextget-textExtract the plain-text content of the document.
doc.getMarkdownget-markdownExtract the document content as a Markdown string.
doc.getHtmlget-htmlExtract the document content as an HTML string.
doc.markdownToFragmentmarkdown-to-fragmentConvert a Markdown string into an SDM/1 structural fragment.
doc.infoinfoReturn document metadata including revision, node count, and capabilities.
doc.clearContentclear-contentClear all document body content, leaving a single empty paragraph.
doc.insertinsertInsert content at a target position, or at the end of the document when target is omitted. Accepts two input shapes: legacy string-based (value + type) or structural SDFragment (content). Supports text (default), markdown, and html content types via the type field in legacy mode. Structural mode accepts an SDFragment with typed nodes (paragraphs, tables, images, etc.).
doc.replacereplaceReplace content at a target position with new content. Accepts two input shapes: legacy string-based (text) or structural SDFragment (content). Structural mode replaces the target range with typed nodes (paragraphs, tables, images, etc.).
doc.deletedeleteDelete content at a target position.
doc.blocks.deleteblocks deleteDelete an entire block node (paragraph, heading, list item, table, image, or sdt) deterministically.
doc.query.matchquery matchDeterministic selector-based search with cardinality contracts for mutation targeting.
doc.mutations.previewmutations previewDry-run a mutation plan, returning resolved targets without applying changes.
doc.mutations.applymutations applyExecute a mutation plan atomically against the document.
doc.capabilities.getcapabilitiesQuery runtime capabilities supported by the current document engine.
doc.hyperlinks.listhyperlinks listList all hyperlinks in the document, with optional filtering by href, anchor, or display text.
doc.hyperlinks.gethyperlinks getRetrieve details of a specific hyperlink by its inline address.
doc.hyperlinks.wraphyperlinks wrapWrap an existing text range with a hyperlink.
doc.hyperlinks.inserthyperlinks insertInsert new linked text at a target position.
doc.hyperlinks.patchhyperlinks patchUpdate hyperlink metadata (destination, tooltip, target, rel) without changing display text.
doc.hyperlinks.removehyperlinks removeRemove a hyperlink. Mode ‘unwrap’ preserves display text; ‘deleteText’ removes the linked content entirely.
doc.headerFooters.listheader-footers listList header/footer slot entries across sections.
doc.headerFooters.getheader-footers getGet a single header/footer slot entry by address.
doc.headerFooters.resolveheader-footers resolveResolve the effective header/footer reference for a slot, walking the section inheritance chain.
doc.headerFooters.refs.setheader-footers refs setSet an explicit header/footer reference on a section slot.
doc.headerFooters.refs.clearheader-footers refs clearClear an explicit header/footer reference from a section slot.
doc.headerFooters.refs.setLinkedToPreviousheader-footers refs set-linked-to-previousLink or unlink a header/footer slot to/from the previous section.
doc.headerFooters.parts.listheader-footers parts listList unique header/footer part records from document relationships.
doc.headerFooters.parts.createheader-footers parts createCreate a new independent header/footer part, optionally cloned from an existing part.
doc.headerFooters.parts.deleteheader-footers parts deleteDelete a header/footer part and its associated relationship when no section slots reference it.
doc.create.contentControlcreate content-controlCreate a new content control (SDT) in the document.
doc.contentControls.listcontent-controls listList all content controls in the document with optional type/tag filtering.
doc.contentControls.getcontent-controls getRetrieve a single content control by target.
doc.contentControls.listInRangecontent-controls list-in-rangeList content controls within a block range.
doc.contentControls.selectByTagcontent-controls select-by-tagSelect content controls matching a specific tag value.
doc.contentControls.selectByTitlecontent-controls select-by-titleSelect content controls matching a specific title (alias) value.
doc.contentControls.listChildrencontent-controls list-childrenList direct child content controls nested inside the target.
doc.contentControls.getParentcontent-controls get-parentGet the parent content control of the target, if any.
doc.contentControls.wrapcontent-controls wrapWrap existing content with a new content control.
doc.contentControls.unwrapcontent-controls unwrapRemove the content control wrapper, preserving its content in place.
doc.contentControls.deletecontent-controls deleteDelete a content control and its content from the document.
doc.contentControls.copycontent-controls copyCopy a content control to a destination position. Copied SDTs receive new IDs.
doc.contentControls.movecontent-controls moveMove a content control to a new position. Preserves original IDs.
doc.contentControls.patchcontent-controls patchPatch metadata properties on a content control (tag, alias, appearance, color, etc.).
doc.contentControls.setLockModecontent-controls set-lock-modeSet the lock mode on a content control.
doc.contentControls.setTypecontent-controls set-typeTransition a content control to a different semantic type. Metadata-only; no implicit content rewrite.
doc.contentControls.getContentcontent-controls get-contentGet the text content of a content control.
doc.contentControls.replaceContentcontent-controls replace-contentReplace the entire content of a content control.
doc.contentControls.clearContentcontent-controls clear-contentClear all content inside a content control, leaving it empty.
doc.contentControls.appendContentcontent-controls append-contentAppend content to the end of a content control.
doc.contentControls.prependContentcontent-controls prepend-contentPrepend content to the beginning of a content control.
doc.contentControls.insertBeforecontent-controls insert-beforeInsert content immediately before a content control.
doc.contentControls.insertAftercontent-controls insert-afterInsert content immediately after a content control.
doc.contentControls.getBindingcontent-controls get-bindingGet the data binding metadata (w:dataBinding) of a content control.
doc.contentControls.setBindingcontent-controls set-bindingSet data binding metadata on a content control.
doc.contentControls.clearBindingcontent-controls clear-bindingRemove data binding metadata from a content control.
doc.contentControls.getRawPropertiescontent-controls get-raw-propertiesGet the raw sdtPr properties of a content control as a passthrough hash.
doc.contentControls.patchRawPropertiescontent-controls patch-raw-propertiesApply raw XML-level patches to the sdtPr subtree of a content control.
doc.contentControls.validateWordCompatibilitycontent-controls validate-word-compatibilityValidate a content control for Word compatibility issues.
doc.contentControls.normalizeWordCompatibilitycontent-controls normalize-word-compatibilityNormalize a content control to resolve Word compatibility issues.
doc.contentControls.normalizeTagPayloadcontent-controls normalize-tag-payloadNormalize a content control tag between plain-string and JSON-encoded formats.
doc.contentControls.text.setMultilinecontent-controls text set-multilineSet or clear the multiline attribute on a plain-text content control.
doc.contentControls.text.setValuecontent-controls text set-valueSet the text value of a plain-text content control.
doc.contentControls.text.clearValuecontent-controls text clear-valueClear the text value of a plain-text content control.
doc.contentControls.date.setValuecontent-controls date set-valueSet the date value of a date content control.
doc.contentControls.date.clearValuecontent-controls date clear-valueClear the date value of a date content control.
doc.contentControls.date.setDisplayFormatcontent-controls date set-display-formatSet the display format string for a date content control.
doc.contentControls.date.setDisplayLocalecontent-controls date set-display-localeSet the display locale for a date content control.
doc.contentControls.date.setStorageFormatcontent-controls date set-storage-formatSet the XML storage format for a date content control.
doc.contentControls.date.setCalendarcontent-controls date set-calendarSet the calendar type for a date content control.
doc.contentControls.checkbox.getStatecontent-controls checkbox get-stateGet the checked state of a checkbox content control.
doc.contentControls.checkbox.setStatecontent-controls checkbox set-stateSet the checked state of a checkbox content control.
doc.contentControls.checkbox.togglecontent-controls checkbox toggleToggle the checked state of a checkbox content control.
doc.contentControls.checkbox.setSymbolPaircontent-controls checkbox set-symbol-pairSet the checked and unchecked symbol glyphs for a checkbox content control.
doc.contentControls.choiceList.getItemscontent-controls choice-list get-itemsGet the list items and selected value of a comboBox or dropDownList content control.
doc.contentControls.choiceList.setItemscontent-controls choice-list set-itemsReplace the list items of a comboBox or dropDownList content control.
doc.contentControls.choiceList.setSelectedcontent-controls choice-list set-selectedSet the selected value of a comboBox or dropDownList content control.
doc.contentControls.repeatingSection.listItemscontent-controls repeating-section list-itemsList the repeating section items inside a repeating section content control.
doc.contentControls.repeatingSection.insertItemBeforecontent-controls repeating-section insert-item-beforeInsert a new item before a specific index in a repeating section.
doc.contentControls.repeatingSection.insertItemAftercontent-controls repeating-section insert-item-afterInsert a new item after a specific index in a repeating section.
doc.contentControls.repeatingSection.cloneItemcontent-controls repeating-section clone-itemClone a repeating section item at the given index. Cloned SDTs receive new IDs.
doc.contentControls.repeatingSection.deleteItemcontent-controls repeating-section delete-itemDelete a repeating section item at the given index.
doc.contentControls.repeatingSection.setAllowInsertDeletecontent-controls repeating-section set-allow-insert-deleteSet the allowInsertDelete flag on a repeating section.
doc.contentControls.group.wrapcontent-controls group wrapWrap a content control inside a new group content control. Always nests; not idempotent.
doc.contentControls.group.ungroupcontent-controls group ungroupRemove the group designation from a group content control.
doc.bookmarks.listbookmarks listList all bookmarks in the document.
doc.bookmarks.getbookmarks getGet detailed information about a specific bookmark.
doc.bookmarks.insertbookmarks insertInsert a new named bookmark at a target location.
doc.bookmarks.renamebookmarks renameRename an existing bookmark.
doc.bookmarks.removebookmarks removeRemove a bookmark from the document.
doc.footnotes.listfootnotes listList all footnotes and endnotes in the document.
doc.footnotes.getfootnotes getGet detailed information about a specific footnote or endnote.
doc.footnotes.insertfootnotes insertInsert a new footnote or endnote at a target location.
doc.footnotes.updatefootnotes updateUpdate the content of an existing footnote or endnote.
doc.footnotes.removefootnotes removeRemove a footnote or endnote from the document.
doc.footnotes.configurefootnotes configureConfigure numbering and placement for footnotes or endnotes.
doc.crossRefs.listcross-refs listList all cross-reference fields in the document.
doc.crossRefs.getcross-refs getGet detailed information about a specific cross-reference field.
doc.crossRefs.insertcross-refs insertInsert a new cross-reference field at a target location.
doc.crossRefs.rebuildcross-refs rebuildRebuild (recalculate) a cross-reference field.
doc.crossRefs.removecross-refs removeRemove a cross-reference field from the document.
doc.index.listindex listList all index blocks in the document.
doc.index.getindex getGet detailed information about a specific index block.
doc.index.insertindex insertInsert a new index block at a target location.
doc.index.configureindex configureUpdate the configuration of an existing index block.
doc.index.rebuildindex rebuildRebuild (regenerate) an index block from its entries.
doc.index.removeindex removeRemove an index block from the document.
doc.index.entries.listindex entries listList all XE (index entry) fields in the document.
doc.index.entries.getindex entries getGet detailed information about a specific XE index entry.
doc.index.entries.insertindex entries insertInsert a new XE index entry field at a target location.
doc.index.entries.updateindex entries updateUpdate the properties of an existing XE index entry.
doc.index.entries.removeindex entries removeRemove an XE index entry field from the document.
doc.captions.listcaptions listList all caption paragraphs in the document.
doc.captions.getcaptions getGet detailed information about a specific caption paragraph.
doc.captions.insertcaptions insertInsert a new caption paragraph adjacent to a target block.
doc.captions.updatecaptions updateUpdate the text of an existing caption paragraph.
doc.captions.removecaptions removeRemove a caption paragraph from the document.
doc.captions.configurecaptions configureConfigure numbering format for a caption label.
doc.fields.listfields listList all fields in the document.
doc.fields.getfields getGet detailed information about a specific field.
doc.fields.insertfields insertInsert a raw field code at a target location.
doc.fields.rebuildfields rebuildRebuild (recalculate) a field.
doc.fields.removefields removeRemove a field from the document.
doc.citations.listcitations listList all citation marks in the document.
doc.citations.getcitations getGet detailed information about a specific citation mark.
doc.citations.insertcitations insertInsert a new citation mark at a target location.
doc.citations.updatecitations updateUpdate an existing citation mark’s source references.
doc.citations.removecitations removeRemove a citation mark from the document.
doc.citations.sources.listcitations sources listList all citation sources in the document store.
doc.citations.sources.getcitations sources getGet detailed information about a specific citation source.
doc.citations.sources.insertcitations sources insertRegister a new citation source in the document store.
doc.citations.sources.updatecitations sources updateUpdate the fields of an existing citation source.
doc.citations.sources.removecitations sources removeRemove a citation source from the document store.
doc.citations.bibliography.getcitations bibliography getGet information about the bibliography block.
doc.citations.bibliography.insertcitations bibliography insertInsert a bibliography block at a target location.
doc.citations.bibliography.rebuildcitations bibliography rebuildRebuild the bibliography from current sources.
doc.citations.bibliography.configurecitations bibliography configureConfigure the bibliography style.
doc.citations.bibliography.removecitations bibliography removeRemove the bibliography block from the document.
doc.authorities.listauthorities listList all table-of-authorities blocks in the document.
doc.authorities.getauthorities getGet detailed information about a specific table-of-authorities block.
doc.authorities.insertauthorities insertInsert a new table-of-authorities block at a target location.
doc.authorities.configureauthorities configureUpdate the configuration of an existing table-of-authorities block.
doc.authorities.rebuildauthorities rebuildRebuild a table-of-authorities block from its entries.
doc.authorities.removeauthorities removeRemove a table-of-authorities block from the document.
doc.authorities.entries.listauthorities entries listList all TA (authority entry) fields in the document.
doc.authorities.entries.getauthorities entries getGet detailed information about a specific TA authority entry.
doc.authorities.entries.insertauthorities entries insertInsert a new TA authority entry field at a target location.
doc.authorities.entries.updateauthorities entries updateUpdate the properties of an existing TA authority entry.
doc.authorities.entries.removeauthorities entries removeRemove a TA authority entry field from the document.

Format

OperationCLI commandDescription
doc.format.applyformat applyApply inline run-property patch changes to the target range with explicit set/clear semantics.
doc.format.boldformat boldSet or clear the bold inline run property on the target text range.
doc.format.italicformat italicSet or clear the italic inline run property on the target text range.
doc.format.strikeformat strikeSet or clear the strike inline run property on the target text range.
doc.format.underlineformat underlineSet or clear the underline inline run property on the target text range.
doc.format.highlightformat highlightSet or clear the highlight inline run property on the target text range.
doc.format.colorformat colorSet or clear the color inline run property on the target text range.
doc.format.fontSizeformat font-sizeSet or clear the fontSize inline run property on the target text range.
doc.format.fontFamilyformat font-familySet or clear the fontFamily inline run property on the target text range.
doc.format.letterSpacingformat letter-spacingSet or clear the letterSpacing inline run property on the target text range.
doc.format.vertAlignformat vert-alignSet or clear the vertAlign inline run property on the target text range.
doc.format.positionformat positionSet or clear the position inline run property on the target text range.
doc.format.dstrikeformat dstrikeSet or clear the dstrike inline run property on the target text range.
doc.format.smallCapsformat small-capsSet or clear the smallCaps inline run property on the target text range.
doc.format.capsformat capsSet or clear the caps inline run property on the target text range.
doc.format.shadingformat shadingSet or clear the shading inline run property on the target text range.
doc.format.borderformat borderSet or clear the border inline run property on the target text range.
doc.format.outlineformat outlineSet or clear the outline inline run property on the target text range.
doc.format.shadowformat shadowSet or clear the shadow inline run property on the target text range.
doc.format.embossformat embossSet or clear the emboss inline run property on the target text range.
doc.format.imprintformat imprintSet or clear the imprint inline run property on the target text range.
doc.format.charScaleformat char-scaleSet or clear the charScale inline run property on the target text range.
doc.format.kerningformat kerningSet or clear the kerning inline run property on the target text range.
doc.format.vanishformat vanishSet or clear the vanish inline run property on the target text range.
doc.format.webHiddenformat web-hiddenSet or clear the webHidden inline run property on the target text range.
doc.format.specVanishformat spec-vanishSet or clear the specVanish inline run property on the target text range.
doc.format.rtlformat rtlSet or clear the rtl inline run property on the target text range.
doc.format.csformat csSet or clear the cs inline run property on the target text range.
doc.format.bCsformat b-csSet or clear the bCs inline run property on the target text range.
doc.format.iCsformat i-csSet or clear the iCs inline run property on the target text range.
doc.format.eastAsianLayoutformat east-asian-layoutSet or clear the eastAsianLayout inline run property on the target text range.
doc.format.emformat emSet or clear the em inline run property on the target text range.
doc.format.fitTextformat fit-textSet or clear the fitText inline run property on the target text range.
doc.format.snapToGridformat snap-to-gridSet or clear the snapToGrid inline run property on the target text range.
doc.format.langformat langSet or clear the lang inline run property on the target text range.
doc.format.oMathformat o-mathSet or clear the oMath inline run property on the target text range.
doc.format.rStyleformat r-styleSet or clear the rStyle inline run property on the target text range.
doc.format.rFontsformat r-fontsSet or clear the rFonts inline run property on the target text range.
doc.format.fontSizeCsformat font-size-csSet or clear the fontSizeCs inline run property on the target text range.
doc.format.ligaturesformat ligaturesSet or clear the ligatures inline run property on the target text range.
doc.format.numFormformat num-formSet or clear the numForm inline run property on the target text range.
doc.format.numSpacingformat num-spacingSet or clear the numSpacing inline run property on the target text range.
doc.format.stylisticSetsformat stylistic-setsSet or clear the stylisticSets inline run property on the target text range.
doc.format.contextualAlternatesformat contextual-alternatesSet or clear the contextualAlternates inline run property on the target text range.
doc.styles.applystyles applyApply document-level default style changes to the stylesheet (word/styles.xml). Targets docDefaults run and paragraph channels with set-style patch semantics.
doc.styles.paragraph.setStylestyles paragraph set-styleSet the paragraph style reference (w:pStyle) on a paragraph-like block.
doc.styles.paragraph.clearStylestyles paragraph clear-styleRemove the paragraph style reference from a paragraph-like block.
doc.format.paragraph.resetDirectFormattingformat paragraph reset-direct-formattingStrip all direct paragraph formatting while preserving style reference, numbering, and section metadata.
doc.format.paragraph.setAlignmentformat paragraph set-alignmentSet paragraph alignment (justification) on a paragraph-like block.
doc.format.paragraph.clearAlignmentformat paragraph clear-alignmentRemove direct paragraph alignment, reverting to style-defined or default alignment.
doc.format.paragraph.setIndentationformat paragraph set-indentationSet paragraph indentation properties (left, right, firstLine, hanging) in twips.
doc.format.paragraph.clearIndentationformat paragraph clear-indentationRemove all direct paragraph indentation.
doc.format.paragraph.setSpacingformat paragraph set-spacingSet paragraph spacing properties (before, after, line, lineRule) in twips.
doc.format.paragraph.clearSpacingformat paragraph clear-spacingRemove all direct paragraph spacing.
doc.format.paragraph.setKeepOptionsformat paragraph set-keep-optionsSet keep-with-next, keep-lines-together, and widow/orphan control flags.
doc.format.paragraph.setOutlineLevelformat paragraph set-outline-levelSet the paragraph outline level (0–9) or null to clear.
doc.format.paragraph.setFlowOptionsformat paragraph set-flow-optionsSet contextual spacing, page-break-before, and suppress-auto-hyphens flags.
doc.format.paragraph.setTabStopformat paragraph set-tab-stopAdd or replace a tab stop at a given position.
doc.format.paragraph.clearTabStopformat paragraph clear-tab-stopRemove a tab stop at a given position.
doc.format.paragraph.clearAllTabStopsformat paragraph clear-all-tab-stopsRemove all tab stops from a paragraph.
doc.format.paragraph.setBorderformat paragraph set-borderSet border properties for a specific side of a paragraph.
doc.format.paragraph.clearBorderformat paragraph clear-borderRemove border for a specific side or all sides of a paragraph.
doc.format.paragraph.setShadingformat paragraph set-shadingSet paragraph shading (background fill, pattern color, pattern type).
doc.format.paragraph.clearShadingformat paragraph clear-shadingRemove all paragraph shading.

Create

OperationCLI commandDescription
doc.create.paragraphcreate paragraphCreate a new paragraph at the target position.
doc.create.headingcreate headingCreate a new heading at the target position.
doc.create.sectionBreakcreate section-breakCreate a section break at the target location with optional initial section properties.
doc.create.tablecreate tableCreate a new table at the target position.
doc.create.tableOfContentscreate table-of-contentsInsert a new table of contents at the target position.
doc.create.imagecreate imageInsert a new image at the target position.

Sections

OperationCLI commandDescription
doc.sections.listsections listList sections in deterministic order with section-target handles.
doc.sections.getsections getRetrieve full section information by section address.
doc.sections.setBreakTypesections set-break-typeSet the section break type.
doc.sections.setPageMarginssections set-page-marginsSet page-edge margins for a section.
doc.sections.setHeaderFooterMarginssections set-header-footer-marginsSet header/footer margin distances for a section.
doc.sections.setPageSetupsections set-page-setupSet page size/orientation properties for a section.
doc.sections.setColumnssections set-columnsSet column configuration for a section.
doc.sections.setLineNumberingsections set-line-numberingEnable or configure line numbering for a section.
doc.sections.setPageNumberingsections set-page-numberingSet page numbering format/start for a section.
doc.sections.setTitlePagesections set-title-pageEnable or disable title-page behavior for a section.
doc.sections.setOddEvenHeadersFooterssections set-odd-even-headers-footersEnable or disable odd/even header-footer mode in document settings.
doc.sections.setVerticalAlignsections set-vertical-alignSet vertical page alignment for a section.
doc.sections.setSectionDirectionsections set-section-directionSet section text flow direction (LTR/RTL).
doc.sections.setHeaderFooterRefsections set-header-footer-refSet or replace a section header/footer reference for a variant.
doc.sections.clearHeaderFooterRefsections clear-header-footer-refClear a section header/footer reference for a specific variant.
doc.sections.setLinkToPrevioussections set-link-to-previousSet or clear link-to-previous behavior for a header/footer variant.
doc.sections.setPageBorderssections set-page-bordersSet page border configuration for a section.
doc.sections.clearPageBorderssections clear-page-bordersClear page border configuration for a section.

Lists

OperationCLI commandDescription
doc.lists.listlists listList all list nodes in the document, optionally filtered by scope.
doc.lists.getlists getRetrieve a specific list node by target.
doc.lists.insertlists insertInsert a new list at the target position.
doc.lists.createlists createCreate a new list from one or more paragraphs, or convert existing paragraphs into a new list.
doc.lists.attachlists attachConvert non-list paragraphs to list items under an existing list sequence.
doc.lists.detachlists detachRemove numbering properties from list items, converting them to plain paragraphs.
doc.lists.indentlists indentIncrease the indentation level of a list item.
doc.lists.outdentlists outdentDecrease the indentation level of a list item.
doc.lists.joinlists joinMerge two adjacent list sequences into one.
doc.lists.canJoinlists can-joinCheck whether two adjacent list sequences can be joined.
doc.lists.separatelists separateSplit a list sequence at the target item, creating a new sequence from that point forward.
doc.lists.setLevellists set-levelSet the absolute nesting level (0..8) of a list item.
doc.lists.setValuelists set-valueSet an explicit numbering value at the target item. Mid-sequence targets are atomically separated first.
doc.lists.continuePreviouslists continue-previousContinue numbering from the nearest compatible previous list sequence.
doc.lists.canContinuePreviouslists can-continue-previousCheck whether the target sequence can continue numbering from a previous compatible sequence.
doc.lists.setLevelRestartlists set-level-restartSet the restart behavior for a specific list level.
doc.lists.convertToTextlists convert-to-textConvert list items to plain paragraphs, optionally prepending the rendered marker text.
doc.lists.applyTemplatelists apply-templateApply a captured ListTemplate to the target list, optionally filtered to specific levels.
doc.lists.applyPresetlists apply-presetApply a built-in list formatting preset to the target list.
doc.lists.setTypelists set-typeConvert a list to ordered or bullet and merge adjacent compatible sequences to preserve continuous numbering.
doc.lists.captureTemplatelists capture-templateCapture the formatting of a list as a reusable ListTemplate.
doc.lists.setLevelNumberinglists set-level-numberingSet the numbering format, pattern, and optional start value for a specific list level.
doc.lists.setLevelBulletlists set-level-bulletSet the bullet marker text for a specific list level.
doc.lists.setLevelPictureBulletlists set-level-picture-bulletSet a picture bullet for a specific list level by its OOXML lvlPicBulletId.
doc.lists.setLevelAlignmentlists set-level-alignmentSet the marker alignment (left, center, right) for a specific list level.
doc.lists.setLevelIndentslists set-level-indentsSet the paragraph indentation values (left, hanging, firstLine) for a specific list level.
doc.lists.setLevelTrailingCharacterlists set-level-trailing-characterSet the trailing character (tab, space, nothing) after the marker for a specific list level.
doc.lists.setLevelMarkerFontlists set-level-marker-fontSet the font family used for the marker character at a specific list level.
doc.lists.clearLevelOverrideslists clear-level-overridesRemove instance-level overrides for a specific list level, restoring abstract definition values.

Tables

OperationCLI commandDescription
doc.tables.convertFromTexttables convert-from-textConvert a text range into a table.
doc.tables.deletetables deleteDelete the target table from the document.
doc.tables.clearContentstables clear-contentsClear the contents of the target table or cell range.
doc.tables.movetables moveMove a table to a new position in the document.
doc.tables.splittables splitSplit a table into two tables at the target row.
doc.tables.convertToTexttables convert-to-textConvert a table back to plain text.
doc.tables.setLayouttables set-layoutSet the layout mode of the target table.
doc.tables.insertRowtables insert-rowInsert a new row into the target table.
doc.tables.deleteRowtables delete-rowDelete a row from the target table.
doc.tables.setRowHeighttables set-row-heightSet the height of a table row.
doc.tables.distributeRowstables distribute-rowsDistribute row heights evenly across the target table.
doc.tables.setRowOptionstables set-row-optionsSet options on a table row such as header repeat or page break.
doc.tables.insertColumntables insert-columnInsert a new column into the target table.
doc.tables.deleteColumntables delete-columnDelete a column from the target table.
doc.tables.setColumnWidthtables set-column-widthSet the width of a table column.
doc.tables.distributeColumnstables distribute-columnsDistribute column widths evenly across the target table.
doc.tables.insertCelltables insert-cellInsert a new cell into a table row.
doc.tables.deleteCelltables delete-cellDelete a cell from a table row.
doc.tables.mergeCellstables merge-cellsMerge a range of table cells into one.
doc.tables.unmergeCellstables unmerge-cellsUnmerge a previously merged table cell.
doc.tables.splitCelltables split-cellSplit a table cell into multiple cells.
doc.tables.setCellPropertiestables set-cell-propertiesSet properties on a table cell such as vertical alignment or text direction.
doc.tables.sorttables sortSort table rows by a column value.
doc.tables.setAltTexttables set-alt-textSet the alternative text description for a table.
doc.tables.setStyletables set-styleApply a named table style to the target table.
doc.tables.clearStyletables clear-styleRemove the applied table style, reverting to defaults.
doc.tables.setStyleOptiontables set-style-optionToggle a conditional style option such as banded rows or first column.
doc.tables.setBordertables set-borderSet border properties on a table or cell range.
doc.tables.clearBordertables clear-borderRemove border formatting from a table or cell range.
doc.tables.applyBorderPresettables apply-border-presetApply a border preset (e.g. all borders, outside only) to a table.
doc.tables.setShadingtables set-shadingSet the background shading color on a table or cell range.
doc.tables.clearShadingtables clear-shadingRemove shading from a table or cell range.
doc.tables.setTablePaddingtables set-table-paddingSet default cell padding for the entire table.
doc.tables.setCellPaddingtables set-cell-paddingSet padding on a specific table cell or cell range.
doc.tables.setCellSpacingtables set-cell-spacingSet the cell spacing for the target table.
doc.tables.clearCellSpacingtables clear-cell-spacingRemove custom cell spacing from the target table.
doc.tables.gettables getRetrieve table structure and dimensions by locator.
doc.tables.getCellstables get-cellsRetrieve cell information for a table, optionally filtered by row or column.
doc.tables.getPropertiestables get-propertiesRetrieve layout and style properties of a table.
doc.tables.getStylestables get-stylesList all table styles and the document-level default table style setting.
doc.tables.setDefaultStyletables set-default-styleSet the document-level default table style (w:defaultTableStyle in settings.xml).
doc.tables.clearDefaultStyletables clear-default-styleRemove the document-level default table style setting.

Table of contents

OperationCLI commandDescription
doc.toc.listtoc listList all tables of contents in the document.
doc.toc.gettoc getRetrieve details of a specific table of contents.
doc.toc.configuretoc configureUpdate the configuration switches of a table of contents.
doc.toc.updatetoc updateRebuild or refresh the materialized content of a table of contents.
doc.toc.removetoc removeRemove a table of contents from the document.
doc.toc.markEntrytoc mark-entryInsert a TC (table of contents entry) field at the target paragraph.
doc.toc.unmarkEntrytoc unmark-entryRemove a TC (table of contents entry) field from the document.
doc.toc.listEntriestoc list-entriesList all TC (table of contents entry) fields in the document body.
doc.toc.getEntrytoc get-entryRetrieve details of a specific TC (table of contents entry) field.
doc.toc.editEntrytoc edit-entryUpdate the properties of a TC (table of contents entry) field.

Images

OperationCLI commandDescription
doc.images.listimages listList all images in the document.
doc.images.getimages getGet details for a specific image by its stable ID.
doc.images.deleteimages deleteDelete an image from the document.
doc.images.moveimages moveMove an image to a new location in the document.
doc.images.convertToInlineimages convert-to-inlineConvert a floating image to inline placement.
doc.images.convertToFloatingimages convert-to-floatingConvert an inline image to floating placement.
doc.images.setSizeimages set-sizeSet explicit width/height for an image.
doc.images.setWrapTypeimages set-wrap-typeSet the text wrapping type for a floating image.
doc.images.setWrapSideimages set-wrap-sideSet which side(s) text wraps around a floating image.
doc.images.setWrapDistancesimages set-wrap-distancesSet the text-wrap distance margins for a floating image.
doc.images.setPositionimages set-positionSet the anchor position for a floating image.
doc.images.setAnchorOptionsimages set-anchor-optionsSet anchor behavior options for a floating image.
doc.images.setZOrderimages set-z-orderSet the z-order (relativeHeight) for a floating image.
doc.images.scaleimages scaleScale an image by a uniform factor applied to both dimensions.
doc.images.setLockAspectRatioimages set-lock-aspect-ratioLock or unlock the aspect ratio for an image.
doc.images.rotateimages rotateSet the absolute rotation angle for an image.
doc.images.flipimages flipSet horizontal and/or vertical flip state for an image.
doc.images.cropimages cropApply rectangular edge-percentage crop to an image.
doc.images.resetCropimages reset-cropRemove all cropping from an image.
doc.images.replaceSourceimages replace-sourceReplace the image source while preserving identity and placement.
doc.images.setAltTextimages set-alt-textSet the accessibility description (alt text) for an image.
doc.images.setDecorativeimages set-decorativeMark or unmark an image as decorative.
doc.images.setNameimages set-nameSet the object name for an image.
doc.images.setHyperlinkimages set-hyperlinkSet or remove the hyperlink attached to an image.
doc.images.insertCaptionimages insert-captionInsert a caption paragraph below the image.
doc.images.updateCaptionimages update-captionUpdate the text of an existing caption paragraph.
doc.images.removeCaptionimages remove-captionRemove the caption paragraph from below the image.

Comments

OperationCLI commandDescription
doc.comments.createcomments createCreate a new comment thread (or reply when parentCommentId is given).
doc.comments.patchcomments patchPatch fields on an existing comment (text, target, status, or isInternal).
doc.comments.deletecomments deleteRemove a comment or reply by ID.
doc.comments.getcomments getRetrieve a single comment thread by ID.
doc.comments.listcomments listList all comment threads in the document.

Track changes

OperationCLI commandDescription
doc.trackChanges.listtrack-changes listList all tracked changes in the document.
doc.trackChanges.gettrack-changes getRetrieve a single tracked change by ID.
doc.trackChanges.decidetrack-changes decideAccept or reject a tracked change (by ID or scope: all).

History

OperationCLI commandDescription
doc.history.gethistory getQuery the current undo/redo history state of the active editor.
doc.history.undohistory undoUndo the most recent history-safe mutation in the active editor.
doc.history.redohistory redoRedo the most recently undone action in the active editor.

Session

OperationCLI commandDescription
doc.openopenOpen a document and create a persistent editing session. Optionally override the document body with contentOverride + overrideType (markdown, html, or text).
doc.savesaveSave the current session to the original file or a new path.
doc.closecloseClose the active editing session and clean up resources.
doc.statusstatusShow the current session status and document metadata.
doc.describedescribeList all available CLI operations and contract metadata.
doc.describeCommanddescribe commandShow detailed metadata for a single CLI operation.
doc.session.listsession listList all active editing sessions.
doc.session.savesession savePersist the current session state.
doc.session.closesession closeClose a specific editing session by ID.
doc.session.setDefaultsession set-defaultSet the default session for subsequent commands.
  • Document API — the in-browser API that defines the operation set
  • CLI — use the same operations from the terminal
  • Collaboration guides — set up Liveblocks, Hocuspocus, or SuperDoc Yjs