Skip to main content

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.

Cover-page templating with tokens

Outcome

After completing these steps you can attach cover pages to faxes through the mintfax API, personalize them with tokens, set workspace-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 (fx_test_...). See the 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.
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/fax", {
  method: "POST",
  headers: {
    Authorization: "Bearer fx_test_abc123def456",
    ...form.getHeaders(),
  },
  body: form,
});

const fax = await response.json();
console.log(fax.id, fax.status);
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.
TokenReplaced 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 workspace settings
{{sender_company}}Company name from workspace settings
{{sender_fax}}Sender fax number from workspace 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:
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/fax", {
  method: "POST",
  headers: {
    Authorization: "Bearer fx_test_abc123def456",
    ...form.getHeaders(),
  },
  body: form,
});
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.
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/fax", {
  method: "POST",
  headers: {
    Authorization: "Bearer fx_test_abc123def456",
    ...form.getHeaders(),
  },
  body: form,
});
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.
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/fax", {
  method: "POST",
  headers: {
    Authorization: "Bearer fx_test_abc123def456",
    ...form.getHeaders(),
  },
  body: form,
});
Verify Retrieve the fax image and confirm your custom layout renders correctly with the token values filled in.

Step 5: Set a workspace-level default cover page

You can set a default cover page at the workspace level so you do not have to pass it on every request. Every fax from this workspace uses the default unless the request overrides it.
const response = await fetch(
  "https://api.mintfax.com/v1/account/fax-settings",
  {
    method: "PUT",
    headers: {
      Authorization: "Bearer fx_test_abc123def456",
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      cover_page: "standard",
    }),
  }
);
Verify Send a fax without a cover_page field. The fax should render with the standard cover page from your workspace 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 defines fax-domain terms like T.30, ECM, and FoIP that appear in cover page rendering logs.

What to do next

  • Glossary - fax-domain terms referenced in this guide
  • Webhooks - receive delivery confirmation when your fax (with cover page) is delivered
  • Data retention - understand how long fax images, including cover pages, are stored
  • Sandbox - test cover page rendering with magic fax numbers