
# Office tools

Two office surfaces, one engine (LibreOffice via Gotenberg), output always **PDF**:

- **`POST /v1/office/rescue`** — best-effort convert an *exotic or legacy* office format to PDF. The formats LibreOffice can import but you won't reach through the everyday [`from-office`](/docs/pdf-tools) route: Apple iWork, Visio, Publisher, CorelDRAW, WordPerfect, the legacy MS binaries, and flat ODF.
- **`GET /v1/office/formats`** — the free, no-auth roster of what each office route accepts.

The everyday office formats (`docx`, `xlsx`, `pptx`, `odt`, `ods`, `odp`, `rtf`, `txt`, `csv`) go through [`POST /v1/pdf/from-office`](/docs/pdf-tools). `office/rescue` is the premium, honest best-effort surface for the long-tail formats around it.

> **Fidelity is best-effort.** These are exotic, sometimes proprietary, sometimes very old formats. LibreOffice does its best to import them, and you get a clean PDF — but complex layout, fonts, or vector detail may not survive perfectly. The output is always a faithful-as-possible PDF, never a guarantee of pixel parity. And **office↔office conversion (e.g. docx↔odt) is not offered** — every office route outputs PDF.

## Rescue a legacy or exotic document

```bash
curl -X POST https://api.relaystation.ai/v1/office/rescue \
  -H 'Authorization: Bearer rs_live_<key>' \
  -H 'Idempotency-Key: rescue-visio-20260612' \
  -H 'Content-Type: application/json' \
  -d '{ "file": { "inline": "<base64 vsdx>" }, "filename": "network-diagram.vsdx" }'
```

Or on the lodestone path — no account, a signed x402 payment instead of an API key:

```bash
curl -X POST https://api.relaystation.ai/v1/office/rescue \
  -H 'X-Payment: <base64 EIP-3009 authorization>' \
  -H 'Idempotency-Key: rescue-visio-20260612' \
  -H 'Content-Type: application/json' \
  -d '{ "file": { "inline": "<base64 vsdx>" }, "filename": "network-diagram.vsdx" }'
```

The `filename` is required — its extension is how the format is recognized. Takes the standard input source (`{ "inline": "<b64>" }` ≤ 4 MB, or `{ "inputKey": "..." }` from [`POST /v1/cputools/upload-url`](/docs/persistence-tiers) for larger files) and returns the standard [output envelope](/docs/receiving-outputs) — a PDF inline when small, a presigned URL when large.

## The rescue roster

The default exotic/legacy roster (operator-tunable, so it can flex without a redeploy):

| Family | Extensions |
|---|---|
| Apple iWork | `pages`, `numbers`, `key` |
| Visio | `vsd`, `vsdx` |
| MS Publisher | `pub` |
| CorelDRAW | `cdr` |
| Flat ODF | `fodt` |
| Legacy MS Office binaries | `doc`, `xls`, `ppt` |
| WordPerfect | `wpd` |

`GET /v1/office/formats` is always authoritative. Free, read-only, no auth:

```bash
curl https://api.relaystation.ai/v1/office/formats
```

It returns the rescue roster and the everyday from-office roster, each with its output (`pdf`), plus an honest note that office↔office conversion is not offered:

```json
{
  "rescue": { "inputs": ["pages", "numbers", "key", "vsd", "vsdx", "pub", "cdr", "fodt", "doc", "xls", "ppt", "wpd"], "output": "pdf" },
  "fromOffice": { "inputs": ["docx", "xlsx", "pptx", "odt", "ods", "odp", "rtf", "txt", "csv"], "output": "pdf" },
  "note": "office↔office conversion (e.g. docx↔odt) is not offered; all office routes output PDF."
}
```

An extension outside the roster returns a free `422 UNSUPPORTED_FORMAT` that points you at `GET /v1/office/formats`.

## Export controls (from-office and rescue)

Both `POST /v1/pdf/from-office` and `POST /v1/office/rescue` accept an optional `options` object passed straight to LibreOffice's PDF export — absent fields take the engine default:

| Field | Type | Notes |
|---|---|---|
| `pageRanges` | string | a page subset, e.g. `"1-5,8"` |
| `quality` | integer 1–100 | JPEG quality for embedded images |
| `losslessImageCompression` | boolean | use lossless image compression |
| `reduceImageResolution` | boolean | gate for `maxImageResolution` — must be `true` for it to apply |
| `maxImageResolution` | one of `75`, `150`, `300`, `600`, `1200` | DPI ceiling for embedded images (a closed ladder; other values are rejected) |
| `landscape` | boolean | force landscape orientation |

```bash
curl -X POST https://api.relaystation.ai/v1/pdf/from-office \
  -H 'Authorization: Bearer rs_live_<key>' \
  -H 'Idempotency-Key: print-ready-20260612' \
  -H 'Content-Type: application/json' \
  -d '{ "file": { "inputKey": "<key>" }, "filename": "q3-report.docx",
        "options": { "pageRanges": "1-10", "reduceImageResolution": true, "maxImageResolution": 150, "landscape": true } }'
```

## Billing

| Route | Unit | Price |
|---|---|---|
| `office/rescue` | per call | $0.008 flat |
| `from-office` | per call | $0.005 flat |
| `office/formats` | — | free |

Rescue is priced a step above the everyday `from-office` route — it's heavier, best-effort work. Both are flat per convert (the output page count isn't known before the conversion runs). **Charge-on-attempt** — a convert that reaches the engine and succeeds stands; one that can't be delivered (a corrupt file, an upstream failure) returns `422 CONVERT_FAILED` and the charge is reversed: you pay only for a delivered PDF. Every billable call requires an `Idempotency-Key`; a same-key retry returns the cached result without re-charging.

## MCP tools

Callable over MCP at `https://api.relaystation.ai/mcp`: `office_rescue` (billable) and `office_formats` (free, read-only), plus `pdf_from_office` (the everyday route). Same auth, same prices as the HTTP routes.

## Next

[Quickstart](/docs/quickstart) · [Receiving outputs](/docs/receiving-outputs) · [Persistence tiers](/docs/persistence-tiers) · [PDF tools](/docs/pdf-tools) · [Document conversion](/docs/doc-convert) · [API reference](/api-reference)
