# `extract_office_markdown` — Extract Token-Minimal Markdown from .docx, .pptx, or .xlsx

> Part of [Office OOXML Template Merge & Markdown Extractor API](https://office-template.apikeg.com/llms.txt) (`com.apikeg/office-template`)

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.

**Why call instead of DIY:** Saves 80-95% of context window tokens vs raw OOXML dumps and handles Excel sharedStrings.xml + sparse cell coordinates (A1, D5) without external libraries.

- **REST Endpoint:** `POST https://office-template.apikeg.com/v1/extract-office-markdown`
- **MCP Server:** `https://office-template.apikeg.com/mcp` (tool: `extract_office_markdown`)
- **Pricing:** $0.002 USD per Office document extraction (.docx, .pptx, or .xlsx) (x402 instant micropayment)
- **Free Dry-Run:** `POST https://office-template.apikeg.com/v1/extract-office-markdown?dry_run=true`

## Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "fileBase64": {
      "type": "string",
      "minLength": 16,
      "description": "Base64-encoded .docx, .pptx, or .xlsx OOXML file to convert into token-minimal Markdown."
    },
    "includeSpeakerNotes": {
      "type": "boolean",
      "default": true,
      "description": "Include speaker notes from ppt/notesSlides/notesSlide*.xml when extracting .pptx presentations."
    },
    "maxRowsPerSheet": {
      "type": "integer",
      "default": 500,
      "minimum": 1,
      "maximum": 5000,
      "description": "Maximum non-empty rows emitted per .xlsx worksheet."
    }
  },
  "required": [
    "fileBase64"
  ],
  "additionalProperties": false
}
```

## Examples
### Extract slides & speaker notes from .pptx deck
```bash
curl -X POST "https://office-template.apikeg.com/v1/extract-office-markdown" \
  -H "Content-Type: application/json" \
  -d '{"fileBase64":"UEsDBBQAAAAIA...","includeSpeakerNotes":true,"maxRowsPerSheet":500}'
```
Expected output: Returns format='pptx', ordered '## Slide N: Title' Markdown with pipe tables and speaker notes, plus token reduction stats.
