# Preview Campaign Email

> Render a subject and body with spin syntax and merge tags filled in.

Requires an API key with the `read` scope.

Nothing is sent and nothing is stored. Spin syntax like `{Hi|Hello}` is resolved to one choice and merge tags like `{{firstName}}` are filled from the lead you name, or from sample data (John Doe, Acme Inc., Marketing Manager) when you omit `leadId` or the lead is not in this workspace. Three sample variations of the subject and of the body are returned as well.


## Path Parameters

<ParamField path="campaign_id" type="string" required>The campaign.</ParamField>

## Request Body

<ParamField body="subject" type="string" required>Subject template, up to 500 characters.</ParamField>
<ParamField body="body" type="string" required>Body template, up to 200,000 characters.</ParamField>
<ParamField body="leadId" type="string">Fill merge tags from this lead.</ParamField>

## Response

<ResponseField name="data" type="object">
  <Expandable title="Preview">
    <ResponseField name="subject" type="string">The rendered subject.</ResponseField>
    <ResponseField name="body" type="string">The rendered body.</ResponseField>
    <ResponseField name="subjectVariations" type="string[]">Three other renderings of the subject.</ResponseField>
    <ResponseField name="bodyVariations" type="string[]">Three other renderings of the body.</ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
```bash cURL
curl -X POST "https://api.foxreach.io/api/v1/campaigns/cmcamp1/preview" \
  -H "X-API-Key: otr_your_key" \
  -H "Content-Type: application/json" \
  -d '{"subject": "Hi {{firstName}}", "body": "{Hello|Hi} {{firstName}}, quick question."}'
```

```python Python SDK
from foxreach import FoxReach

client = FoxReach(api_key="otr_your_key")
preview = client.campaigns.preview("cmcamp1", "Hi {{firstName}}", "{Hello|Hi} {{firstName}}, quick question.")
```

```typescript TypeScript SDK
import { FoxReach } from "foxreach";

const client = new FoxReach({ apiKey: "otr_your_key" });
const preview = await client.campaigns.preview("cmcamp1", { subject: "Hi {{firstName}}", body: "{Hello|Hi} {{firstName}}, quick question." });
```
</RequestExample>

<ResponseExample>
```json
{
  "data": {
    "subject": "Hi John",
    "body": "Hello John, quick question.",
    "subjectVariations": ["Hi John", "Hi John", "Hi John"],
    "bodyVariations": ["Hi John, quick question.", "Hello John, quick question.", "Hello John, quick question."]
  }
}
```
</ResponseExample>

## Errors

| Status | Description |
|--------|-------------|
| `401` | Missing, invalid, revoked or expired API key |
| `403` | API key does not have the required scope: `read` |
| `404` | Campaign not found in this workspace |

## Rate Limit

- **300 requests per minute, shared by every `read` call in your workspace.** Fixed 60-second window.
- Every response includes `X-RateLimit-Limit`, `X-RateLimit-Remaining`, `X-RateLimit-Reset` (unix epoch seconds) and `X-RateLimit-Bucket` (`read`).
- A `429` response includes a `Retry-After` header (seconds until the bucket resets).

For client-side patterns (`Retry-After`, exponential backoff, monitoring `X-RateLimit-Remaining`), see [Rate Limiting](/rate-limiting).
