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

# Control what the recipient sees first

> Attach cover pages, personalize with tokens, and use the HIPAA-compliant variant

## Outcome

After completing these steps you can attach cover pages to faxes through the mintfax API, personalize them with tokens, set environment-level defaults, build custom HTML cover pages, and use the HIPAA-compliant variant that strips patient-identifiable information from the rendered output.

## Prerequisites

* A mintfax account with a sandbox API key (`mfx_test_...`). See the [quickstart](/docs/quickstart) if you have not created one yet.
* Node.js 18 or later installed.
* The `node-fetch` and `form-data` packages (or Node 18+ built-in `fetch`).

## Step 1: Send a fax with a built-in cover page

Pass `cover_page` in the request body to attach a built-in template. Start with `standard`.

<CodeGroup>
  ```node theme={null}
  const fs = require("fs");
  const FormData = require("form-data");

  const form = new FormData();
  form.append("to", "+15005550001");
  form.append("file", fs.createReadStream("document.pdf"));
  form.append("cover_page", "standard");

  const response = await fetch("https://api.mintfax.com/v1/faxes", {
    method: "POST",
    headers: {
      Authorization: "Bearer mfx_test_abc123def456",
      ...form.getHeaders(),
    },
    body: form,
  });

  const fax = await response.json();
  console.log(fax.id, fax.status);
  ```
</CodeGroup>

**Verify** The response returns status `queued` and the fax renders with a cover page as the first page.

## Step 2: Personalize with tokens

Templates support tokens that mintfax replaces at send time. Wrap each token in double curly braces.

| Token                | Replaced with                                      |
| -------------------- | -------------------------------------------------- |
| `{{recipient_name}}` | Value of the `recipient_name` field on the request |
| `{{recipient_fax}}`  | The `to` number in E.164 format                    |
| `{{sender_name}}`    | Sender name from environment settings              |
| `{{sender_company}}` | Company name from environment settings             |
| `{{sender_fax}}`     | Sender fax number from environment settings        |
| `{{date}}`           | Send date in ISO 8601 (UTC)                        |
| `{{page_count}}`     | Total page count including the cover page          |
| `{{subject}}`        | Value of the `subject` field on the request        |
| `{{message}}`        | Value of the `message` field on the request        |

Pass token values as fields in the multipart request:

<CodeGroup>
  ```node theme={null}
  const form = new FormData();
  form.append("to", "+15005550001");
  form.append("file", fs.createReadStream("document.pdf"));
  form.append("cover_page", "standard");
  form.append("recipient_name", "Dr. Patel");
  form.append("subject", "Lab results - patient ID 40821");
  form.append("message", "Please see attached lab results.");

  const response = await fetch("https://api.mintfax.com/v1/faxes", {
    method: "POST",
    headers: {
      Authorization: "Bearer mfx_test_abc123def456",
      ...form.getHeaders(),
    },
    body: form,
  });
  ```
</CodeGroup>

**Verify** Retrieve the fax image with `GET /fax/{id}/image` and confirm the cover page shows the recipient name, subject, and message you provided.

## Step 3: Use the HIPAA-compliant cover page variant

The `hipaa` template prints a confidentiality notice and omits patient-identifiable tokens from the rendered output. You still pass `{{recipient_name}}` and `{{message}}` in the request, and mintfax stores them on the fax record for your own tracking. The cover page itself prints only the receiving number, sender company, page count, and the HIPAA confidentiality disclaimer.

<CodeGroup>
  ```node theme={null}
  const form = new FormData();
  form.append("to", "+15005550001");
  form.append("file", fs.createReadStream("lab-results.pdf"));
  form.append("cover_page", "hipaa");
  form.append("recipient_name", "Dr. Patel");
  form.append("subject", "Lab results");

  const response = await fetch("https://api.mintfax.com/v1/faxes", {
    method: "POST",
    headers: {
      Authorization: "Bearer mfx_test_abc123def456",
      ...form.getHeaders(),
    },
    body: form,
  });
  ```
</CodeGroup>

**Verify** The rendered cover page includes the confidentiality notice but does not display the recipient name or message text.

## Step 4: Build a custom HTML cover page

When you need full control over layout, pass a `cover_page_html` field with your own HTML instead. mintfax renders it as the first page of the fax. Tokens work the same way they do in built-in templates.

<CodeGroup>
  ```node theme={null}
  const coverHtml = `
  <html>
  <body style="font-family: sans-serif; padding: 40px;">
    <h1>{{sender_company}}</h1>
    <p>To: {{recipient_name}} ({{recipient_fax}})</p>
    <p>Date: {{date}}</p>
    <p>Pages: {{page_count}}</p>
    <hr />
    <p>{{message}}</p>
  </body>
  </html>
  `;

  const form = new FormData();
  form.append("to", "+15005550001");
  form.append("file", fs.createReadStream("document.pdf"));
  form.append("cover_page_html", coverHtml);
  form.append("recipient_name", "Records Dept");
  form.append("message", "Monthly compliance filing attached.");

  const response = await fetch("https://api.mintfax.com/v1/faxes", {
    method: "POST",
    headers: {
      Authorization: "Bearer mfx_test_abc123def456",
      ...form.getHeaders(),
    },
    body: form,
  });
  ```
</CodeGroup>

**Verify** Retrieve the fax image and confirm your custom layout renders correctly with the token values filled in.

## Step 5: Set an environment-level default cover page

You can set a default cover page at the environment level so you do not have to pass it on every request. Every fax from this environment uses the default unless the request overrides it.

<CodeGroup>
  ```node theme={null}
  const response = await fetch(
    "https://api.mintfax.com/v1/environment/fax-settings",
    {
      method: "PUT",
      headers: {
        Authorization: "Bearer mfx_test_abc123def456",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        cover_page: "standard",
      }),
    }
  );
  ```
</CodeGroup>

**Verify** Send a fax without a `cover_page` field. The fax should render with the `standard` cover page from your environment defaults.

To override the default on a single fax, pass `cover_page` or `cover_page_html` in the send request. To send a fax with no cover page at all when a default is set, pass `cover_page: "none"`.

## Verify

Send a fax to the sandbox success number `+15005550001` with a cover page attached. Retrieve the fax image with `GET /fax/{id}/image` and confirm the cover page renders as the first page with your token values filled in.

For HIPAA-regulated workflows, confirm that the `hipaa` template omits patient-identifiable information from the rendered cover page. The [glossary](/docs/glossary) defines fax-domain terms like [T.30](/docs/glossary#t30), [ECM](/docs/glossary#ecm), and [FoIP](/docs/glossary#foip) that appear in cover page rendering logs.

## What to do next

* [Glossary](/docs/glossary) - fax-domain terms referenced in this guide
* [Webhooks](/docs/webhooks) - receive delivery confirmation when your fax (with cover page) is delivered
* [Data retention](/docs/data-retention) - understand how long fax images, including cover pages, are stored
* [Sandbox](/docs/sandbox) - test cover page rendering with magic fax numbers
