> ## Documentation Index
> Fetch the complete documentation index at: https://docs.khaime.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Preview Email Template

> Render a draft subject/body against sample data before saving it.

# Preview Email Template

Renders arbitrary subject/body content against a hard-coded set of sample RFQ/quote/customer data, wrapped in Khaime's standard email layout — without saving anything. Use this to check a template renders correctly before calling [Upsert Email Template](/api-reference/b2b/upsert-email-template).

## Request Body

<ParamField body="subject" type="string" required>
  Subject line to render, max 255 characters. Not persisted.
</ParamField>

<ParamField body="html_body" type="string" required>
  HTML body to render. Not persisted.
</ParamField>

## Response

```json theme={null}
{
  "success": true,
  "message": "Template preview generated successfully",
  "data": {
    "subject": "Your quote from Acme Corp is ready to review",
    "html": "<html>...fully wrapped, rendered HTML...</html>"
  }
}
```

`html` is the fully wrapped, rendered output — same layout wrapper used for real sends. The sample data used for placeholders is fixed server-side; you cannot supply your own preview data. See [Upsert Email Template § Template Variables](/api-reference/b2b/upsert-email-template#template-variables) for the full list of `{{variable}}` placeholders available and which event types populate which ones — the fixed preview data covers most of them, but not conditional fields like `rejection_reason`.

## Error Codes

| Status | Cause                                                               |
| ------ | ------------------------------------------------------------------- |
| `422`  | `subject` or `html_body` missing, or `subject` over 255 characters. |

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.khaime.com/api/v1/partner/email-templates/preview \
    -H "X-API-Key: pk_sandbox_your_key" \
    -H "Content-Type: application/json" \
    -d '{
      "subject": "Your quote from {{business_name}} is ready",
      "html_body": "<html><body>Hi {{customer_name}}, your quote is ready.</body></html>"
    }'
  ```
</RequestExample>
