Custom Templates for mail via API

Configure custom Templates and send thousands of customized letters with Mailform's API

Letter Template System - Automated Document Generation & Mail API

Overview

The Letter Template System is a powerful visual editor and API-driven solution for creating, managing, and sending personalized physical mail at scale. Design professional letter templates with your branding, embed dynamic variables, and generate thousands of customized letters through a simple REST API integration.

Key Features

Visual Template Editor

Create professional letter templates with an intuitive split-screen interface. Real-time preview shows exactly how your letters will look when printed and mailed. No coding required for template design.

Dynamic Variable System

Insert variables anywhere in your templates using simple {{variable_name}} syntax. Personalize each letter with recipient-specific data including names, addresses, amounts, dates, and custom fields. Variables are automatically populated when you submit orders through the API.

Logo & Branding Integration

Upload and embed your company logo directly into templates. Logos are stored as base64-encoded images within the template, ensuring consistent branding across all mailings. Build a reusable logo library for multi-brand organizations.

QR Code Generation

Embed QR codes in your letters for enhanced customer engagement. Two modes supported:

RESTful API Integration

Send letters programmatically through a simple multipart form data API. Submit recipient addresses, sender information, template GUID, and variable data in a single API call. Supports all major USPS mail classes including First Class, Certified, and Priority Mail.

Template Management

Use Cases

Debt Collection & Legal Notices

Send personalized payment reminders, collection notices, and legal correspondence with proper formatting and tracking. Embed account balances, payment due dates, and case numbers as variables.

Healthcare & Medical Billing

Automate patient statements, appointment reminders, and explanation of benefits letters. Include personalized amounts due, service dates, and provider information.

Financial Services

Generate account statements, loan notifications, tax documents, and compliance mailings. Maintain regulatory compliance with consistent formatting and audit trails.

Government & Municipal Services

Send tax notices, permit approvals, violation notices, and public notifications. Scale from single letters to mass mailings with the same template.

E-Commerce & Retail

Create personalized thank you letters, promotional offers, and customer appreciation mailings. Drive online engagement with QR codes linking to exclusive offers.

Non-Profit & Fundraising

Send donation acknowledgments, event invitations, and impact reports with personalized donor information and contribution amounts.

Technical Capabilities

Supported Mail Services

Template Specifications

API Features

Data Security

Integration Workflow

  1. Design Template: Use the visual editor to create your letter layout with logos, text blocks, and QR codes
  2. Add Variables: Insert dynamic placeholders like {{first_name}}{{balance_due}}{{due_date}}
  3. Save Template: Template is stored with a unique GUID for API reference
  4. API Integration: Copy the auto-generated curl command and integrate into your application
  5. Submit Orders: Send API requests with recipient data and variable values
  6. Automated Fulfillment: Letters are printed, inserted into envelopes, and mailed via USPS

Benefits

Time Savings

Eliminate manual letter creation and mailing processes. What once took hours now takes seconds. Scale from 1 letter to 10,000 letters with the same effort.

Cost Efficiency

No need for in-house printing equipment, envelope stuffing, or postage management. Pay only for letters you send with transparent per-piece pricing.

Personalization at Scale

Send uniquely customized letters to every recipient while maintaining brand consistency. Increase engagement rates with personalized content.

Developer-Friendly API

Simple REST API integration works with any programming language. Comprehensive documentation, working examples, and curl commands included.

Brand Consistency

Centralized template management ensures every letter matches your brand guidelines. No more inconsistent formatting or outdated logos.

Compliance & Tracking

Built-in audit trails for regulatory compliance. Track every letter from creation to delivery with detailed status updates.

SEO Keywords

Letter template system, automated mail API, personalized letter printing, REST API mail service, USPS API integration, bulk mail automation, template-based document generation, variable data printing, QR code mail integration, programmatic mail sending, direct mail API, letter personalization software, automated document fulfillment, mail merge API, physical mail automation

Getting Started

Create your first template in minutes. The visual editor guides you through every step with helpful hints and real-time preview. Once your template is saved, copy the API integration example and start sending personalized letters immediately.

No special software required. No printing equipment needed. No postage management headaches. Just design, integrate, and send.

 

Customer Release Notes: Template Features

Overview

We've added powerful template capabilities to the Mailform API, allowing you to create reusable letter templates with dynamic variables. This enables mail merge functionality for personalized letters at scale.

What's New

1. Template Management

2. Bulk Import with Templates

3. API Template Orders Create orders using templates via the /api/v1/orders endpoint:

curl -X POST https://api.mailform.io/app/api/v1/orders \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "template=YOUR_TEMPLATE_GUID" \
  -F "service=USPS_FIRST_CLASS" \
  -F "to.name=John Smith" \
  -F "to.address1=123 Main St" \
  -F "to.city=Boston" \
  -F "to.state=MA" \
  -F "to.postcode=02101" \
  -F "to.country=US" \
  --form-string 'variables={"first_name":"John","case_number":"2024-CV-1234"}'

4. PDF Preview Endpoint (NEW) Preview your rendered template without creating an order:

curl -X POST https://api.mailform.io/app/v1/documenttemplates/render \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "template=YOUR_TEMPLATE_GUID" \
  --form-string 'variables={"first_name":"John","venue":"Boston Court"}' \
  -o preview.pdf

Returns the rendered PDF binary. Use this to validate your templates and variables before submitting orders.


API Error Reference

Error Code HTTP Status Description
template_not_found 404 Template GUID not found or not authorized
template_parse_error 400 Template HTML contains invalid Mustache syntax
missing_variables 400 Required template variables not provided
invalid_request 400 Missing or invalid parameters
generation_failed 500 PDF generation failed

Missing Variables Response Example:

{
  "error": "missing_variables",
  "detail": {
    "missing_variables": ["case_number", "hearing_date"],
    "required_variables": ["first_name", "case_number", "hearing_date", "venue"],
    "unused_variables": ["extra_field"]
  }
}

A/B Testing with Templates

Run A/B tests on your mail campaigns using templates:

  1. Create Variants - Create multiple template versions (e.g., notice_version_anotice_version_b)

  2. Randomize Selection - Use your own logic to select which template GUID to use:

    const templates = {
      a: 'guid-for-version-a',
      b: 'guid-for-version-b'
    };
    const variant = Math.random() < 0.5 ? 'a' : 'b';
    const templateGuid = templates[variant];
    
  3. Track Variants - Use the customer_reference field to identify which variant was sent:

    -F "customer_reference=campaign_2024_variant_a"
    
  4. Analyze Results - Compare delivery and response metrics by customer_reference to measure effectiveness


Template Variables

Templates use Mustache syntax for variables:

<p>Dear {{first_name}},</p>
<p>Your case number {{case_number}} is scheduled for 
   {{hearing_date}} at {{venue}}.</p>

Variable Rules:


CSV Template Download

From the Templates page, click the download icon on any template to get a pre-formatted CSV with:

This makes it easy to prepare bulk import files that match your template's requirements.


Best Practices

  1. Test First - Use the /render endpoint to preview before creating orders
  2. Validate Variables - The API will return which variables are missing
  3. Use customer_reference - Track campaigns, variants, or internal IDs
  4. Download CSV Templates - Get pre-formatted files from the Templates page

Ready to automate your physical mail? Start creating templates today and transform how your organization communicates through postal mail.

How can we help?

Your Email:

Request Callback?:

Subject:

Message:

Attachment:

{{attachment.name}} ()
NOTE Please upload multiple attachments as a single zip file.

Schedule a quick call to learn more about how Mailform can help you.

These happy customers and businesses are using Mailform

"Mailform saves me time. Period."

- Alex Andon, Simility

"We print monthly invoices and the quick support is fantastic!"

- Brett Florio, FoxyCart