Skip to main content

Installation

npm install agent-office-sdk

Documentation

View the full SDK documentation on npm:

agent-office-sdk on npm

Complete TypeScript SDK documentation and API reference

Quick Example

import { AgentOffice } from "agent-office-sdk";
import { v4 as uuidv4 } from "uuid";
import fs from "fs";

const client = new AgentOffice({
  apiKey: process.env.AGENT_OFFICE_API_KEY || "",
});

const fileBuffer = fs.readFileSync("document.docx");
const file = new File([fileBuffer], "document.docx", {
  type: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
});

// Upload with tracked changes enabled
const { docId, markdown } = await client.documents.create({
  file: file,
  returnMarkdown: true,
  trackedChanges: true,
  authorName: "John Doe",
});

// Edit the document
const editResult = await client.edit({
  docId: docId,
  editUid: uuidv4(),
  editInstructions: "Change the title to 'My New Title'",
  saveChunksForReview: false,
});

// Download the edited document
const { downloadUrl } = await client.documents.download({
  docId: docId,
});