# Office OOXML Template Merge & Markdown Extractor API (v1.0.0)

> Brand-safe .docx/.pptx template merging (fixing Word split XML runs & table loops) and 85%+ token-saving .docx/.pptx/.xlsx Markdown extraction.

Zero-dependency Cloudflare Edge OOXML engine that merges .docx and .pptx templates (healing split XML runs, preserving run/cell styles, and expanding repeating table rows) and extracts .docx, .pptx, and .xlsx files into token-minimal Markdown.

## Why Agents Use This API Instead of DIY
Typing {{customer_name}} in Word or PowerPoint shatters placeholders across multiple <w:r>/<a:r> runs with <w:proofErr/> tags, breaking naive regex scripts and corrupting PKZIP CRC32 headers. This API heals split runs, clones styled table rows, and extracts clean Markdown in milliseconds.

## Connection & Payment (x402 Default + Optional Bearer API Key)
- **MCP Server (Streamable HTTP):** `https://office-template.apikeg.com/mcp` (Registry ID: `com.apikeg/office-template` — `initialize`, `tools/list`, `resources/*`, and `prompts/*` are free)
- **OpenAPI 3.1 Spec:** [openapi.json](https://office-template.apikeg.com/openapi.json)
- **Full Schema & Examples:** [llms-full.txt](https://office-template.apikeg.com/llms-full.txt)
- **RFC 9727 API Catalog:** [.well-known/api-catalog](https://office-template.apikeg.com/.well-known/api-catalog)
- **x402 Bazaar Manifest:** [.well-known/x402.json](https://office-template.apikeg.com/.well-known/x402.json)
- **MCP Discovery Manifest:** [.well-known/mcp.json](https://office-template.apikeg.com/.well-known/mcp.json)
- **A2A Agent Card:** [.well-known/agent-card.json](https://office-template.apikeg.com/.well-known/agent-card.json)
- **Primary Payment (Zero Signup):** Cloudflare Monetization Gateway (`HTTP 402` / `x402` v2 with USDC on Base).
- **Optional Monthly API Key:** Pass `Authorization: Bearer ak_live_...` ($5 / $20 / $50 monthly per-product Stripe plans at [apikeg.com/account](https://apikeg.com/account)).
- **Free Preflight:** Append `?dry_run=true` (or header `X-Dry-Run: true`) to validate any request payload at `$0.00` cost.

## Tools & REST Endpoints
- [`merge_office_template`](https://office-template.apikeg.com/tools/merge-office-template.md) (`POST https://office-template.apikeg.com/v1/merge-office-template`) — $0.004 USD per Office template merge (.docx or .pptx) (x402 instant micropayment): Coalesces split {{variable}} runs across Word (<w:r>) and PowerPoint (<a:r>) paragraphs while preserving opening-run typography, expands {{#loop}}...{{/loop}} table rows, replaces variables across body/headers/footers/slides, and returns a valid PKZIP Base64 document plus any unmatchedPlaceholders.
- [`extract_office_markdown`](https://office-template.apikeg.com/tools/extract-office-markdown.md) (`POST https://office-template.apikeg.com/v1/extract-office-markdown`) — $0.002 USD per Office document extraction (.docx, .pptx, or .xlsx) (x402 instant micropayment): Auto-detects .docx, .pptx, or .xlsx from OOXML structure and converts headings, lists, Word/PowerPoint tables, numerically ordered slides, speaker notes, and sparse Excel worksheets into compact GitHub-Flavored Markdown with token-savings telemetry.

## Instant MCP Configuration
```json
{
  "mcpServers": {
    "office-template": {
      "type": "streamable-http",
      "url": "https://office-template.apikeg.com/mcp"
    }
  }
}
```

## Common Agent Use Cases
- merge docx template variables API without breaking formatting
- fix Word split XML runs placeholder replacement MCP
- generate PowerPoint pptx deck from template JSON variables
- convert docx pptx xlsx to clean LLM Markdown API
- populate invoice table rows in Word docx template
