# preview_flow_email

Returns merchant plus rendered subject/body, or merchant plus an AI draft when brief was supplied..

## Purpose

Render a template subject/body (merge tags like &#123;&#123; first_name &#125;&#125;) against a real merchant, or generate a sample AI draft from a brief. Nothing is sent.

## Credentials and scope

Owner workspace credential. The credential determines tool visibility. For tools with appId, use the HeyCrust app UUID from list_apps; the dashboard app selector does not supply MCP arguments for you.

## Inputs

- `subject`: optional; string
- `body`: optional; string
- `brief`: optional; string
- `shopDomainOrInstallId`: optional; string

## Example request

The identifiers and merchant are fictional. Replace them with records returned for your own workspace; this example is schema-checked, not a promise that the fictional record exists.

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "preview_flow_email",
    "arguments": {
      "subject": "Welcome to {{ app_name }}",
      "body": "Hi {{ first_name | \"there\" }}, welcome.",
      "shopDomainOrInstallId": "example.myshopify.com"
    }
  }
}
```

POST this JSON to `https://heycrust.com/api/mcp` with `Content-Type: application/json` and `Authorization: Bearer <YOUR_CREDENTIAL>`. The tool result normally contains JSON encoded as text in `result.content`; inspect JSON-RPC errors and `result.isError` before using it.

## Result

Returns merchant plus rendered subject/body, or merchant plus an AI draft when brief was supplied.

## Effects and verification

Without brief, renders supplied templates against a preview merchant. With brief, it calls the configured AI draft provider. Neither branch sends the email. An AI preview still transmits draft context to the configured provider and requires appropriate approval.

## Troubleshooting

A missing tool can mean that the credential lacks its catalog or required scopes. Invalid arguments are different from unavailable source data or a record outside the workspace. A handler can return a business error even when the argument schema is valid. Read [MCP overview](/docs/mcp) and [Help](/docs/help).
