Create Word document (.docx)

$0.003 per callUSDC via x402POST /api/docx-create

Turn markdown into a real Word document (.docx) in one call. Send POST /api/docx-create with the required field markdown and pay $0.003 per call over x402 or MPP (there is no free tier). It returns a JSON object with docxBase64, bytes, contentType, filename, blocks and 5 more.

Send "markdown" and an optional "title": headings, paragraphs, bold, italic, strikethrough, inline code, bullet and numbered lists (nested), task lists, tables, code blocks, block quotes, horizontal rules and links come out as native Word formatting. A link is written as a hyperlink; an image is written as its alt text linked to its address and is never fetched. Up to 100,000 characters, 5,000 blocks, tables of 200 rows by 20 columns and 25,000 table cells in all (a short row counts at its header's width), nesting 8 levels of blocks and 16 of inline formatting. The request body may be up to 2 MB. Returns the file as base64 with its size, content type and filename.

Category: Data conversionTags: word docx document create-word markdown-to-docx office export report

Try in playground →

Parameters

NameTypeRequiredDescription
markdownstringyesDocument body as markdown (GitHub flavor), up to 100,000 characters
titlestringnoOptional title, written as the document's Title paragraph and its title property (up to 500 characters)
filenamestringnoFile name for the answer (default "document.docx")

Example request

curl -i -X POST https://agent402.tools/api/docx-create \
  -H "Content-Type: application/json" \
  -d '{"title":"Quarterly update","markdown":"## Highlights\n\nRevenue grew **12%** and churn fell to *2.1%*.\n\n- Two new regions\n- Support hours extended\n\n1. Hire two engineers\n2. Ship the billing export\n\n| Region | Units |\n|---|---:|\n| North | 1200 |\n| South | 860 |\n\n```\nnpm run report\n```\n\nDetails at [the status page](https://agent402.tools/status).","filename":"update.docx"}'

Without payment this returns HTTP 402 Payment Required with the exact price for docx-create; any x402 v2 or MPP client pays it and retries.

Example response

{
  "docxBase64": "UEsDBAoAAAAAAG...",
  "bytes": 10520,
  "contentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
  "filename": "update.docx",
  "blocks": 10,
  "headings": 1,
  "tables": 1,
  "listItems": 4,
  "codeBlocks": 1,
  "links": 1
}
FieldTypeAlways presentIn the example
docxBase64stringyesUEsDBAoAAAAAAG...
bytesnumberyes10520
contentTypestringyesapplication/vnd.openxmlformats-officedocument.wordprocessingml.document
filenamestringyesupdate.docx
blocksnumberyes10
headingsnumberyes1
tablesnumberyes1
listItemsnumberyes4
codeBlocksnumberyes1
linksnumberyes1

From an MCP client

catalog.call {
  "slug": "docx-create",
  "params": {
    "title": "Quarterly update",
    "markdown": "## Highlights\n\nRevenue grew **12%** and churn fell to *2.1%*.\n\n- Two new regions\n- Support hours extended\n\n1. Hire two engineers\n2. Ship the billing export\n\n| Region | Units |\n|---|---:|\n| North | 1200 |\n| South | 860 |\n\n```\nnpm run report\n```\n\nDetails at [the status page](https://agent402.tools/status).",
    "filename": "update.docx"
  }
}

The hosted connector at https://agent402.tools/mcp needs a payment for docx-create; the stdio package pays it from a wallet or from an AGENT402_CREDITS_KEY issued earlier. Local install: npx -y [email protected].

Errors and behavior

Paid call (JavaScript agent)

import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { registerExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client();
client.setSpendControls?.({ maxAmountPerPayment: "$0.003" }); // refuse any quote above this tool's price
registerExactEvmScheme(client, { signer: privateKeyToAccount(KEY) });
const payFetch = wrapFetchWithPayment(fetch, client);

const res = await payFetch("https://agent402.tools/api/docx-create", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
    "title": "Quarterly update",
    "markdown": "## Highlights\n\nRevenue grew **12%** and churn fell to *2.1%*.\n\n- Two new regions\n- Support hours extended\n\n1. Hire two engineers\n2. Ship the billing export\n\n| Region | Units |\n|---|---:|\n| North | 1200 |\n| South | 860 |\n\n```\nnpm run report\n```\n\nDetails at [the status page](https://agent402.tools/status).",
    "filename": "update.docx"
  }),
});

Related tools

Create PowerPoint deck (.pptx)

$0.003 · POST /api/pptx-create

Turn slide outlines into a real PowerPoint deck (.pptx, 16:9) in one call.

Create Excel spreadsheet (.xlsx)

$0.003 · POST /api/xlsx-create

Turn rows of data into a real Excel workbook (.xlsx) in one call.

Base / radix convert

FREE w/ compute · or $0.001 · POST /api/base-convert

Convert an integer between number bases (radix 2-36), e.g. binary↔hex↔decimal.

CSV to JSON

FREE w/ compute · or $0.002 · POST /api/csv-to-json

Parse CSV (quoted fields supported) into a JSON array of objects, using the first row as headers (header=false.

CSV to Markdown table

FREE w/ compute · or $0.002 · POST /api/csv-to-md

Convert CSV into a GitHub-flavored Markdown table (first row is the header).

HTML to Markdown

FREE w/ compute · or $0.001 · POST /api/html-to-markdown

Convert an HTML fragment or document you already have into clean markdown.