Skip to content

Latest commit

 

History

History
1544 lines (1392 loc) · 131 KB

File metadata and controls

1544 lines (1392 loc) · 131 KB
title SDKs
sidebarTitle Overview
description Node.js and Python SDKs for programmatic document editing
keywords sdk, node, python, document automation, headless docx, superdoc sdk

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.

Installation

```bash npm install @superdoc-dev/sdk ``` ```bash pip install superdoc-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');
```typescript import { SuperDocClient } from '@superdoc-dev/sdk';
const client = new SuperDocClient({
  defaultChangeMode: 'tracked',
});

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

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

const ref = match.items?.[0]?.handle?.ref;
if (ref) {
  await 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 doc.save();
await doc.close();
```
```javascript const { SuperDocClient } = require('@superdoc-dev/sdk');
async function main() {
  const client = new SuperDocClient({
    defaultChangeMode: 'tracked',
  });

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

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

  const ref = match.items?.[0]?.handle?.ref;
  if (ref) {
    await 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 doc.save();
  await doc.close();
}

main();
```
```python import asyncio
from superdoc import AsyncSuperDocClient


async def main():
    async with AsyncSuperDocClient(default_change_mode="tracked") as client:
        # Open a document
        doc = await client.open({"doc": "./contract.docx"})

        # Find and replace text with query + mutation plan
        match = await doc.query.match(
            {
                "select": {"type": "text", "pattern": "ACME Corp"},
                "require": "first",
            }
        )

        items = match.get("items") or []
        first_item = items[0] if items else {}
        ref = first_item.get("handle", {}).get("ref")
        if ref:
            await doc.mutations.apply(
                {
                    "expectedRevision": match["evaluatedRevision"],
                    "atomic": True,
                    "steps": [
                        {
                            "id": "replace-acme",
                            "op": "text.rewrite",
                            "where": {"by": "ref", "ref": ref},
                            "args": {"replacement": {"text": "NewCo Inc."}},
                        }
                    ],
                }
            )

        # Save and close
        await doc.save({"inPlace": True})
        await doc.close({})


asyncio.run(main())
```

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 document-handle methods when you prefer non-async code paths.

Need file-to-file diffing?

For workflows where you already have Doc1 and need to compare an uploaded Doc2, see Compare documents: a Document Engine workflow that wraps diff.capture, diff.compare, and diff.apply into a recommended file-to-file flow.

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:

```typescript const client = new SuperDocClient({ user: { name: 'Review Bot', email: 'bot@example.com' }, }); ``` ```python client = AsyncSuperDocClient(user={"name": "Review Bot", "email": "bot@example.com"}) ```

The user is injected into every client.open call. If you pass userName or userEmail on a specific client.open, those per-call values take precedence.

Collaboration sessions

Use this when your app already has a live collaboration room. The SDK supports three providers:

Provider When to use Config path Auth model
y-websocket Self-hosted, simple setup collabUrl shorthand or explicit collaboration object Token via env var
hocuspocus Hocuspocus server, richer protocol Explicit collaboration object only Token via env var
liveblocks Managed service, no server to run Explicit collaboration object only Public key or auth endpoint

Join an existing room (y-websocket shorthand)

Pass collabUrl and collabDocumentId to client.open:

The `collabUrl` + `collabDocumentId` shorthand defaults to the `y-websocket` provider. For Hocuspocus or Liveblocks, pass an explicit `collaboration` object. ```typescript import { SuperDocClient } from '@superdoc-dev/sdk';
const client = new SuperDocClient();
await client.connect();

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

await doc.insert({
  target: { type: 'end' },
  content: 'Added by the SDK',
});
```
```python import asyncio
from superdoc import AsyncSuperDocClient


async def main():
    async with AsyncSuperDocClient() as client:
        doc = await client.open({
            "collabUrl": "ws://localhost:4000",
            "collabDocumentId": "my-doc-room",
        })

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


asyncio.run(main())
```

Connect to Hocuspocus explicitly

Use the explicit collaboration object when your server speaks the Hocuspocus protocol:

```typescript const doc = await client.open({ collaboration: { providerType: 'hocuspocus', url: 'ws://localhost:1234', documentId: 'my-doc-room', }, }); ``` ```python doc = await client.open({ "collaboration": { "providerType": "hocuspocus", "url": "ws://localhost:1234", "documentId": "my-doc-room", } }) ```

Forward custom WebSocket query parameters

Attach arbitrary key-value pairs to the WebSocket connection URL with the params field. Use this when your collaboration server expects per-connection metadata (activity tracking, tenant identifiers, feature flags, etc.) that shouldn't live in the document ID.

```typescript const doc = await client.open({ collaboration: { providerType: 'y-websocket', url: 'wss://collab.example.com/ws', documentId: 'asset_abc', tokenEnv: 'SUPERDOC_COLLAB_TOKEN', params: { customAttributions: 'agent_id:abc,session_id:def,user_id:ghi', region: 'us-east-1', }, }, }); ``` ```python doc = await client.open({ "collaboration": { "providerType": "y-websocket", "url": "wss://collab.example.com/ws", "documentId": "asset_abc", "tokenEnv": "SUPERDOC_COLLAB_TOKEN", "params": { "customAttributions": "agent_id:abc,session_id:def,user_id:ghi", "region": "us-east-1", }, } }) ```

Keys and values must both be strings: query parameters serialize as strings on the URL. The field is supported for y-websocket and hocuspocus; Liveblocks manages its transport differently and does not accept this field.

`token` is reserved: the CLI sets it automatically from `tokenEnv`. Passing `token` inside `params` is a validation error; use `tokenEnv` for authentication.

Connect to Liveblocks

Liveblocks is configured through an explicit collaboration object. Two auth modes are supported:

Public API key

```typescript const doc = await client.open({ collaboration: { providerType: 'liveblocks', roomId: 'my-room', publicApiKey: 'pk_live_xxx', }, }); ``` ```python doc = await client.open({ "collaboration": { "providerType": "liveblocks", "roomId": "my-room", "publicApiKey": "pk_live_xxx", } }) ```

Auth endpoint

For production use, point to your auth endpoint instead:

```typescript const doc = await client.open({ collaboration: { providerType: 'liveblocks', roomId: 'my-room', authEndpoint: 'https://app.example.com/api/liveblocks-auth', }, }); ``` ```python doc = await client.open({ "collaboration": { "providerType": "liveblocks", "roomId": "my-room", "authEndpoint": "https://app.example.com/api/liveblocks-auth", } }) ``` Unlike browser usage, SDK `authEndpoint` values must be absolute URLs (starting with `http://` or `https://`). Relative paths like `/api/liveblocks-auth` are not supported because the CLI host has no browser origin to resolve them against.

To pass custom headers to your auth endpoint, set authHeadersEnv to the name of an environment variable containing a JSON object of headers:

```typescript // Pass the env var through the SDK client const client = new SuperDocClient({ env: { MY_AUTH_HEADERS: '{"Authorization":"Bearer service-token"}' }, });
const doc = await client.open({
  collaboration: {
    providerType: 'liveblocks',
    roomId: 'my-room',
    authEndpoint: 'https://app.example.com/api/liveblocks-auth',
    authHeadersEnv: 'MY_AUTH_HEADERS',
  },
});
```
```python client = AsyncSuperDocClient( env={"MY_AUTH_HEADERS": '{"Authorization":"Bearer service-token"}'}, )
doc = await client.open({
    "collaboration": {
        "providerType": "liveblocks",
        "roomId": "my-room",
        "authEndpoint": "https://app.example.com/api/liveblocks-auth",
        "authHeadersEnv": "MY_AUTH_HEADERS",
    }
})
```
Environment variables referenced by `authHeadersEnv` (Liveblocks) and `tokenEnv` (websocket providers) are resolved inside the CLI host process, not in your application code. If the variable is not already in your shell environment, pass it through the SDK client's `env` option as shown above.

Liveblocks input uses roomId. The response normalizes this to documentId:

  • Input: collaboration.roomId
  • Output: openResult.collaboration.documentId

Start an empty room from a local .docx

If the room is empty, pass doc together with collaboration params:

```typescript const doc = await client.open({ doc: './starting-template.docx', collabUrl: 'ws://localhost:4000', collabDocumentId: 'my-doc-room', }); ``` ```python doc = await client.open({ "doc": "./starting-template.docx", "collabUrl": "ws://localhost:4000", "collabDocumentId": "my-doc-room", }) ```

What happens when you pass doc:

Room state Result
Room already has content SDK joins the room. doc is ignored.
Room is empty and doc is provided SDK seeds the room from doc, then joins.
Room is empty and no doc is provided SDK starts a blank document.

Control empty-room behavior

Parameter Type Default Description
collabUrl string none WebSocket URL. Shorthand for y-websocket only.
collabDocumentId string session ID Room/document ID on the provider.
doc string none Local .docx used only when the room is empty.
onMissing string seedFromDoc seedFromDoc, blank, or error.
bootstrapSettlingMs number 1500 Wait time (ms) before seeding to avoid race conditions.

The three onMissing values:

Value When the room is empty Use when
seedFromDoc (default) Seeds from doc if provided, otherwise seeds a blank document. First-time opens where you provide a .docx template.
blank Always seeds a blank document. You want an empty starting document regardless of doc.
error Throws 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. ```typescript // Safe reopen: throws if the room is unexpectedly empty const doc = await client.open({ collabUrl: 'ws://localhost:4000', collabDocumentId: 'my-doc-room', onMissing: 'error', }); ``` ```python # Safe reopen: throws if the room is unexpectedly empty doc = await client.open({ "collabUrl": "ws://localhost:4000", "collabDocumentId": "my-doc-room", "onMissing": "error", }) ```

Check if the SDK seeded or joined

client.open returns a bound document handle. In collaboration mode, bootstrap details are available on the handle's initial open result:

```typescript const doc = await client.open({ doc: './starting-template.docx', collabUrl: 'ws://localhost:4000', collabDocumentId: 'my-doc-room', });
console.log(doc.openResult.bootstrap);
// { roomState, bootstrapApplied, bootstrapSource }
```
```python doc = await client.open({ "doc": "./starting-template.docx", "collabUrl": "ws://localhost:4000", "collabDocumentId": "my-doc-room", })
print(doc.open_result.get("bootstrap"))
```

{/* SDK_OPERATIONS_START */}

Available operations

The SDKs expose all operations from the Document API plus lifecycle and client commands. client.open() returns a bound document handle: all document operations run on that handle.

Core

Operation CLI command Description
doc.get get Read the full document as an SDDocument structure.
doc.find find Search the document for text or node matches using SDM/1 selectors. Returns discovery-grade results: for mutation targeting, use query.match instead.
doc.getNode get-node Retrieve a single node by target position.
doc.getNodeById get-node-by-id Retrieve a single node by its unique ID.
doc.getText get-text Extract the plain-text content of the document.
doc.getMarkdown get-markdown Extract the document content as a Markdown string.
doc.getHtml get-html Extract the document content as an HTML string.
doc.markdownToFragment markdown-to-fragment Convert a Markdown string into an SDM/1 structural fragment.
doc.info info Return document summary info including word, character, paragraph, heading, table, image, comment, tracked-change, SDT-field, list, and page counts, plus outline and capabilities.
doc.extract extract Extract all document content with stable IDs for RAG pipelines. Returns blocks with full text, comments, and tracked changes: each with an ID compatible with scrollToElement().
doc.clearContent clear-content Clear all document body content, leaving a single empty paragraph.
doc.insert insert Insert content into the document. Two input shapes: text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target/ref is omitted, content appends at the end of the document. Text mode supports text (default), markdown, and html content types via the type field. Structural mode uses placement (before/after/insideStart/insideEnd) to position relative to the target block.
doc.replace replace Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.
doc.delete delete Delete content at a contiguous document selection. Accepts a SelectionTarget or mutation-ready ref. Supports cross-block deletion and optional block-edge expansion via behavior mode.
doc.blocks.list blocks list List top-level blocks in document order with IDs, types, text previews, and optional full text when includeText:true. Supports pagination via offset/limit and optional nodeType filtering.
doc.blocks.delete blocks delete Delete an entire block node (paragraph, heading, list item, table, image, or sdt) deterministically.
doc.blocks.deleteRange blocks delete-range Delete a contiguous range of top-level blocks between two endpoints (inclusive). Both endpoints must be direct children of the document node. Supports dry-run preview.
doc.templates.apply templates apply Apply detected DOCX template/substrate (styles, numbering, settings, theme, font table, web settings, headers/footers, section defaults) from a source package onto the current document, preserving body content. Scopes are auto-detected from source package evidence.
doc.query.match query match Deterministic selector-based search returning mutation-grade addresses and text ranges. Use this to discover targets before any mutation.
doc.ranges.resolve ranges resolve Resolve two explicit anchors into a contiguous document range. Returns a transparent SelectionTarget, a mutation-ready ref, and preview metadata. Stateless and deterministic.
doc.selection.current selection current Read the editor's current selection as a portable SelectionInfo with a text-anchored TextTarget. Primitive for building custom comments UIs, floating toolbars, and other selection-driven components without reaching into ProseMirror internals.
doc.mutations.preview mutations preview Dry-run a mutation plan, returning resolved targets without applying changes.
doc.mutations.apply mutations apply Execute a mutation plan atomically against the document.
doc.capabilities.get capabilities Query runtime capabilities supported by the current document engine.
doc.hyperlinks.list hyperlinks list List all hyperlinks in the document, with optional filtering by href, anchor, or display text.
doc.hyperlinks.get hyperlinks get Retrieve details of a specific hyperlink by its inline address.
doc.hyperlinks.wrap hyperlinks wrap Wrap an existing text range with a hyperlink.
doc.hyperlinks.insert hyperlinks insert Insert new linked text at a target position.
doc.hyperlinks.patch hyperlinks patch Update hyperlink metadata (destination, tooltip, target, rel) without changing display text.
doc.hyperlinks.remove hyperlinks remove Remove a hyperlink. Mode 'unwrap' preserves display text; 'deleteText' removes the linked content entirely.
doc.headerFooters.list header-footers list List header/footer slot entries across sections.
doc.headerFooters.get header-footers get Get a single header/footer slot entry by address.
doc.headerFooters.resolve header-footers resolve Resolve the effective header/footer reference for a slot, walking the section inheritance chain.
doc.headerFooters.refs.set header-footers refs set Set an explicit header/footer reference on a section slot.
doc.headerFooters.refs.clear header-footers refs clear Clear an explicit header/footer reference from a section slot.
doc.headerFooters.refs.setLinkedToPrevious header-footers refs set-linked-to-previous Link or unlink a header/footer slot to/from the previous section.
doc.headerFooters.parts.list header-footers parts list List unique header/footer part records from document relationships.
doc.headerFooters.parts.create header-footers parts create Create a new independent header/footer part, optionally cloned from an existing part.
doc.headerFooters.parts.delete header-footers parts delete Delete a header/footer part and its associated relationship when no section slots reference it.
doc.create.contentControl create content-control Create a new content control (SDT) in the document.
doc.contentControls.list content-controls list List all content controls in the document with optional type/tag filtering.
doc.contentControls.get content-controls get Retrieve a single content control by target.
doc.contentControls.listInRange content-controls list-in-range List content controls within a block range.
doc.contentControls.selectByTag content-controls select-by-tag Select content controls matching a specific tag value.
doc.contentControls.selectByTitle content-controls select-by-title Select content controls matching a specific title (alias) value.
doc.contentControls.listChildren content-controls list-children List direct child content controls nested inside the target.
doc.contentControls.getParent content-controls get-parent Get the parent content control of the target, if any.
doc.contentControls.wrap content-controls wrap Wrap existing content with a new content control.
doc.contentControls.unwrap content-controls unwrap Remove the content control wrapper, preserving its content in place.
doc.contentControls.delete content-controls delete Delete a content control and its content from the document.
doc.contentControls.copy content-controls copy Copy a content control to a destination position. Copied SDTs receive new IDs.
doc.contentControls.move content-controls move Move a content control to a new position. Preserves original IDs.
doc.contentControls.patch content-controls patch Patch metadata properties on a content control (tag, alias, appearance, color, etc.).
doc.contentControls.setLockMode content-controls set-lock-mode Set the lock mode on a content control.
doc.contentControls.setType content-controls set-type Transition a content control to a different semantic type. Metadata-only; no implicit content rewrite.
doc.contentControls.getContent content-controls get-content Get the text content of a content control.
doc.contentControls.replaceContent content-controls replace-content Replace the entire content of a content control.
doc.contentControls.clearContent content-controls clear-content Clear all content inside a content control, leaving it empty.
doc.contentControls.appendContent content-controls append-content Append content to the end of a content control.
doc.contentControls.prependContent content-controls prepend-content Prepend content to the beginning of a content control.
doc.contentControls.insertBefore content-controls insert-before Insert content immediately before a content control.
doc.contentControls.insertAfter content-controls insert-after Insert content immediately after a content control.
doc.contentControls.getBinding content-controls get-binding Get the data binding metadata (w:dataBinding) of a content control.
doc.contentControls.setBinding content-controls set-binding Set data binding metadata on a content control.
doc.contentControls.clearBinding content-controls clear-binding Remove data binding metadata from a content control.
doc.contentControls.getRawProperties content-controls get-raw-properties Get the raw sdtPr properties of a content control as a passthrough hash.
doc.contentControls.patchRawProperties content-controls patch-raw-properties Apply raw XML-level patches to the sdtPr subtree of a content control.
doc.contentControls.validateWordCompatibility content-controls validate-word-compatibility Validate a content control for Word compatibility issues.
doc.contentControls.normalizeWordCompatibility content-controls normalize-word-compatibility Normalize a content control to resolve Word compatibility issues.
doc.contentControls.normalizeTagPayload content-controls normalize-tag-payload Normalize a content control tag between plain-string and JSON-encoded formats.
doc.contentControls.text.setMultiline content-controls text set-multiline Set or clear the multiline attribute on a plain-text content control.
doc.contentControls.text.setValue content-controls text set-value Set the text value of a plain-text content control.
doc.contentControls.text.clearValue content-controls text clear-value Clear the text value of a plain-text content control.
doc.contentControls.date.setValue content-controls date set-value Set the date value of a date content control.
doc.contentControls.date.clearValue content-controls date clear-value Clear the date value of a date content control.
doc.contentControls.date.setDisplayFormat content-controls date set-display-format Set the display format string for a date content control.
doc.contentControls.date.setDisplayLocale content-controls date set-display-locale Set the display locale for a date content control.
doc.contentControls.date.setStorageFormat content-controls date set-storage-format Set the XML storage format for a date content control.
doc.contentControls.date.setCalendar content-controls date set-calendar Set the calendar type for a date content control.
doc.contentControls.checkbox.getState content-controls checkbox get-state Get the checked state of a checkbox content control.
doc.contentControls.checkbox.setState content-controls checkbox set-state Set the checked state of a checkbox content control.
doc.contentControls.checkbox.toggle content-controls checkbox toggle Toggle the checked state of a checkbox content control.
doc.contentControls.checkbox.setSymbolPair content-controls checkbox set-symbol-pair Set the checked and unchecked symbol glyphs for a checkbox content control.
doc.contentControls.choiceList.getItems content-controls choice-list get-items Get the list items and selected value of a comboBox or dropDownList content control.
doc.contentControls.choiceList.setItems content-controls choice-list set-items Replace the list items of a comboBox or dropDownList content control.
doc.contentControls.choiceList.setSelected content-controls choice-list set-selected Set the selected value of a comboBox or dropDownList content control.
doc.contentControls.repeatingSection.listItems content-controls repeating-section list-items List the repeating section items inside a repeating section content control.
doc.contentControls.repeatingSection.insertItemBefore content-controls repeating-section insert-item-before Insert a new item before a specific index in a repeating section.
doc.contentControls.repeatingSection.insertItemAfter content-controls repeating-section insert-item-after Insert a new item after a specific index in a repeating section.
doc.contentControls.repeatingSection.cloneItem content-controls repeating-section clone-item Clone a repeating section item at the given index. Cloned SDTs receive new IDs.
doc.contentControls.repeatingSection.deleteItem content-controls repeating-section delete-item Delete a repeating section item at the given index.
doc.contentControls.repeatingSection.setAllowInsertDelete content-controls repeating-section set-allow-insert-delete Set the allowInsertDelete flag on a repeating section.
doc.contentControls.group.wrap content-controls group wrap Wrap a content control inside a new group content control. Always nests; not idempotent.
doc.contentControls.group.ungroup content-controls group ungroup Remove the group designation from a group content control.
doc.bookmarks.list bookmarks list List all bookmarks in the document.
doc.bookmarks.get bookmarks get Get detailed information about a specific bookmark.
doc.bookmarks.insert bookmarks insert Insert a new named bookmark at a target location.
doc.bookmarks.rename bookmarks rename Rename an existing bookmark.
doc.bookmarks.remove bookmarks remove Remove a bookmark from the document.
doc.footnotes.list footnotes list List all footnotes and endnotes in the document.
doc.footnotes.get footnotes get Get detailed information about a specific footnote or endnote.
doc.footnotes.insert footnotes insert Insert a new footnote or endnote at a target location.
doc.footnotes.update footnotes update Update the content of an existing footnote or endnote.
doc.footnotes.remove footnotes remove Remove a footnote or endnote from the document.
doc.footnotes.configure footnotes configure Configure numbering and placement for footnotes or endnotes.
doc.crossRefs.list cross-refs list List all cross-reference fields in the document.
doc.crossRefs.get cross-refs get Get detailed information about a specific cross-reference field.
doc.crossRefs.insert cross-refs insert Insert a new cross-reference field at a target location.
doc.crossRefs.rebuild cross-refs rebuild Rebuild (recalculate) a cross-reference field.
doc.crossRefs.remove cross-refs remove Remove a cross-reference field from the document.
doc.index.list index list List all index blocks in the document.
doc.index.get index get Get detailed information about a specific index block.
doc.index.insert index insert Insert a new index block at a target location.
doc.index.configure index configure Update the configuration of an existing index block.
doc.index.rebuild index rebuild Rebuild (regenerate) an index block from its entries.
doc.index.remove index remove Remove an index block from the document.
doc.index.entries.list index entries list List all XE (index entry) fields in the document.
doc.index.entries.get index entries get Get detailed information about a specific XE index entry.
doc.index.entries.insert index entries insert Insert a new XE index entry field at a target location.
doc.index.entries.update index entries update Update the properties of an existing XE index entry.
doc.index.entries.remove index entries remove Remove an XE index entry field from the document.
doc.captions.list captions list List all caption paragraphs in the document.
doc.captions.get captions get Get detailed information about a specific caption paragraph.
doc.captions.insert captions insert Insert a new caption paragraph adjacent to a target block.
doc.captions.update captions update Update the text of an existing caption paragraph.
doc.captions.remove captions remove Remove a caption paragraph from the document.
doc.captions.configure captions configure Configure numbering format for a caption label.
doc.fields.list fields list List all fields in the document.
doc.fields.get fields get Get detailed information about a specific field.
doc.fields.insert fields insert Insert a raw field code at a target location.
doc.fields.rebuild fields rebuild Rebuild (recalculate) a field.
doc.fields.remove fields remove Remove a field from the document.
doc.citations.list citations list List all citation marks in the document.
doc.citations.get citations get Get detailed information about a specific citation mark.
doc.citations.insert citations insert Insert a new citation mark at a target location.
doc.citations.update citations update Update an existing citation mark's source references.
doc.citations.remove citations remove Remove a citation mark from the document.
doc.citations.sources.list citations sources list List all citation sources in the document store.
doc.citations.sources.get citations sources get Get detailed information about a specific citation source.
doc.citations.sources.insert citations sources insert Register a new citation source in the document store.
doc.citations.sources.update citations sources update Update the fields of an existing citation source.
doc.citations.sources.remove citations sources remove Remove a citation source from the document store.
doc.citations.bibliography.get citations bibliography get Get information about the bibliography block.
doc.citations.bibliography.insert citations bibliography insert Insert a bibliography block at a target location.
doc.citations.bibliography.rebuild citations bibliography rebuild Rebuild the bibliography from current sources.
doc.citations.bibliography.configure citations bibliography configure Configure the bibliography style.
doc.citations.bibliography.remove citations bibliography remove Remove the bibliography block from the document.
doc.authorities.list authorities list List all table-of-authorities blocks in the document.
doc.authorities.get authorities get Get detailed information about a specific table-of-authorities block.
doc.authorities.insert authorities insert Insert a new table-of-authorities block at a target location.
doc.authorities.configure authorities configure Update the configuration of an existing table-of-authorities block.
doc.authorities.rebuild authorities rebuild Rebuild a table-of-authorities block from its entries.
doc.authorities.remove authorities remove Remove a table-of-authorities block from the document.
doc.authorities.entries.list authorities entries list List all TA (authority entry) fields in the document.
doc.authorities.entries.get authorities entries get Get detailed information about a specific TA authority entry.
doc.authorities.entries.insert authorities entries insert Insert a new TA authority entry field at a target location.
doc.authorities.entries.update authorities entries update Update the properties of an existing TA authority entry.
doc.authorities.entries.remove authorities entries remove Remove a TA authority entry field from the document.
doc.diff.capture diff capture Capture the current document's diffable state as a versioned snapshot. v1 covers body, comments, styles, and numbering. Header/footer content is not included.
doc.diff.compare diff compare Compare the current document (base) against a previously captured target snapshot. Returns a versioned diff payload describing the changes from base to target.
doc.diff.apply diff apply Apply a previously computed diff payload to the current document. The document fingerprint must match the diff base fingerprint. Tracked mode governs body content only; styles, numbering, and comments are always applied directly.
doc.protection.get protection get Read the current document protection state including editing restrictions, write protection, and read-only recommendation.
doc.protection.setEditingRestriction protection set-editing-restriction Enable Word-style editing restriction on the document. Only readOnly mode is supported in v1.
doc.protection.clearEditingRestriction protection clear-editing-restriction Disable document-level editing restriction by setting enforcement to off. Preserves the protection element and its metadata for round-trip fidelity.
doc.permissionRanges.list permission-ranges list List all permission ranges in the document. Returns only complete paired ranges (both start and end markers present).
doc.permissionRanges.get permission-ranges get Get detailed information about a specific permission range by ID.
doc.permissionRanges.create permission-ranges create Create a permission range exception region in the document. Inserts matched permStart/permEnd markers at the target.
doc.permissionRanges.remove permission-ranges remove Remove a permission range by ID. Removes whichever markers exist for the given ID (start, end, or both).
doc.permissionRanges.updatePrincipal permission-ranges update-principal Change which principal is allowed to edit a permission range. Updates the principal fields on the start marker.
doc.customXml.parts.list custom-xml parts list List Custom XML Data Storage Parts in the document, optionally filtered by root namespace or schema reference.
doc.customXml.parts.get custom-xml parts get Get a single Custom XML Data Storage Part by itemID or package part name, including its full content. v1 partName targeting is limited to Word-style customXml/itemN.xml paths.
doc.customXml.parts.create custom-xml parts create Add a new Custom XML Data Storage Part to the document. Generates a fresh itemID GUID and emits the Properties Part.
doc.customXml.parts.patch custom-xml parts patch Replace the content and/or schemaRefs of an existing Custom XML Data Storage Part. At least one of content or schemaRefs is required. v1 partName targeting is limited to Word-style customXml/itemN.xml paths.
doc.customXml.parts.remove custom-xml parts remove Remove a Custom XML Data Storage Part and clean up all linked package files (item, props, rels, content-types entry). v1 partName targeting is limited to Word-style customXml/itemN.xml paths.
doc.metadata.attach metadata attach Anchor a JSON metadata payload to a span of text. Wraps the target range in a hidden inline content control whose w:tag carries a stable id, and stores the payload in a namespaced Custom XML Data Storage Part. v1 supports text-range anchors only.
doc.metadata.list metadata list List anchored-metadata entries in the document, optionally filtered by consumer namespace and/or a within selection (returns only entries whose anchor overlaps within).
doc.metadata.get metadata get Get a single anchored-metadata entry by id, including its JSON payload.
doc.metadata.update metadata update Replace the JSON payload of an existing anchored-metadata entry. Replace semantics; no merge. The anchor is left untouched.
doc.metadata.remove metadata remove Remove an anchored-metadata entry. Strips the anchor content-control wrapper (its content stays in the document) and deletes the payload entry from the Storage Part. In v1 these writes are sequenced, not transactional: the adapter resolves the target up-front so missing-target failures land before any state change, but a crash strictly between the two writes can leave a dangling payload. When the backing part has no remaining entries, the part itself is removed.
doc.metadata.resolve metadata resolve Find where an anchored-metadata entry is anchored in the document. Returns the SelectionTarget covering the anchor content.
doc.insertTab insert tab Insert a real Word tab node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.
doc.insertLineBreak insert line-break Insert a real Word line-break node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.

Format

Operation CLI command Description
doc.formatRange format-range Legacy root-level alias for inline range formatting. Routes to format.apply for compatibility with older callers.
doc.format.apply format apply Apply inline run-property patch changes to the target range with explicit set/clear semantics.
doc.format.bold format bold Set or clear the bold inline run property on the target text range.
doc.format.italic format italic Set or clear the italic inline run property on the target text range.
doc.format.strike format strike Set or clear the strike inline run property on the target text range.
doc.format.underline format underline Set or clear the underline inline run property on the target text range.
doc.format.highlight format highlight Set or clear the highlight inline run property on the target text range.
doc.format.color format color Set or clear the color inline run property on the target text range.
doc.format.fontSize format font-size Set or clear the fontSize inline run property on the target text range.
doc.format.fontFamily format font-family Set or clear the fontFamily inline run property on the target text range.
doc.format.letterSpacing format letter-spacing Set or clear the letterSpacing inline run property on the target text range.
doc.format.vertAlign format vert-align Set or clear the vertAlign inline run property on the target text range.
doc.format.position format position Set or clear the position inline run property on the target text range.
doc.format.dstrike format dstrike Set or clear the dstrike inline run property on the target text range.
doc.format.smallCaps format small-caps Set or clear the smallCaps inline run property on the target text range.
doc.format.caps format caps Set or clear the caps inline run property on the target text range.
doc.format.shading format shading Set or clear the shading inline run property on the target text range.
doc.format.border format border Set or clear the border inline run property on the target text range.
doc.format.outline format outline Set or clear the outline inline run property on the target text range.
doc.format.shadow format shadow Set or clear the shadow inline run property on the target text range.
doc.format.emboss format emboss Set or clear the emboss inline run property on the target text range.
doc.format.imprint format imprint Set or clear the imprint inline run property on the target text range.
doc.format.charScale format char-scale Set or clear the charScale inline run property on the target text range.
doc.format.kerning format kerning Set or clear the kerning inline run property on the target text range.
doc.format.vanish format vanish Set or clear the vanish inline run property on the target text range.
doc.format.webHidden format web-hidden Set or clear the webHidden inline run property on the target text range.
doc.format.specVanish format spec-vanish Set or clear the specVanish inline run property on the target text range.
doc.format.rtl format rtl Set or clear the rtl inline run property on the target text range. This does not change paragraph direction; use format.paragraph.setDirection for paragraph-level RTL.
doc.format.cs format cs Set or clear the cs inline run property on the target text range.
doc.format.bCs format b-cs Set or clear the bCs inline run property on the target text range.
doc.format.iCs format i-cs Set or clear the iCs inline run property on the target text range.
doc.format.eastAsianLayout format east-asian-layout Set or clear the eastAsianLayout inline run property on the target text range.
doc.format.em format em Set or clear the em inline run property on the target text range.
doc.format.fitText format fit-text Set or clear the fitText inline run property on the target text range.
doc.format.snapToGrid format snap-to-grid Set or clear the snapToGrid inline run property on the target text range.
doc.format.lang format lang Set or clear the lang inline run property on the target text range.
doc.format.oMath format o-math Set or clear the oMath inline run property on the target text range.
doc.format.rStyle format r-style Set or clear the rStyle inline run property on the target text range.
doc.format.rFonts format r-fonts Set or clear the rFonts inline run property on the target text range.
doc.format.fontSizeCs format font-size-cs Set or clear the fontSizeCs inline run property on the target text range.
doc.format.ligatures format ligatures Set or clear the ligatures inline run property on the target text range.
doc.format.numForm format num-form Set or clear the numForm inline run property on the target text range.
doc.format.numSpacing format num-spacing Set or clear the numSpacing inline run property on the target text range.
doc.format.stylisticSets format stylistic-sets Set or clear the stylisticSets inline run property on the target text range.
doc.format.contextualAlternates format contextual-alternates Set or clear the contextualAlternates inline run property on the target text range.
doc.styles.apply styles apply Apply 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.setStyle styles paragraph set-style Apply a paragraph style (w:pStyle) to a paragraph-like block, clearing direct run formatting while preserving character-style references.
doc.styles.paragraph.clearStyle styles paragraph clear-style Remove the paragraph style reference from a paragraph-like block.
doc.format.paragraph.resetDirectFormatting format paragraph reset-direct-formatting Strip all direct paragraph formatting while preserving style reference, numbering, and section metadata.
doc.format.paragraph.setAlignment format paragraph set-alignment Set visual paragraph alignment on a paragraph-like block. For RTL paragraphs, left/right are translated to Word-compatible stored justification values.
doc.format.paragraph.clearAlignment format paragraph clear-alignment Remove direct paragraph alignment, reverting to style-defined or default alignment.
doc.format.paragraph.setIndentation format paragraph set-indentation Set paragraph indentation properties (left, right, firstLine, hanging) in twips.
doc.format.paragraph.clearIndentation format paragraph clear-indentation Remove all direct paragraph indentation.
doc.format.paragraph.setSpacing format paragraph set-spacing Set paragraph spacing properties (before, after, line, lineRule) in twips.
doc.format.paragraph.clearSpacing format paragraph clear-spacing Remove all direct paragraph spacing.
doc.format.paragraph.setKeepOptions format paragraph set-keep-options Set keep-with-next, keep-lines-together, and widow/orphan control flags.
doc.format.paragraph.setOutlineLevel format paragraph set-outline-level Set the paragraph outline level (0–9) or null to clear.
doc.format.paragraph.setFlowOptions format paragraph set-flow-options Set contextual spacing, page-break-before, and suppress-auto-hyphens flags.
doc.format.paragraph.setTabStop format paragraph set-tab-stop Add or replace a tab stop at a given position.
doc.format.paragraph.clearTabStop format paragraph clear-tab-stop Remove a tab stop at a given position.
doc.format.paragraph.clearAllTabStops format paragraph clear-all-tab-stops Remove all tab stops from a paragraph.
doc.format.paragraph.setBorder format paragraph set-border Set border properties for a specific side of a paragraph.
doc.format.paragraph.clearBorder format paragraph clear-border Remove border for a specific side or all sides of a paragraph.
doc.format.paragraph.setShading format paragraph set-shading Set paragraph shading (background fill, pattern color, pattern type).
doc.format.paragraph.clearShading format paragraph clear-shading Remove all paragraph shading.
doc.format.paragraph.setDirection format paragraph set-direction Set paragraph base direction (LTR or RTL via w:bidi). Optionally align text to match.
doc.format.paragraph.clearDirection format paragraph clear-direction Remove explicit paragraph direction, reverting to inherited or default (LTR).

Create

Operation CLI command Description
doc.create.paragraph create paragraph Create a standalone paragraph at the target position. To add a list item, use lists.insert instead.
doc.create.heading create heading Create a new heading at the target position.
doc.create.sectionBreak create section-break Create a section break at the target location with optional initial section properties.
doc.create.table create table Create a new table at the target position.
doc.create.tableOfContents create table-of-contents Insert a new table of contents at the target position.
doc.create.image create image Insert a new image at the target position.

Sections

Operation CLI command Description
doc.sections.list sections list List sections in deterministic order with section-target handles.
doc.sections.get sections get Retrieve full section information by section address.
doc.sections.setBreakType sections set-break-type Set the section break type.
doc.sections.setPageMargins sections set-page-margins Set page-edge margins for a section.
doc.sections.setHeaderFooterMargins sections set-header-footer-margins Set header/footer margin distances for a section.
doc.sections.setPageSetup sections set-page-setup Set page size/orientation properties for a section.
doc.sections.setColumns sections set-columns Set column configuration for a section.
doc.sections.setLineNumbering sections set-line-numbering Enable or configure line numbering for a section.
doc.sections.setPageNumbering sections set-page-numbering Set page numbering format/start and chapter numbering settings for a section.
doc.sections.setTitlePage sections set-title-page Enable or disable title-page behavior for a section.
doc.sections.setOddEvenHeadersFooters sections set-odd-even-headers-footers Enable or disable odd/even header-footer mode in document settings.
doc.sections.setVerticalAlign sections set-vertical-align Set vertical page alignment for a section.
doc.sections.setSectionDirection sections set-section-direction Set section text flow direction (LTR/RTL).
doc.sections.setHeaderFooterRef sections set-header-footer-ref Set or replace a section header/footer reference for a variant.
doc.sections.clearHeaderFooterRef sections clear-header-footer-ref Clear a section header/footer reference for a specific variant.
doc.sections.setLinkToPrevious sections set-link-to-previous Set or clear link-to-previous behavior for a header/footer variant.
doc.sections.setPageBorders sections set-page-borders Set page border configuration for a section.
doc.sections.clearPageBorders sections clear-page-borders Clear page border configuration for a section.

Lists

Operation CLI command Description
doc.lists.list lists list List all list nodes in the document, optionally filtered by scope.
doc.lists.get lists get Retrieve a specific list node by target.
doc.lists.insert lists insert Insert a new list item before or after an existing list item. The new item inherits the target list context.
doc.lists.create lists create Create a new list from one or more paragraphs. Supports optional preset or style for new sequences. When sequence.mode is "continuePrevious", preset and style are not allowed: the new items inherit formatting from the previous sequence.
doc.lists.attach lists attach Convert non-list paragraphs to list items under an existing list sequence.
doc.lists.detach lists detach Remove numbering properties from list items, converting them to plain paragraphs.
doc.lists.delete lists delete Delete the entire list that contains the targeted list item. Removes ALL items in the same numbered sequence (the contiguous run of list items sharing the target's numbering) AND their text content from the document. Pass any single list item from the list as target; the op walks adjacent siblings to find the full list. Use this for "remove the list" / "delete this list" intents and for the cleanup step of a list-to-table conversion.
doc.lists.indent lists indent Increase the indentation level of a list item.
doc.lists.outdent lists outdent Decrease the indentation level of a list item.
doc.lists.join lists join Merge two adjacent list sequences into one.
doc.lists.canJoin lists can-join Check whether two adjacent list sequences can be joined.
doc.lists.separate lists separate Split a list sequence at the target item, creating a new sequence from that point forward.
doc.lists.merge lists merge Compound: merge two adjacent list sequences into one. Reassigns numId on the absorbed sequence (no strict abstractNumId check: absorbed items adopt the absorbing definition) and deletes empty paragraphs between the two sequences. Use this instead of lists.join for the user-facing "merge these lists" intent.
doc.lists.split lists split Compound: split a list sequence at the target item into two independent sequences. Runs lists.separate then (by default) lists.setValue(1) so the new half starts numbering fresh at 1. Pass restartNumbering:false for raw separate semantics (new half continues the previous count).
doc.lists.setLevel lists set-level Set the absolute nesting level (0..8) of a list item.
doc.lists.setValue lists set-value Set an explicit numbering value at the target item. Mid-sequence targets are atomically separated first.
doc.lists.continuePrevious lists continue-previous Continue numbering from the nearest compatible previous list sequence.
doc.lists.canContinuePrevious lists can-continue-previous Check whether the target sequence can continue numbering from a previous compatible sequence.
doc.lists.setLevelRestart lists set-level-restart Set the restart behavior for a specific list level.
doc.lists.convertToText lists convert-to-text Convert list items to plain paragraphs, optionally prepending the rendered marker text.
doc.lists.applyTemplate lists apply-template Advanced alias for lists.applyStyle. Apply a captured ListTemplate to the target list (abstract-scoped, no clone-on-write).
doc.lists.applyPreset lists apply-preset Apply a built-in list formatting preset to the target list.
doc.lists.setType lists set-type Convert a list to ordered or bullet and merge adjacent compatible sequences to preserve continuous numbering.
doc.lists.captureTemplate lists capture-template Advanced alias for lists.getStyle. Capture list formatting from the abstract definition only (does not merge lvlOverride formatting).
doc.lists.setLevelNumbering lists set-level-numbering Advanced alias for lists.setLevelNumberStyle/setLevelText/setLevelStart. Set format, pattern, and start in one call (abstract-scoped, no clone-on-write).
doc.lists.setLevelBullet lists set-level-bullet Set the bullet marker text for a specific list level.
doc.lists.setLevelPictureBullet lists set-level-picture-bullet Set a picture bullet for a specific list level by its OOXML lvlPicBulletId.
doc.lists.setLevelAlignment lists set-level-alignment Set the marker alignment (left, center, right) for a specific list level.
doc.lists.setLevelIndents lists set-level-indents Set the paragraph indentation values (left, hanging, firstLine) for a specific list level.
doc.lists.setLevelTrailingCharacter lists set-level-trailing-character Set the trailing character (tab, space, nothing) after the marker for a specific list level.
doc.lists.setLevelMarkerFont lists set-level-marker-font Set the font family used for the marker character at a specific list level.
doc.lists.clearLevelOverrides lists clear-level-overrides Remove instance-level overrides for a specific list level, restoring abstract definition values.
doc.lists.getStyle lists get-style Read the effective reusable style of a list, including instance-level overrides. Returns a ListStyle that can be applied to other lists via lists.applyStyle.
doc.lists.applyStyle lists apply-style Apply a reusable list style to the target list. Sequence-local: if the abstract definition is shared with other lists, it is cloned first to avoid affecting them.
doc.lists.restartAt lists restart-at Restart numbering at the target list item with a specific value. If the item is mid-sequence, it is separated first.
doc.lists.setLevelNumberStyle lists set-level-number-style Set the numbering style (e.g. decimal, lowerLetter, upperRoman) for a specific list level. Rejects "bullet": use setLevelBullet instead. Sequence-local: clones shared definitions.
doc.lists.setLevelText lists set-level-text Set the level text pattern (e.g. "%1.", "(%1)") for a specific list level. Uses OOXML level-placeholder syntax. Sequence-local: clones shared definitions.
doc.lists.setLevelStart lists set-level-start Set the start value for a specific list level. Rejects bullet levels and non-positive values. Sequence-local: clones shared definitions.
doc.lists.setLevelLayout lists set-level-layout Set the layout properties (alignment, indentation, trailing character, tab stop) for a specific list level. Accepts partial updates: omitted fields are left unchanged. Sequence-local: clones shared definitions.

Tables

Operation CLI command Description
doc.tables.convertFromText tables convert-from-text Convert a text range into a table.
doc.tables.delete tables delete Delete the target table from the document.
doc.tables.clearContents tables clear-contents Clear the contents of the target table or cell range.
doc.tables.move tables move Move a table to a new position in the document.
doc.tables.split tables split Split a table into two tables at the target row.
doc.tables.convertToText tables convert-to-text Convert a table back to plain text.
doc.tables.setLayout tables set-layout Set the layout mode of the target table.
doc.tables.insertRow tables insert-row Insert a new row into the target table. The new row is cloned from an adjacent row, so it inherits the existing cell shading, borders, alignment, and padding. No follow-up styling call is needed unless the new row should look different from the rest of the table.
doc.tables.deleteRow tables delete-row Delete a row from the target table.
doc.tables.setRowHeight tables set-row-height Set the height of a table row.
doc.tables.distributeRows tables distribute-rows Distribute row heights evenly across the target table.
doc.tables.setRowOptions tables set-row-options Set options on a table row such as header repeat or page break.
doc.tables.insertColumn tables insert-column Insert a new column into the target table. The new column is cloned from an adjacent column, so it inherits the existing cell shading, borders, alignment, and width. No follow-up styling call is needed unless the new column should look different from the rest of the table.
doc.tables.deleteColumn tables delete-column Delete a column from the target table.
doc.tables.setColumnWidth tables set-column-width Set the width of a table column.
doc.tables.distributeColumns tables distribute-columns Distribute column widths evenly across the target table.
doc.tables.insertCell tables insert-cell Insert a new cell into a table row.
doc.tables.deleteCell tables delete-cell Delete a cell from a table row.
doc.tables.mergeCells tables merge-cells Merge a range of table cells into one.
doc.tables.unmergeCells tables unmerge-cells Unmerge a previously merged table cell.
doc.tables.splitCell tables split-cell Split a table cell into multiple cells.
doc.tables.setCellProperties tables set-cell-properties Set non-text properties on a single table cell: vertical alignment, text wrapping, fit-text, or preferred width. Requires a cell-level target (a tableCell block address with kind, nodeType, nodeId). Does NOT accept a table target with rowIndex/columnIndex. To set the text content of a cell, use action "set_cell_text" instead.
doc.tables.setCellText tables set-cell-text Replace the text content of a single table cell with plain text (one paragraph). Accepts either a direct cell locator (a tableCell block address with kind, nodeType, nodeId) OR a table target with rowIndex + columnIndex. Cell properties (vertical alignment, shading, borders, colspan/rowspan) are preserved. Use this for filling cells with values, replacing cell text, or populating empty tables. Much simpler than walking paragraphs and runs through superdoc_edit.
doc.tables.sort tables sort Sort table rows by a column value.
doc.tables.setAltText tables set-alt-text Set the alternative text description for a table.
doc.tables.setStyle tables set-style Apply a named table style to the target table.
doc.tables.clearStyle tables clear-style Remove the applied table style, reverting to defaults.
doc.tables.setStyleOption tables set-style-option Toggle a conditional style option such as banded rows or first column.
doc.tables.setBorder tables set-border Set border properties on a table or cell range.
doc.tables.clearBorder tables clear-border Remove border formatting from a table or cell range.
doc.tables.applyBorderPreset tables apply-border-preset Apply a border preset (e.g. all borders, outside only) to a table.
doc.tables.setShading tables set-shading Set the background shading color on a table or cell range.
doc.tables.clearShading tables clear-shading Remove shading from a table or cell range.
doc.tables.setTablePadding tables set-table-padding Set default cell padding for the entire table.
doc.tables.setCellPadding tables set-cell-padding Set padding on a specific table cell or cell range.
doc.tables.setCellSpacing tables set-cell-spacing Set the cell spacing for the target table.
doc.tables.clearCellSpacing tables clear-cell-spacing Remove custom cell spacing from the target table.
doc.tables.applyStyle tables apply-style Toggle conditional-format flags (header row, banded rows/columns, first/last column, last row) on a table. Pass styleOptions with the flags you want to set or clear (omitted flags stay unchanged). For "format the first row as a header" use styleOptions: { headerRow: true }. Optional styleId applies a named table style. Leave it unset unless you have a styleId from superdoc_get_content (no need to invent one).
doc.tables.setBorders tables set-borders Set borders on a table using a target set or per-edge patch.
doc.tables.setTableOptions tables set-table-options Set table-level default cell margins and/or cell spacing.
doc.tables.applyPreset tables apply-preset Apply a named visual preset to a table. Presets: "grid" (1pt black borders all around), "minimal" (no outer borders, hairline grey row separators + thicker bottom), "striped" (banded rows on, 0.5pt grey borders), "accent" (filled header row + thick accent top/bottom; defaults to dark blue, override with accentColor). Composes set_borders + set_style_options + header-row shading in one call. Available via the document API and superdoc_mutations (intentionally NOT exposed as a top-level action on superdoc_table. Agents should compose explicit set_borders / set_shading / set_style_options calls so they always pick concrete colors that match the document context).
doc.tables.get tables get Retrieve table structure and dimensions by locator.
doc.tables.getCells tables get-cells Retrieve cell information for a table, optionally filtered by row or column.
doc.tables.getProperties tables get-properties Retrieve layout and style properties of a table.
doc.tables.getStyles tables get-styles List all table styles and the document-level default table style setting.
doc.tables.setDefaultStyle tables set-default-style Set the document-level default table style (w:defaultTableStyle in settings.xml).
doc.tables.clearDefaultStyle tables clear-default-style Remove the document-level default table style setting.

Table of contents

Operation CLI command Description
doc.toc.list toc list List all tables of contents in the document.
doc.toc.get toc get Retrieve details of a specific table of contents.
doc.toc.configure toc configure Update the configuration switches of a table of contents.
doc.toc.update toc update Rebuild or refresh the materialized content of a table of contents.
doc.toc.remove toc remove Remove a table of contents from the document.
doc.toc.markEntry toc mark-entry Insert a TC (table of contents entry) field at the target paragraph.
doc.toc.unmarkEntry toc unmark-entry Remove a TC (table of contents entry) field from the document.
doc.toc.listEntries toc list-entries List all TC (table of contents entry) fields in the document body.
doc.toc.getEntry toc get-entry Retrieve details of a specific TC (table of contents entry) field.
doc.toc.editEntry toc edit-entry Update the properties of a TC (table of contents entry) field.

Images

Operation CLI command Description
doc.images.list images list List all images in the document.
doc.images.get images get Get details for a specific image by its stable ID.
doc.images.delete images delete Delete an image from the document.
doc.images.move images move Move an image to a new location in the document.
doc.images.convertToInline images convert-to-inline Convert a floating image to inline placement.
doc.images.convertToFloating images convert-to-floating Convert an inline image to floating placement.
doc.images.setSize images set-size Set explicit width/height for an image.
doc.images.setWrapType images set-wrap-type Set the text wrapping type for a floating image.
doc.images.setWrapSide images set-wrap-side Set which side(s) text wraps around a floating image.
doc.images.setWrapDistances images set-wrap-distances Set the text-wrap distance margins for a floating image.
doc.images.setPosition images set-position Set the anchor position for a floating image.
doc.images.setAnchorOptions images set-anchor-options Set anchor behavior options for a floating image.
doc.images.setZOrder images set-z-order Set the z-order (relativeHeight) for a floating image.
doc.images.scale images scale Scale an image by a uniform factor applied to both dimensions.
doc.images.setLockAspectRatio images set-lock-aspect-ratio Lock or unlock the aspect ratio for an image.
doc.images.rotate images rotate Set the absolute rotation angle for an image.
doc.images.flip images flip Set horizontal and/or vertical flip state for an image.
doc.images.crop images crop Apply rectangular edge-percentage crop to an image.
doc.images.resetCrop images reset-crop Remove all cropping from an image.
doc.images.replaceSource images replace-source Replace the image source while preserving identity and placement.
doc.images.setAltText images set-alt-text Set the accessibility description (alt text) for an image.
doc.images.setDecorative images set-decorative Mark or unmark an image as decorative.
doc.images.setName images set-name Set the object name for an image.
doc.images.setHyperlink images set-hyperlink Set or remove the hyperlink attached to an image.
doc.images.insertCaption images insert-caption Insert a caption paragraph below the image.
doc.images.updateCaption images update-caption Update the text of an existing caption paragraph.
doc.images.removeCaption images remove-caption Remove the caption paragraph from below the image.

Comments

Operation CLI command Description
doc.comments.create comments create Create a new comment thread (or reply when parentCommentId is given).
doc.comments.patch comments patch Patch fields on an existing comment (text, target, status, or isInternal).
doc.comments.delete comments delete Remove a comment or reply by ID.
doc.comments.get comments get Retrieve a single comment thread by ID.
doc.comments.list comments list List all comment threads in the document.

Track changes

Operation CLI command Description
doc.trackChanges.list track-changes list List all tracked changes in the document.
doc.trackChanges.get track-changes get Retrieve a single tracked change by ID.
doc.trackChanges.decide track-changes decide Accept or reject tracked changes by ID, range, or scope: all (optionally filtered by story).

History

Operation CLI command Description
doc.history.get history get Query the current undo/redo history state of the document.
doc.history.undo history undo Undo the most recent history-safe mutation in the document.
doc.history.redo history redo Redo the most recently undone action in the document.

Lifecycle

Operation CLI command Description
client.open open Open a document and create a persistent editing session. Optionally override the document body with contentOverride + overrideType (markdown, html, or text).
doc.save save Save the current session to the original file or a new path. Supports explicit review-preserving and final export modes.
doc.close close Close the active editing session and clean up resources.

Client

Operation CLI command Description
client.describe describe List all available CLI operations and contract metadata.
client.describeCommand describe command Show detailed metadata for a single CLI operation.

Core

Operation CLI command Description
doc.get get Read the full document as an SDDocument structure.
doc.find find Search the document for text or node matches using SDM/1 selectors. Returns discovery-grade results: for mutation targeting, use query.match instead.
doc.get_node get-node Retrieve a single node by target position.
doc.get_node_by_id get-node-by-id Retrieve a single node by its unique ID.
doc.get_text get-text Extract the plain-text content of the document.
doc.get_markdown get-markdown Extract the document content as a Markdown string.
doc.get_html get-html Extract the document content as an HTML string.
doc.markdown_to_fragment markdown-to-fragment Convert a Markdown string into an SDM/1 structural fragment.
doc.info info Return document summary info including word, character, paragraph, heading, table, image, comment, tracked-change, SDT-field, list, and page counts, plus outline and capabilities.
doc.extract extract Extract all document content with stable IDs for RAG pipelines. Returns blocks with full text, comments, and tracked changes: each with an ID compatible with scrollToElement().
doc.clear_content clear-content Clear all document body content, leaving a single empty paragraph.
doc.insert insert Insert content into the document. Two input shapes: text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target/ref is omitted, content appends at the end of the document. Text mode supports text (default), markdown, and html content types via the type field. Structural mode uses placement (before/after/insideStart/insideEnd) to position relative to the target block.
doc.replace replace Replace content at a contiguous document selection. Text path accepts a SelectionTarget or ref plus replacement text. Structural path accepts a BlockNodeAddress (replaces whole block), SelectionTarget (expands to full covered block boundaries), or ref plus SDFragment content.
doc.delete delete Delete content at a contiguous document selection. Accepts a SelectionTarget or mutation-ready ref. Supports cross-block deletion and optional block-edge expansion via behavior mode.
doc.blocks.list blocks list List top-level blocks in document order with IDs, types, text previews, and optional full text when includeText:true. Supports pagination via offset/limit and optional nodeType filtering.
doc.blocks.delete blocks delete Delete an entire block node (paragraph, heading, list item, table, image, or sdt) deterministically.
doc.blocks.delete_range blocks delete-range Delete a contiguous range of top-level blocks between two endpoints (inclusive). Both endpoints must be direct children of the document node. Supports dry-run preview.
doc.templates.apply templates apply Apply detected DOCX template/substrate (styles, numbering, settings, theme, font table, web settings, headers/footers, section defaults) from a source package onto the current document, preserving body content. Scopes are auto-detected from source package evidence.
doc.query.match query match Deterministic selector-based search returning mutation-grade addresses and text ranges. Use this to discover targets before any mutation.
doc.ranges.resolve ranges resolve Resolve two explicit anchors into a contiguous document range. Returns a transparent SelectionTarget, a mutation-ready ref, and preview metadata. Stateless and deterministic.
doc.selection.current selection current Read the editor's current selection as a portable SelectionInfo with a text-anchored TextTarget. Primitive for building custom comments UIs, floating toolbars, and other selection-driven components without reaching into ProseMirror internals.
doc.mutations.preview mutations preview Dry-run a mutation plan, returning resolved targets without applying changes.
doc.mutations.apply mutations apply Execute a mutation plan atomically against the document.
doc.capabilities.get capabilities Query runtime capabilities supported by the current document engine.
doc.hyperlinks.list hyperlinks list List all hyperlinks in the document, with optional filtering by href, anchor, or display text.
doc.hyperlinks.get hyperlinks get Retrieve details of a specific hyperlink by its inline address.
doc.hyperlinks.wrap hyperlinks wrap Wrap an existing text range with a hyperlink.
doc.hyperlinks.insert hyperlinks insert Insert new linked text at a target position.
doc.hyperlinks.patch hyperlinks patch Update hyperlink metadata (destination, tooltip, target, rel) without changing display text.
doc.hyperlinks.remove hyperlinks remove Remove a hyperlink. Mode 'unwrap' preserves display text; 'deleteText' removes the linked content entirely.
doc.header_footers.list header-footers list List header/footer slot entries across sections.
doc.header_footers.get header-footers get Get a single header/footer slot entry by address.
doc.header_footers.resolve header-footers resolve Resolve the effective header/footer reference for a slot, walking the section inheritance chain.
doc.header_footers.refs.set header-footers refs set Set an explicit header/footer reference on a section slot.
doc.header_footers.refs.clear header-footers refs clear Clear an explicit header/footer reference from a section slot.
doc.header_footers.refs.set_linked_to_previous header-footers refs set-linked-to-previous Link or unlink a header/footer slot to/from the previous section.
doc.header_footers.parts.list header-footers parts list List unique header/footer part records from document relationships.
doc.header_footers.parts.create header-footers parts create Create a new independent header/footer part, optionally cloned from an existing part.
doc.header_footers.parts.delete header-footers parts delete Delete a header/footer part and its associated relationship when no section slots reference it.
doc.create.content_control create content-control Create a new content control (SDT) in the document.
doc.content_controls.list content-controls list List all content controls in the document with optional type/tag filtering.
doc.content_controls.get content-controls get Retrieve a single content control by target.
doc.content_controls.list_in_range content-controls list-in-range List content controls within a block range.
doc.content_controls.select_by_tag content-controls select-by-tag Select content controls matching a specific tag value.
doc.content_controls.select_by_title content-controls select-by-title Select content controls matching a specific title (alias) value.
doc.content_controls.list_children content-controls list-children List direct child content controls nested inside the target.
doc.content_controls.get_parent content-controls get-parent Get the parent content control of the target, if any.
doc.content_controls.wrap content-controls wrap Wrap existing content with a new content control.
doc.content_controls.unwrap content-controls unwrap Remove the content control wrapper, preserving its content in place.
doc.content_controls.delete content-controls delete Delete a content control and its content from the document.
doc.content_controls.copy content-controls copy Copy a content control to a destination position. Copied SDTs receive new IDs.
doc.content_controls.move content-controls move Move a content control to a new position. Preserves original IDs.
doc.content_controls.patch content-controls patch Patch metadata properties on a content control (tag, alias, appearance, color, etc.).
doc.content_controls.set_lock_mode content-controls set-lock-mode Set the lock mode on a content control.
doc.content_controls.set_type content-controls set-type Transition a content control to a different semantic type. Metadata-only; no implicit content rewrite.
doc.content_controls.get_content content-controls get-content Get the text content of a content control.
doc.content_controls.replace_content content-controls replace-content Replace the entire content of a content control.
doc.content_controls.clear_content content-controls clear-content Clear all content inside a content control, leaving it empty.
doc.content_controls.append_content content-controls append-content Append content to the end of a content control.
doc.content_controls.prepend_content content-controls prepend-content Prepend content to the beginning of a content control.
doc.content_controls.insert_before content-controls insert-before Insert content immediately before a content control.
doc.content_controls.insert_after content-controls insert-after Insert content immediately after a content control.
doc.content_controls.get_binding content-controls get-binding Get the data binding metadata (w:dataBinding) of a content control.
doc.content_controls.set_binding content-controls set-binding Set data binding metadata on a content control.
doc.content_controls.clear_binding content-controls clear-binding Remove data binding metadata from a content control.
doc.content_controls.get_raw_properties content-controls get-raw-properties Get the raw sdtPr properties of a content control as a passthrough hash.
doc.content_controls.patch_raw_properties content-controls patch-raw-properties Apply raw XML-level patches to the sdtPr subtree of a content control.
doc.content_controls.validate_word_compatibility content-controls validate-word-compatibility Validate a content control for Word compatibility issues.
doc.content_controls.normalize_word_compatibility content-controls normalize-word-compatibility Normalize a content control to resolve Word compatibility issues.
doc.content_controls.normalize_tag_payload content-controls normalize-tag-payload Normalize a content control tag between plain-string and JSON-encoded formats.
doc.content_controls.text.set_multiline content-controls text set-multiline Set or clear the multiline attribute on a plain-text content control.
doc.content_controls.text.set_value content-controls text set-value Set the text value of a plain-text content control.
doc.content_controls.text.clear_value content-controls text clear-value Clear the text value of a plain-text content control.
doc.content_controls.date.set_value content-controls date set-value Set the date value of a date content control.
doc.content_controls.date.clear_value content-controls date clear-value Clear the date value of a date content control.
doc.content_controls.date.set_display_format content-controls date set-display-format Set the display format string for a date content control.
doc.content_controls.date.set_display_locale content-controls date set-display-locale Set the display locale for a date content control.
doc.content_controls.date.set_storage_format content-controls date set-storage-format Set the XML storage format for a date content control.
doc.content_controls.date.set_calendar content-controls date set-calendar Set the calendar type for a date content control.
doc.content_controls.checkbox.get_state content-controls checkbox get-state Get the checked state of a checkbox content control.
doc.content_controls.checkbox.set_state content-controls checkbox set-state Set the checked state of a checkbox content control.
doc.content_controls.checkbox.toggle content-controls checkbox toggle Toggle the checked state of a checkbox content control.
doc.content_controls.checkbox.set_symbol_pair content-controls checkbox set-symbol-pair Set the checked and unchecked symbol glyphs for a checkbox content control.
doc.content_controls.choice_list.get_items content-controls choice-list get-items Get the list items and selected value of a comboBox or dropDownList content control.
doc.content_controls.choice_list.set_items content-controls choice-list set-items Replace the list items of a comboBox or dropDownList content control.
doc.content_controls.choice_list.set_selected content-controls choice-list set-selected Set the selected value of a comboBox or dropDownList content control.
doc.content_controls.repeating_section.list_items content-controls repeating-section list-items List the repeating section items inside a repeating section content control.
doc.content_controls.repeating_section.insert_item_before content-controls repeating-section insert-item-before Insert a new item before a specific index in a repeating section.
doc.content_controls.repeating_section.insert_item_after content-controls repeating-section insert-item-after Insert a new item after a specific index in a repeating section.
doc.content_controls.repeating_section.clone_item content-controls repeating-section clone-item Clone a repeating section item at the given index. Cloned SDTs receive new IDs.
doc.content_controls.repeating_section.delete_item content-controls repeating-section delete-item Delete a repeating section item at the given index.
doc.content_controls.repeating_section.set_allow_insert_delete content-controls repeating-section set-allow-insert-delete Set the allowInsertDelete flag on a repeating section.
doc.content_controls.group.wrap content-controls group wrap Wrap a content control inside a new group content control. Always nests; not idempotent.
doc.content_controls.group.ungroup content-controls group ungroup Remove the group designation from a group content control.
doc.bookmarks.list bookmarks list List all bookmarks in the document.
doc.bookmarks.get bookmarks get Get detailed information about a specific bookmark.
doc.bookmarks.insert bookmarks insert Insert a new named bookmark at a target location.
doc.bookmarks.rename bookmarks rename Rename an existing bookmark.
doc.bookmarks.remove bookmarks remove Remove a bookmark from the document.
doc.footnotes.list footnotes list List all footnotes and endnotes in the document.
doc.footnotes.get footnotes get Get detailed information about a specific footnote or endnote.
doc.footnotes.insert footnotes insert Insert a new footnote or endnote at a target location.
doc.footnotes.update footnotes update Update the content of an existing footnote or endnote.
doc.footnotes.remove footnotes remove Remove a footnote or endnote from the document.
doc.footnotes.configure footnotes configure Configure numbering and placement for footnotes or endnotes.
doc.cross_refs.list cross-refs list List all cross-reference fields in the document.
doc.cross_refs.get cross-refs get Get detailed information about a specific cross-reference field.
doc.cross_refs.insert cross-refs insert Insert a new cross-reference field at a target location.
doc.cross_refs.rebuild cross-refs rebuild Rebuild (recalculate) a cross-reference field.
doc.cross_refs.remove cross-refs remove Remove a cross-reference field from the document.
doc.index.list index list List all index blocks in the document.
doc.index.get index get Get detailed information about a specific index block.
doc.index.insert index insert Insert a new index block at a target location.
doc.index.configure index configure Update the configuration of an existing index block.
doc.index.rebuild index rebuild Rebuild (regenerate) an index block from its entries.
doc.index.remove index remove Remove an index block from the document.
doc.index.entries.list index entries list List all XE (index entry) fields in the document.
doc.index.entries.get index entries get Get detailed information about a specific XE index entry.
doc.index.entries.insert index entries insert Insert a new XE index entry field at a target location.
doc.index.entries.update index entries update Update the properties of an existing XE index entry.
doc.index.entries.remove index entries remove Remove an XE index entry field from the document.
doc.captions.list captions list List all caption paragraphs in the document.
doc.captions.get captions get Get detailed information about a specific caption paragraph.
doc.captions.insert captions insert Insert a new caption paragraph adjacent to a target block.
doc.captions.update captions update Update the text of an existing caption paragraph.
doc.captions.remove captions remove Remove a caption paragraph from the document.
doc.captions.configure captions configure Configure numbering format for a caption label.
doc.fields.list fields list List all fields in the document.
doc.fields.get fields get Get detailed information about a specific field.
doc.fields.insert fields insert Insert a raw field code at a target location.
doc.fields.rebuild fields rebuild Rebuild (recalculate) a field.
doc.fields.remove fields remove Remove a field from the document.
doc.citations.list citations list List all citation marks in the document.
doc.citations.get citations get Get detailed information about a specific citation mark.
doc.citations.insert citations insert Insert a new citation mark at a target location.
doc.citations.update citations update Update an existing citation mark's source references.
doc.citations.remove citations remove Remove a citation mark from the document.
doc.citations.sources.list citations sources list List all citation sources in the document store.
doc.citations.sources.get citations sources get Get detailed information about a specific citation source.
doc.citations.sources.insert citations sources insert Register a new citation source in the document store.
doc.citations.sources.update citations sources update Update the fields of an existing citation source.
doc.citations.sources.remove citations sources remove Remove a citation source from the document store.
doc.citations.bibliography.get citations bibliography get Get information about the bibliography block.
doc.citations.bibliography.insert citations bibliography insert Insert a bibliography block at a target location.
doc.citations.bibliography.rebuild citations bibliography rebuild Rebuild the bibliography from current sources.
doc.citations.bibliography.configure citations bibliography configure Configure the bibliography style.
doc.citations.bibliography.remove citations bibliography remove Remove the bibliography block from the document.
doc.authorities.list authorities list List all table-of-authorities blocks in the document.
doc.authorities.get authorities get Get detailed information about a specific table-of-authorities block.
doc.authorities.insert authorities insert Insert a new table-of-authorities block at a target location.
doc.authorities.configure authorities configure Update the configuration of an existing table-of-authorities block.
doc.authorities.rebuild authorities rebuild Rebuild a table-of-authorities block from its entries.
doc.authorities.remove authorities remove Remove a table-of-authorities block from the document.
doc.authorities.entries.list authorities entries list List all TA (authority entry) fields in the document.
doc.authorities.entries.get authorities entries get Get detailed information about a specific TA authority entry.
doc.authorities.entries.insert authorities entries insert Insert a new TA authority entry field at a target location.
doc.authorities.entries.update authorities entries update Update the properties of an existing TA authority entry.
doc.authorities.entries.remove authorities entries remove Remove a TA authority entry field from the document.
doc.diff.capture diff capture Capture the current document's diffable state as a versioned snapshot. v1 covers body, comments, styles, and numbering. Header/footer content is not included.
doc.diff.compare diff compare Compare the current document (base) against a previously captured target snapshot. Returns a versioned diff payload describing the changes from base to target.
doc.diff.apply diff apply Apply a previously computed diff payload to the current document. The document fingerprint must match the diff base fingerprint. Tracked mode governs body content only; styles, numbering, and comments are always applied directly.
doc.protection.get protection get Read the current document protection state including editing restrictions, write protection, and read-only recommendation.
doc.protection.set_editing_restriction protection set-editing-restriction Enable Word-style editing restriction on the document. Only readOnly mode is supported in v1.
doc.protection.clear_editing_restriction protection clear-editing-restriction Disable document-level editing restriction by setting enforcement to off. Preserves the protection element and its metadata for round-trip fidelity.
doc.permission_ranges.list permission-ranges list List all permission ranges in the document. Returns only complete paired ranges (both start and end markers present).
doc.permission_ranges.get permission-ranges get Get detailed information about a specific permission range by ID.
doc.permission_ranges.create permission-ranges create Create a permission range exception region in the document. Inserts matched permStart/permEnd markers at the target.
doc.permission_ranges.remove permission-ranges remove Remove a permission range by ID. Removes whichever markers exist for the given ID (start, end, or both).
doc.permission_ranges.update_principal permission-ranges update-principal Change which principal is allowed to edit a permission range. Updates the principal fields on the start marker.
doc.custom_xml.parts.list custom-xml parts list List Custom XML Data Storage Parts in the document, optionally filtered by root namespace or schema reference.
doc.custom_xml.parts.get custom-xml parts get Get a single Custom XML Data Storage Part by itemID or package part name, including its full content. v1 partName targeting is limited to Word-style customXml/itemN.xml paths.
doc.custom_xml.parts.create custom-xml parts create Add a new Custom XML Data Storage Part to the document. Generates a fresh itemID GUID and emits the Properties Part.
doc.custom_xml.parts.patch custom-xml parts patch Replace the content and/or schemaRefs of an existing Custom XML Data Storage Part. At least one of content or schemaRefs is required. v1 partName targeting is limited to Word-style customXml/itemN.xml paths.
doc.custom_xml.parts.remove custom-xml parts remove Remove a Custom XML Data Storage Part and clean up all linked package files (item, props, rels, content-types entry). v1 partName targeting is limited to Word-style customXml/itemN.xml paths.
doc.metadata.attach metadata attach Anchor a JSON metadata payload to a span of text. Wraps the target range in a hidden inline content control whose w:tag carries a stable id, and stores the payload in a namespaced Custom XML Data Storage Part. v1 supports text-range anchors only.
doc.metadata.list metadata list List anchored-metadata entries in the document, optionally filtered by consumer namespace and/or a within selection (returns only entries whose anchor overlaps within).
doc.metadata.get metadata get Get a single anchored-metadata entry by id, including its JSON payload.
doc.metadata.update metadata update Replace the JSON payload of an existing anchored-metadata entry. Replace semantics; no merge. The anchor is left untouched.
doc.metadata.remove metadata remove Remove an anchored-metadata entry. Strips the anchor content-control wrapper (its content stays in the document) and deletes the payload entry from the Storage Part. In v1 these writes are sequenced, not transactional: the adapter resolves the target up-front so missing-target failures land before any state change, but a crash strictly between the two writes can leave a dangling payload. When the backing part has no remaining entries, the part itself is removed.
doc.metadata.resolve metadata resolve Find where an anchored-metadata entry is anchored in the document. Returns the SelectionTarget covering the anchor content.
doc.insert_tab insert tab Insert a real Word tab node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.
doc.insert_line_break insert line-break Insert a real Word line-break node at a collapsed text insertion point. Accepts the same target/ref shortcuts as insert, but only for point inserts.

Format

Operation CLI command Description
doc.format_range format-range Legacy root-level alias for inline range formatting. Routes to format.apply for compatibility with older callers.
doc.format.apply format apply Apply inline run-property patch changes to the target range with explicit set/clear semantics.
doc.format.bold format bold Set or clear the bold inline run property on the target text range.
doc.format.italic format italic Set or clear the italic inline run property on the target text range.
doc.format.strike format strike Set or clear the strike inline run property on the target text range.
doc.format.underline format underline Set or clear the underline inline run property on the target text range.
doc.format.highlight format highlight Set or clear the highlight inline run property on the target text range.
doc.format.color format color Set or clear the color inline run property on the target text range.
doc.format.font_size format font-size Set or clear the fontSize inline run property on the target text range.
doc.format.font_family format font-family Set or clear the fontFamily inline run property on the target text range.
doc.format.letter_spacing format letter-spacing Set or clear the letterSpacing inline run property on the target text range.
doc.format.vert_align format vert-align Set or clear the vertAlign inline run property on the target text range.
doc.format.position format position Set or clear the position inline run property on the target text range.
doc.format.dstrike format dstrike Set or clear the dstrike inline run property on the target text range.
doc.format.small_caps format small-caps Set or clear the smallCaps inline run property on the target text range.
doc.format.caps format caps Set or clear the caps inline run property on the target text range.
doc.format.shading format shading Set or clear the shading inline run property on the target text range.
doc.format.border format border Set or clear the border inline run property on the target text range.
doc.format.outline format outline Set or clear the outline inline run property on the target text range.
doc.format.shadow format shadow Set or clear the shadow inline run property on the target text range.
doc.format.emboss format emboss Set or clear the emboss inline run property on the target text range.
doc.format.imprint format imprint Set or clear the imprint inline run property on the target text range.
doc.format.char_scale format char-scale Set or clear the charScale inline run property on the target text range.
doc.format.kerning format kerning Set or clear the kerning inline run property on the target text range.
doc.format.vanish format vanish Set or clear the vanish inline run property on the target text range.
doc.format.web_hidden format web-hidden Set or clear the webHidden inline run property on the target text range.
doc.format.spec_vanish format spec-vanish Set or clear the specVanish inline run property on the target text range.
doc.format.rtl format rtl Set or clear the rtl inline run property on the target text range. This does not change paragraph direction; use format.paragraph.setDirection for paragraph-level RTL.
doc.format.cs format cs Set or clear the cs inline run property on the target text range.
doc.format.b_cs format b-cs Set or clear the bCs inline run property on the target text range.
doc.format.i_cs format i-cs Set or clear the iCs inline run property on the target text range.
doc.format.east_asian_layout format east-asian-layout Set or clear the eastAsianLayout inline run property on the target text range.
doc.format.em format em Set or clear the em inline run property on the target text range.
doc.format.fit_text format fit-text Set or clear the fitText inline run property on the target text range.
doc.format.snap_to_grid format snap-to-grid Set or clear the snapToGrid inline run property on the target text range.
doc.format.lang format lang Set or clear the lang inline run property on the target text range.
doc.format.o_math format o-math Set or clear the oMath inline run property on the target text range.
doc.format.r_style format r-style Set or clear the rStyle inline run property on the target text range.
doc.format.r_fonts format r-fonts Set or clear the rFonts inline run property on the target text range.
doc.format.font_size_cs format font-size-cs Set or clear the fontSizeCs inline run property on the target text range.
doc.format.ligatures format ligatures Set or clear the ligatures inline run property on the target text range.
doc.format.num_form format num-form Set or clear the numForm inline run property on the target text range.
doc.format.num_spacing format num-spacing Set or clear the numSpacing inline run property on the target text range.
doc.format.stylistic_sets format stylistic-sets Set or clear the stylisticSets inline run property on the target text range.
doc.format.contextual_alternates format contextual-alternates Set or clear the contextualAlternates inline run property on the target text range.
doc.styles.apply styles apply Apply 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.set_style styles paragraph set-style Apply a paragraph style (w:pStyle) to a paragraph-like block, clearing direct run formatting while preserving character-style references.
doc.styles.paragraph.clear_style styles paragraph clear-style Remove the paragraph style reference from a paragraph-like block.
doc.format.paragraph.reset_direct_formatting format paragraph reset-direct-formatting Strip all direct paragraph formatting while preserving style reference, numbering, and section metadata.
doc.format.paragraph.set_alignment format paragraph set-alignment Set visual paragraph alignment on a paragraph-like block. For RTL paragraphs, left/right are translated to Word-compatible stored justification values.
doc.format.paragraph.clear_alignment format paragraph clear-alignment Remove direct paragraph alignment, reverting to style-defined or default alignment.
doc.format.paragraph.set_indentation format paragraph set-indentation Set paragraph indentation properties (left, right, firstLine, hanging) in twips.
doc.format.paragraph.clear_indentation format paragraph clear-indentation Remove all direct paragraph indentation.
doc.format.paragraph.set_spacing format paragraph set-spacing Set paragraph spacing properties (before, after, line, lineRule) in twips.
doc.format.paragraph.clear_spacing format paragraph clear-spacing Remove all direct paragraph spacing.
doc.format.paragraph.set_keep_options format paragraph set-keep-options Set keep-with-next, keep-lines-together, and widow/orphan control flags.
doc.format.paragraph.set_outline_level format paragraph set-outline-level Set the paragraph outline level (0–9) or null to clear.
doc.format.paragraph.set_flow_options format paragraph set-flow-options Set contextual spacing, page-break-before, and suppress-auto-hyphens flags.
doc.format.paragraph.set_tab_stop format paragraph set-tab-stop Add or replace a tab stop at a given position.
doc.format.paragraph.clear_tab_stop format paragraph clear-tab-stop Remove a tab stop at a given position.
doc.format.paragraph.clear_all_tab_stops format paragraph clear-all-tab-stops Remove all tab stops from a paragraph.
doc.format.paragraph.set_border format paragraph set-border Set border properties for a specific side of a paragraph.
doc.format.paragraph.clear_border format paragraph clear-border Remove border for a specific side or all sides of a paragraph.
doc.format.paragraph.set_shading format paragraph set-shading Set paragraph shading (background fill, pattern color, pattern type).
doc.format.paragraph.clear_shading format paragraph clear-shading Remove all paragraph shading.
doc.format.paragraph.set_direction format paragraph set-direction Set paragraph base direction (LTR or RTL via w:bidi). Optionally align text to match.
doc.format.paragraph.clear_direction format paragraph clear-direction Remove explicit paragraph direction, reverting to inherited or default (LTR).

Create

Operation CLI command Description
doc.create.paragraph create paragraph Create a standalone paragraph at the target position. To add a list item, use lists.insert instead.
doc.create.heading create heading Create a new heading at the target position.
doc.create.section_break create section-break Create a section break at the target location with optional initial section properties.
doc.create.table create table Create a new table at the target position.
doc.create.table_of_contents create table-of-contents Insert a new table of contents at the target position.
doc.create.image create image Insert a new image at the target position.

Sections

Operation CLI command Description
doc.sections.list sections list List sections in deterministic order with section-target handles.
doc.sections.get sections get Retrieve full section information by section address.
doc.sections.set_break_type sections set-break-type Set the section break type.
doc.sections.set_page_margins sections set-page-margins Set page-edge margins for a section.
doc.sections.set_header_footer_margins sections set-header-footer-margins Set header/footer margin distances for a section.
doc.sections.set_page_setup sections set-page-setup Set page size/orientation properties for a section.
doc.sections.set_columns sections set-columns Set column configuration for a section.
doc.sections.set_line_numbering sections set-line-numbering Enable or configure line numbering for a section.
doc.sections.set_page_numbering sections set-page-numbering Set page numbering format/start and chapter numbering settings for a section.
doc.sections.set_title_page sections set-title-page Enable or disable title-page behavior for a section.
doc.sections.set_odd_even_headers_footers sections set-odd-even-headers-footers Enable or disable odd/even header-footer mode in document settings.
doc.sections.set_vertical_align sections set-vertical-align Set vertical page alignment for a section.
doc.sections.set_section_direction sections set-section-direction Set section text flow direction (LTR/RTL).
doc.sections.set_header_footer_ref sections set-header-footer-ref Set or replace a section header/footer reference for a variant.
doc.sections.clear_header_footer_ref sections clear-header-footer-ref Clear a section header/footer reference for a specific variant.
doc.sections.set_link_to_previous sections set-link-to-previous Set or clear link-to-previous behavior for a header/footer variant.
doc.sections.set_page_borders sections set-page-borders Set page border configuration for a section.
doc.sections.clear_page_borders sections clear-page-borders Clear page border configuration for a section.

Lists

Operation CLI command Description
doc.lists.list lists list List all list nodes in the document, optionally filtered by scope.
doc.lists.get lists get Retrieve a specific list node by target.
doc.lists.insert lists insert Insert a new list item before or after an existing list item. The new item inherits the target list context.
doc.lists.create lists create Create a new list from one or more paragraphs. Supports optional preset or style for new sequences. When sequence.mode is "continuePrevious", preset and style are not allowed: the new items inherit formatting from the previous sequence.
doc.lists.attach lists attach Convert non-list paragraphs to list items under an existing list sequence.
doc.lists.detach lists detach Remove numbering properties from list items, converting them to plain paragraphs.
doc.lists.delete lists delete Delete the entire list that contains the targeted list item. Removes ALL items in the same numbered sequence (the contiguous run of list items sharing the target's numbering) AND their text content from the document. Pass any single list item from the list as target; the op walks adjacent siblings to find the full list. Use this for "remove the list" / "delete this list" intents and for the cleanup step of a list-to-table conversion.
doc.lists.indent lists indent Increase the indentation level of a list item.
doc.lists.outdent lists outdent Decrease the indentation level of a list item.
doc.lists.join lists join Merge two adjacent list sequences into one.
doc.lists.can_join lists can-join Check whether two adjacent list sequences can be joined.
doc.lists.separate lists separate Split a list sequence at the target item, creating a new sequence from that point forward.
doc.lists.merge lists merge Compound: merge two adjacent list sequences into one. Reassigns numId on the absorbed sequence (no strict abstractNumId check: absorbed items adopt the absorbing definition) and deletes empty paragraphs between the two sequences. Use this instead of lists.join for the user-facing "merge these lists" intent.
doc.lists.split lists split Compound: split a list sequence at the target item into two independent sequences. Runs lists.separate then (by default) lists.setValue(1) so the new half starts numbering fresh at 1. Pass restartNumbering:false for raw separate semantics (new half continues the previous count).
doc.lists.set_level lists set-level Set the absolute nesting level (0..8) of a list item.
doc.lists.set_value lists set-value Set an explicit numbering value at the target item. Mid-sequence targets are atomically separated first.
doc.lists.continue_previous lists continue-previous Continue numbering from the nearest compatible previous list sequence.
doc.lists.can_continue_previous lists can-continue-previous Check whether the target sequence can continue numbering from a previous compatible sequence.
doc.lists.set_level_restart lists set-level-restart Set the restart behavior for a specific list level.
doc.lists.convert_to_text lists convert-to-text Convert list items to plain paragraphs, optionally prepending the rendered marker text.
doc.lists.apply_template lists apply-template Advanced alias for lists.applyStyle. Apply a captured ListTemplate to the target list (abstract-scoped, no clone-on-write).
doc.lists.apply_preset lists apply-preset Apply a built-in list formatting preset to the target list.
doc.lists.set_type lists set-type Convert a list to ordered or bullet and merge adjacent compatible sequences to preserve continuous numbering.
doc.lists.capture_template lists capture-template Advanced alias for lists.getStyle. Capture list formatting from the abstract definition only (does not merge lvlOverride formatting).
doc.lists.set_level_numbering lists set-level-numbering Advanced alias for lists.setLevelNumberStyle/setLevelText/setLevelStart. Set format, pattern, and start in one call (abstract-scoped, no clone-on-write).
doc.lists.set_level_bullet lists set-level-bullet Set the bullet marker text for a specific list level.
doc.lists.set_level_picture_bullet lists set-level-picture-bullet Set a picture bullet for a specific list level by its OOXML lvlPicBulletId.
doc.lists.set_level_alignment lists set-level-alignment Set the marker alignment (left, center, right) for a specific list level.
doc.lists.set_level_indents lists set-level-indents Set the paragraph indentation values (left, hanging, firstLine) for a specific list level.
doc.lists.set_level_trailing_character lists set-level-trailing-character Set the trailing character (tab, space, nothing) after the marker for a specific list level.
doc.lists.set_level_marker_font lists set-level-marker-font Set the font family used for the marker character at a specific list level.
doc.lists.clear_level_overrides lists clear-level-overrides Remove instance-level overrides for a specific list level, restoring abstract definition values.
doc.lists.get_style lists get-style Read the effective reusable style of a list, including instance-level overrides. Returns a ListStyle that can be applied to other lists via lists.applyStyle.
doc.lists.apply_style lists apply-style Apply a reusable list style to the target list. Sequence-local: if the abstract definition is shared with other lists, it is cloned first to avoid affecting them.
doc.lists.restart_at lists restart-at Restart numbering at the target list item with a specific value. If the item is mid-sequence, it is separated first.
doc.lists.set_level_number_style lists set-level-number-style Set the numbering style (e.g. decimal, lowerLetter, upperRoman) for a specific list level. Rejects "bullet": use setLevelBullet instead. Sequence-local: clones shared definitions.
doc.lists.set_level_text lists set-level-text Set the level text pattern (e.g. "%1.", "(%1)") for a specific list level. Uses OOXML level-placeholder syntax. Sequence-local: clones shared definitions.
doc.lists.set_level_start lists set-level-start Set the start value for a specific list level. Rejects bullet levels and non-positive values. Sequence-local: clones shared definitions.
doc.lists.set_level_layout lists set-level-layout Set the layout properties (alignment, indentation, trailing character, tab stop) for a specific list level. Accepts partial updates: omitted fields are left unchanged. Sequence-local: clones shared definitions.

Tables

Operation CLI command Description
doc.tables.convert_from_text tables convert-from-text Convert a text range into a table.
doc.tables.delete tables delete Delete the target table from the document.
doc.tables.clear_contents tables clear-contents Clear the contents of the target table or cell range.
doc.tables.move tables move Move a table to a new position in the document.
doc.tables.split tables split Split a table into two tables at the target row.
doc.tables.convert_to_text tables convert-to-text Convert a table back to plain text.
doc.tables.set_layout tables set-layout Set the layout mode of the target table.
doc.tables.insert_row tables insert-row Insert a new row into the target table. The new row is cloned from an adjacent row, so it inherits the existing cell shading, borders, alignment, and padding. No follow-up styling call is needed unless the new row should look different from the rest of the table.
doc.tables.delete_row tables delete-row Delete a row from the target table.
doc.tables.set_row_height tables set-row-height Set the height of a table row.
doc.tables.distribute_rows tables distribute-rows Distribute row heights evenly across the target table.
doc.tables.set_row_options tables set-row-options Set options on a table row such as header repeat or page break.
doc.tables.insert_column tables insert-column Insert a new column into the target table. The new column is cloned from an adjacent column, so it inherits the existing cell shading, borders, alignment, and width. No follow-up styling call is needed unless the new column should look different from the rest of the table.
doc.tables.delete_column tables delete-column Delete a column from the target table.
doc.tables.set_column_width tables set-column-width Set the width of a table column.
doc.tables.distribute_columns tables distribute-columns Distribute column widths evenly across the target table.
doc.tables.insert_cell tables insert-cell Insert a new cell into a table row.
doc.tables.delete_cell tables delete-cell Delete a cell from a table row.
doc.tables.merge_cells tables merge-cells Merge a range of table cells into one.
doc.tables.unmerge_cells tables unmerge-cells Unmerge a previously merged table cell.
doc.tables.split_cell tables split-cell Split a table cell into multiple cells.
doc.tables.set_cell_properties tables set-cell-properties Set non-text properties on a single table cell: vertical alignment, text wrapping, fit-text, or preferred width. Requires a cell-level target (a tableCell block address with kind, nodeType, nodeId). Does NOT accept a table target with rowIndex/columnIndex. To set the text content of a cell, use action "set_cell_text" instead.
doc.tables.set_cell_text tables set-cell-text Replace the text content of a single table cell with plain text (one paragraph). Accepts either a direct cell locator (a tableCell block address with kind, nodeType, nodeId) OR a table target with rowIndex + columnIndex. Cell properties (vertical alignment, shading, borders, colspan/rowspan) are preserved. Use this for filling cells with values, replacing cell text, or populating empty tables. Much simpler than walking paragraphs and runs through superdoc_edit.
doc.tables.sort tables sort Sort table rows by a column value.
doc.tables.set_alt_text tables set-alt-text Set the alternative text description for a table.
doc.tables.set_style tables set-style Apply a named table style to the target table.
doc.tables.clear_style tables clear-style Remove the applied table style, reverting to defaults.
doc.tables.set_style_option tables set-style-option Toggle a conditional style option such as banded rows or first column.
doc.tables.set_border tables set-border Set border properties on a table or cell range.
doc.tables.clear_border tables clear-border Remove border formatting from a table or cell range.
doc.tables.apply_border_preset tables apply-border-preset Apply a border preset (e.g. all borders, outside only) to a table.
doc.tables.set_shading tables set-shading Set the background shading color on a table or cell range.
doc.tables.clear_shading tables clear-shading Remove shading from a table or cell range.
doc.tables.set_table_padding tables set-table-padding Set default cell padding for the entire table.
doc.tables.set_cell_padding tables set-cell-padding Set padding on a specific table cell or cell range.
doc.tables.set_cell_spacing tables set-cell-spacing Set the cell spacing for the target table.
doc.tables.clear_cell_spacing tables clear-cell-spacing Remove custom cell spacing from the target table.
doc.tables.apply_style tables apply-style Toggle conditional-format flags (header row, banded rows/columns, first/last column, last row) on a table. Pass styleOptions with the flags you want to set or clear (omitted flags stay unchanged). For "format the first row as a header" use styleOptions: { headerRow: true }. Optional styleId applies a named table style. Leave it unset unless you have a styleId from superdoc_get_content (no need to invent one).
doc.tables.set_borders tables set-borders Set borders on a table using a target set or per-edge patch.
doc.tables.set_table_options tables set-table-options Set table-level default cell margins and/or cell spacing.
doc.tables.apply_preset tables apply-preset Apply a named visual preset to a table. Presets: "grid" (1pt black borders all around), "minimal" (no outer borders, hairline grey row separators + thicker bottom), "striped" (banded rows on, 0.5pt grey borders), "accent" (filled header row + thick accent top/bottom; defaults to dark blue, override with accentColor). Composes set_borders + set_style_options + header-row shading in one call. Available via the document API and superdoc_mutations (intentionally NOT exposed as a top-level action on superdoc_table. Agents should compose explicit set_borders / set_shading / set_style_options calls so they always pick concrete colors that match the document context).
doc.tables.get tables get Retrieve table structure and dimensions by locator.
doc.tables.get_cells tables get-cells Retrieve cell information for a table, optionally filtered by row or column.
doc.tables.get_properties tables get-properties Retrieve layout and style properties of a table.
doc.tables.get_styles tables get-styles List all table styles and the document-level default table style setting.
doc.tables.set_default_style tables set-default-style Set the document-level default table style (w:defaultTableStyle in settings.xml).
doc.tables.clear_default_style tables clear-default-style Remove the document-level default table style setting.

Table of contents

Operation CLI command Description
doc.toc.list toc list List all tables of contents in the document.
doc.toc.get toc get Retrieve details of a specific table of contents.
doc.toc.configure toc configure Update the configuration switches of a table of contents.
doc.toc.update toc update Rebuild or refresh the materialized content of a table of contents.
doc.toc.remove toc remove Remove a table of contents from the document.
doc.toc.mark_entry toc mark-entry Insert a TC (table of contents entry) field at the target paragraph.
doc.toc.unmark_entry toc unmark-entry Remove a TC (table of contents entry) field from the document.
doc.toc.list_entries toc list-entries List all TC (table of contents entry) fields in the document body.
doc.toc.get_entry toc get-entry Retrieve details of a specific TC (table of contents entry) field.
doc.toc.edit_entry toc edit-entry Update the properties of a TC (table of contents entry) field.

Images

Operation CLI command Description
doc.images.list images list List all images in the document.
doc.images.get images get Get details for a specific image by its stable ID.
doc.images.delete images delete Delete an image from the document.
doc.images.move images move Move an image to a new location in the document.
doc.images.convert_to_inline images convert-to-inline Convert a floating image to inline placement.
doc.images.convert_to_floating images convert-to-floating Convert an inline image to floating placement.
doc.images.set_size images set-size Set explicit width/height for an image.
doc.images.set_wrap_type images set-wrap-type Set the text wrapping type for a floating image.
doc.images.set_wrap_side images set-wrap-side Set which side(s) text wraps around a floating image.
doc.images.set_wrap_distances images set-wrap-distances Set the text-wrap distance margins for a floating image.
doc.images.set_position images set-position Set the anchor position for a floating image.
doc.images.set_anchor_options images set-anchor-options Set anchor behavior options for a floating image.
doc.images.set_z_order images set-z-order Set the z-order (relativeHeight) for a floating image.
doc.images.scale images scale Scale an image by a uniform factor applied to both dimensions.
doc.images.set_lock_aspect_ratio images set-lock-aspect-ratio Lock or unlock the aspect ratio for an image.
doc.images.rotate images rotate Set the absolute rotation angle for an image.
doc.images.flip images flip Set horizontal and/or vertical flip state for an image.
doc.images.crop images crop Apply rectangular edge-percentage crop to an image.
doc.images.reset_crop images reset-crop Remove all cropping from an image.
doc.images.replace_source images replace-source Replace the image source while preserving identity and placement.
doc.images.set_alt_text images set-alt-text Set the accessibility description (alt text) for an image.
doc.images.set_decorative images set-decorative Mark or unmark an image as decorative.
doc.images.set_name images set-name Set the object name for an image.
doc.images.set_hyperlink images set-hyperlink Set or remove the hyperlink attached to an image.
doc.images.insert_caption images insert-caption Insert a caption paragraph below the image.
doc.images.update_caption images update-caption Update the text of an existing caption paragraph.
doc.images.remove_caption images remove-caption Remove the caption paragraph from below the image.

Comments

Operation CLI command Description
doc.comments.create comments create Create a new comment thread (or reply when parentCommentId is given).
doc.comments.patch comments patch Patch fields on an existing comment (text, target, status, or isInternal).
doc.comments.delete comments delete Remove a comment or reply by ID.
doc.comments.get comments get Retrieve a single comment thread by ID.
doc.comments.list comments list List all comment threads in the document.

Track changes

Operation CLI command Description
doc.track_changes.list track-changes list List all tracked changes in the document.
doc.track_changes.get track-changes get Retrieve a single tracked change by ID.
doc.track_changes.decide track-changes decide Accept or reject tracked changes by ID, range, or scope: all (optionally filtered by story).

History

Operation CLI command Description
doc.history.get history get Query the current undo/redo history state of the document.
doc.history.undo history undo Undo the most recent history-safe mutation in the document.
doc.history.redo history redo Redo the most recently undone action in the document.

Lifecycle

Operation CLI command Description
client.open open Open a document and create a persistent editing session. Optionally override the document body with contentOverride + overrideType (markdown, html, or text).
doc.save save Save the current session to the original file or a new path. Supports explicit review-preserving and final export modes.
doc.close close Close the active editing session and clean up resources.

Client

Operation CLI command Description
client.describe describe List all available CLI operations and contract metadata.
client.describe_command describe command Show detailed metadata for a single CLI operation.
{/* SDK_OPERATIONS_END */}

SDK vs browser integration model

The SDKs are request/response wrappers around the CLI. They do not expose browser event subscriptions like editor.on('update', ...) or superdoc.on('editor-update', ...).

  • Call doc.info() at workflow boundaries (after opening, after edits, or before saving), not in a polling loop.
  • If you are building a browser live counter, use the SuperEditor events or SuperDoc events instead.
const doc = await client.open({ doc: './report.docx' });
const info = await doc.info();
console.log(
  `${info.counts.words} words, ` +
    `${info.counts.characters} characters, ` +
    `${info.counts.trackedChanges} tracked changes, ` +
    `${info.counts.sdtFields} SDT fields, ` +
    `${info.counts.lists} lists`,
);
await doc.close();

Related

  • 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