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

Installation

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

Quick start

import { SuperDocClient } from '@superdoc-dev/sdk';

const client = new SuperDocClient();

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

// Find text
const result = await client.doc.find({ pattern: 'ACME Corp' });

// Replace it
const target = result.context?.[0]?.textRanges?.[0];
if (target) {
  await client.doc.replace({ target, text: 'NewCo Inc.' });
}

// Save and close
await client.doc.save();
await client.doc.close();

AI tool use

The SDKs include tool catalogs for LLM integrations. You can expose document operations as tools for AI agents:
import { chooseSuperDocTools, dispatchSuperDocTool } from '@superdoc-dev/sdk';

// Get tools scoped to the current task
const tools = chooseSuperDocTools({
  phase: 'mutate',
  features: { comments: true, trackChanges: true },
});

// Dispatch a tool call from your LLM
const result = await dispatchSuperDocTool(client, toolCall);

Available operations

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

Lifecycle

OperationCLI commandDescription
doc.openopenOpen a document and create a persistent editing session.
doc.savesaveSave the current session to the original file or a new path.
doc.closecloseClose the active editing session and clean up resources.

Query

OperationCLI commandDescription
doc.findfindSearch the document for nodes matching type, text, or attribute criteria.
doc.getNodeget-nodeRetrieve a single node by target position.
doc.getNodeByIdget-node-by-idRetrieve a single node by its unique ID.
doc.infoinfoReturn document metadata including revision, node count, and capabilities.

Mutation

OperationCLI commandDescription
doc.insertinsertInsert text or inline content at a target position.
doc.replacereplaceReplace content at a target position with new text or inline content.
doc.deletedeleteDelete content at a target position.

Format

OperationCLI commandDescription
doc.format.boldformat boldToggle bold formatting on the target range.
doc.format.italicformat italicToggle italic formatting on the target range.
doc.format.underlineformat underlineToggle underline formatting on the target range.
doc.format.strikethroughformat strikethroughToggle strikethrough formatting on the target range.

Create

OperationCLI commandDescription
doc.create.paragraphcreate paragraphCreate a new paragraph at the target position.

Lists

OperationCLI commandDescription
doc.lists.listlists listList all list nodes in the document, optionally filtered by scope.
doc.lists.getlists getRetrieve a specific list node by target.
doc.lists.insertlists insertInsert a new list at the target position.
doc.lists.setTypelists set-typeChange the list type (ordered, unordered) of a target list.
doc.lists.indentlists indentIncrease the indentation level of a list item.
doc.lists.outdentlists outdentDecrease the indentation level of a list item.
doc.lists.restartlists restartRestart numbering of an ordered list at the target item.
doc.lists.exitlists exitExit a list context, converting the target item to a paragraph.

Comments

OperationCLI commandDescription
doc.comments.addcomments addAdd a new comment thread anchored to a target range.
doc.comments.editcomments editEdit the content of an existing comment.
doc.comments.replycomments replyAdd a reply to an existing comment thread.
doc.comments.movecomments moveMove a comment thread to a new anchor range.
doc.comments.resolvecomments resolveResolve or unresolve a comment thread.
doc.comments.removecomments removeRemove a comment or reply by ID.
doc.comments.setInternalcomments set-internalToggle the internal (private) flag on a comment thread.
doc.comments.setActivecomments set-activeSet the active (focused) comment thread for UI highlighting.
doc.comments.goTocomments go-toScroll the viewport to a comment thread by ID.
doc.comments.getcomments getRetrieve a single comment thread by ID.
doc.comments.listcomments listList all comment threads in the document.

Track changes

OperationCLI commandDescription
doc.trackChanges.listtrack-changes listList all tracked changes in the document.
doc.trackChanges.gettrack-changes getRetrieve a single tracked change by ID.
doc.trackChanges.accepttrack-changes acceptAccept a tracked change, applying it permanently.
doc.trackChanges.rejecttrack-changes rejectReject a tracked change, reverting it.
doc.trackChanges.acceptAlltrack-changes accept-allAccept all tracked changes in the document.
doc.trackChanges.rejectAlltrack-changes reject-allReject all tracked changes in the document.

Session

OperationCLI commandDescription
doc.session.listsession listList all active editing sessions.
doc.session.savesession savePersist the current session state.
doc.session.closesession closeClose a specific editing session by ID.
doc.session.setDefaultsession set-defaultSet the default session for subsequent commands.

Introspection

OperationCLI commandDescription
doc.statusstatusShow the current session status and document metadata.
doc.describedescribeList all available CLI operations and contract metadata.
doc.describeCommanddescribe commandShow detailed metadata for a single CLI operation.
  • Document API — the in-browser API that defines the operation set
  • CLI — use the same operations from the terminal