# `compact_email_thread` — De-duplicate Email Thread & RFC 5322 .eml

> Part of [Context Crush — Deterministic LLM Context Compactor](https://context-crush.apikeg.com/llms.txt) (`com.apikeg/context-crush`)

Decodes raw RFC 5322 .eml MIME messages (multipart/alternative, quoted-printable, base64) or pasted reply chains, strips O(N^2) repeated quoted history, mobile signatures, and legal disclaimers, and outputs chronological Markdown.

**Why call instead of DIY:** Avoids writing RFC 2047/quoted-printable/multipart MIME parsers and multi-client Outlook/Gmail quote splitters; collapses 10-reply O(N^2) threads by >80%.

- **REST Endpoint:** `POST https://context-crush.apikeg.com/v1/compact-email-thread`
- **MCP Server:** `https://context-crush.apikeg.com/mcp` (tool: `compact_email_thread`)
- **Pricing:** $0.001 base (up to $0.005 max ($0.001 base + $0.0005 per 50KB of input, capped at $0.005 for payloads up to 2MB), x402 variable settlement)
- **Free Dry-Run:** `POST https://context-crush.apikeg.com/v1/compact-email-thread?dry_run=true`

## Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "content": {
      "type": "string",
      "minLength": 1,
      "maxLength": 2000000,
      "description": "Raw RFC 5322 .eml MIME message (multipart/alternative, quoted-printable, base64) or pasted multi-reply email thread."
    },
    "stripSignatures": {
      "type": "boolean",
      "default": true,
      "description": "Strip mobile/client footers ('Sent from my iPhone', 'Get Outlook for iOS') and RFC 3676 '-- ' tails."
    },
    "stripDisclaimers": {
      "type": "boolean",
      "default": true,
      "description": "Strip standard corporate confidentiality and legal disclaimer footer blocks."
    }
  },
  "required": [
    "content"
  ],
  "additionalProperties": false
}
```

## Examples
### Peel nested Gmail & Outlook reply chain with legal footers
```bash
curl -X POST "https://context-crush.apikeg.com/v1/compact-email-thread" \
  -H "Content-Type: application/json" \
  -d '{"stripSignatures":true,"stripDisclaimers":true,"content":"Approved — let's lock in the annual tier.\n\nSent from my iPhone\n\nOn Tue, Nov 12, 2026 at 2:15 PM Alice Chen <alice@acme.com> wrote:\n> Can you confirm final pricing?\n>\n> CONFIDENTIALITY NOTICE: This email and any attachments are confidential."}'
```
Expected output: 2 chronological deduplicated messages + participant roster + stripped signature/disclaimer counts.
