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

# Email pre-test

> Create a marketing email pre-test.

Use `channel: "email"` for emails. The creative is an **image** of the email (a capture of the piece): video is not accepted and responds [`upload_invalid`](https://docs.myunite.ai/en/errors#upload_invalid).

## Fields

| Field | Required | Description |
| - | - | - |
| `uploadId` | Yes | Image of the email. |
| `channel` | Yes | `email`. |
| `email.subject` | Yes | Subject, not empty (up to 500 characters). |
| `email.preheader` | Yes | Preheader, not empty (up to 500 characters). |
| `email.stage` | No | `draft` (default) or `final_review`. |
| `email.type` | No | `promotional`, `newsletter`, `transactional`, `lifecycle` or `welcome`. |
| `title`, `brandId`, `locale`, `metadata` | No | Same as the [OOH pre-test](https://docs.myunite.ai/en/pretests/ooh.md). |

## Example

```bash curl theme={null}
curl -X POST https://myunite.ai/api/v1/pretests \
  -H "Authorization: Bearer $UNITE_API_KEY" \
  -H "Idempotency-Key: summer-urban-clock-email-001" \
  -H "Content-Type: application/json" \
  -d '{
    "uploadId": "upl_0123456789abcdef0123456789abcdef.png",
    "title": "Summer · urban clock",
    "channel": "email",
    "email": {
      "subject": "The summer clock has arrived",
      "preheader": "Limited edition, this week only",
      "stage": "draft",
      "type": "promotional"
    }
  }'
```

```javascript JavaScript theme={null}
const res = await fetch("https://myunite.ai/api/v1/pretests", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.UNITE_API_KEY}`,
    "Idempotency-Key": "summer-urban-clock-email-001",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    uploadId: "upl_0123456789abcdef0123456789abcdef.png",
    title: "Summer · urban clock",
    channel: "email",
    email: {
      subject: "The summer clock has arrived",
      preheader: "Limited edition, this week only",
      stage: "draft",
      type: "promotional",
    },
  }),
});
console.log(res.status, await res.json()); // 202
```

```python Python theme={null}
import os
import requests

res = requests.post(
    "https://myunite.ai/api/v1/pretests",
    headers={
        "Authorization": f"Bearer {os.environ['UNITE_API_KEY']}",
        "Idempotency-Key": "summer-urban-clock-email-001",
    },
    json={
        "uploadId": "upl_0123456789abcdef0123456789abcdef.png",
        "title": "Summer · urban clock",
        "channel": "email",
        "email": {
            "subject": "The summer clock has arrived",
            "preheader": "Limited edition, this week only",
            "stage": "draft",
            "type": "promotional",
        },
    },
)
print(res.status_code, res.json())  # 202
```

## Analysis PDF

The PDF of an email pre-test is only generated when you ask for it (through `GET /pretests/{id}/report` or an export in the product), and the [`pretest.report_ready`](https://docs.myunite.ai/en/webhooks) event only arrives after that. Do not wait for that event without requesting the PDF first. Until then, `report.status` stays `pending`. Call `GET /pretests/{id}/report` with the pre-test in `completed`: the response is `202` with `Retry-After` while the PDF is generated and `200` with the `url` when it is ready. The step by step is in the [first pre-test](https://docs.myunite.ai/en/quickstart.md). The full result is also in the `result` field (see [Results](https://docs.myunite.ai/en/results.md)).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.