# `audit_email_template` — Audit Outbound Email Template

> Part of [MailPreflight Email QA & Deliverability API](https://mail-preflight.apikeg.com/llms.txt) (`com.apikeg/mail-preflight`)

Runs a full pre-send deliverability, merge-tag, link-hygiene, Gmail 102KB clipping, and cross-client CSS compatibility audit (Outlook Windows, Gmail, Apple Mail Dark Mode) on an HTML email.

**Why call instead of DIY:** Audits 30+ email-client CSS quirks, 6 ESP merge syntaxes, and phishing/spam heuristics in <10ms for $0.003 without maintaining Can-I-Email rulesets.

- **REST Endpoint:** `POST https://mail-preflight.apikeg.com/v1/audit-email-template`
- **MCP Server:** `https://mail-preflight.apikeg.com/mcp` (tool: `audit_email_template`)
- **Pricing:** $0.003 USD per email template preflight audit (x402 instant micropayment)
- **Free Dry-Run:** `POST https://mail-preflight.apikeg.com/v1/audit-email-template?dry_run=true`

## Input JSON Schema
```json
{
  "type": "object",
  "properties": {
    "html": {
      "type": "string",
      "minLength": 1,
      "maxLength": 900000,
      "description": "Complete outbound HTML email payload to inspect for Gmail 102KB clipping, Outlook/Gmail/Dark Mode CSS support, link hygiene, and spam triggers."
    },
    "subject": {
      "type": "string",
      "maxLength": 998,
      "description": "Optional Subject header evaluated for unmerged placeholders, fake Re:/Fwd: prefixes, ALL-CAPS shouting, and punctuation triggers."
    },
    "preheader": {
      "type": "string",
      "maxLength": 1000,
      "description": "Optional preview/preheader snippet checked for unmerged merge tags and spam triggers."
    },
    "plainText": {
      "type": "string",
      "maxLength": 500000,
      "description": "Optional text/plain MIME companion body checked for unmerged placeholders and unsubscribe compliance."
    },
    "emailCategory": {
      "type": "string",
      "enum": [
        "transactional",
        "marketing",
        "cold_outreach"
      ],
      "default": "transactional",
      "description": "Outbound email class controlling compliance rules (marketing and cold_outreach require an unsubscribe mechanism)."
    }
  },
  "required": [
    "html"
  ],
  "additionalProperties": false
}
```

## Examples
### Marketing email preflight
```bash
curl -X POST "https://mail-preflight.apikeg.com/v1/audit-email-template" \
  -H "Content-Type: application/json" \
  -d '{"subject":"Welcome to Acme, {{first_name}}!","preheader":"Your workspace is provisioned.","emailCategory":"marketing","html":"<!DOCTYPE html><html><head><meta name=\"color-scheme\" content=\"light dark\"></head><body style=\"background-color:#f9fafb;\"><p>Hi there, <a href=\"https://acme.com/start\">Launch Workspace</a> · <a href=\"https://acme.com/unsubscribe\">Unsubscribe</a></p></body></html>"}'
```
Expected output: Flags unmerged {{first_name}} in subject as blocked with prioritized actionableFixes.
