Skip to main content
Back to Blog
Physical Mail API for Developers: How to Automate Letters
Direct Mail MarketingMay 20, 2026

Physical Mail API for Developers: How to Automate Letters

W

WriteToMail Team

Physical mail sounds like a solved problem — until you're the developer who gets asked to automate it. Suddenly you're looking at printer vendor docs, USPS postal regulations, and a stack of variables that don't map cleanly to any REST endpoint you've ever touched.

This guide is for developers who need to send real, physical letters programmatically. Whether you're building triggered billing notices, automating legal correspondence, or adding physical mail to a customer communication workflow, the core decision tree looks the same: build it yourself or integrate with a physical mail API.

Spoiler: building it yourself is almost always the wrong call.


Table of Contents

  1. What Is a Physical Mail API?
  2. Why Developers Need Mail Automation
  3. Key Use Cases for Automated Physical Mail
  4. How a Physical Mail API Works
  5. Build vs. Buy: The Real Cost Analysis
  6. Comparing Physical Mail API Providers
  7. WriteToMail as a Developer-Friendly Option
  8. Integration Patterns and Triggers
  9. Compliance Considerations
  10. FAQ

What Is a Physical Mail API?

A physical mail API is a programmatic interface that lets your application send real, printed, physical mail — letters, postcards, or checks — without managing any printing hardware, postage accounts, or postal logistics.

You make an API call (or trigger a workflow), pass in the recipient address and document content, and the service handles the rest: printing, enveloping, stamping, and USPS delivery.

The analogy is close to an email API like SendGrid or Mailgun, but the output is a physical document dropped in someone's mailbox, not an inbox.

From a developer's perspective, this matters because:

  • Physical mail has legal standing that digital communication often lacks
  • Response rates for physical mail are significantly higher than email for certain use cases
  • Regulatory requirements in healthcare, law, and finance sometimes mandate physical delivery

Why Developers Need Mail Automation

This isn't a niche problem. Mail automation comes up across industries because some communications simply can't live in email.

According to USPS data on mail response rates, direct mail generates an average response rate of 9% for house lists — compared to email's 1%. For collections and billing, physical notices often carry legal weight that digital messages don't.

Healthcare is a clear example. HIPAA mandates specific handling for patient data, and physical letters remain the preferred channel for billing, lab results, and appointment reminders in many clinical contexts. Legal firms face similar requirements — demand letters, cease and desist notices, and court correspondence often need USPS delivery to establish a paper trail.

For developers, the trigger is usually this: someone in legal, finance, or operations says "we need to send X by physical mail," and the question becomes how to operationalize that at scale without standing up a print shop.


Key Use Cases for Automated Physical Mail

Triggered Billing Notices

Accounts receivable teams need overdue invoices to go out automatically when a payment misses a deadline. Wiring physical mail into your billing system — so that a failed payment at day 30 automatically generates a mailed notice at day 31 — is exactly what a mail API enables.

Legal Letters and Demand Notices

Law firms and legal departments send high volumes of standardized legal correspondence. A physical mail API integrated into a case management system can automate demand letters, lease violation notices, and client communications — cutting paralegal overhead and maintaining delivery records.

Customer Re-Engagement

Some customers stop responding to email. A physical letter, triggered when email engagement drops below a threshold, can outperform a dozen digital retargeting ads. This is a legitimate use case in SaaS, subscription boxes, and insurance.

Government and Regulatory Notices

Applications serving healthcare providers, financial advisors, or utilities often need to generate regulatory-compliant physical notices. A HIPAA-compliant mail API can handle patient billing and benefit notices at scale. See the HIPAA-compliant physical mail guide for what that compliance actually requires.

Real Estate and Property Management

Lease renewals, rent increase notices, and eviction proceedings all require physical delivery in most jurisdictions. Automating these through a property management platform via API is a clean solution to a recurring compliance headache.


How a Physical Mail API Works

The workflow is simpler than most developers expect:

  1. Authenticate — obtain an API key from the provider
  2. Compose — pass document content (HTML, PDF, or plain text) as part of the request payload
  3. Address — include recipient name and mailing address
  4. Submit — POST the request to the provider's endpoint
  5. Track — receive a job ID and poll (or receive webhook callbacks) for status updates

A minimal pseudocode example:

POST /v1/letters
{
  "to": {
    "name": "Jane Smith",
    "address_line1": "123 Main St",
    "city": "Austin",
    "state": "TX",
    "zip": "78701"
  },
  "from": {
    "name": "Acme Corp",
    "address_line1": "456 Commerce Blvd",
    "city": "Dallas",
    "state": "TX",
    "zip": "75201"
  },
  "content": "Dear Jane, your invoice for $247.00 is now 30 days overdue...",
  "mail_class": "first_class"
}

The provider prints, stuffs an envelope, applies postage, and hands it to USPS — typically within 1 business day.

Some providers support HTML templates with variable substitution, PDF uploads, and duplex printing. The more sophisticated APIs also support address verification and CASS certification to reduce undeliverable mail.


Build vs. Buy: The Real Cost Analysis

Building your own print-and-mail infrastructure is a path that sounds reasonable until you price it out.

What "building it" actually involves:

  • Commercial-grade printer procurement and maintenance
  • USPS Business Customer Gateway account setup
  • Bulk mail permits (if applicable) and postage metering
  • Envelope inserting equipment or manual labor
  • Address verification against USPS National Change of Address (NCCoA) database
  • Return mail handling
  • Compliance infrastructure for regulated industries
  • Engineering time to wire all of this together

USPS commercial mail permit fees alone can add hundreds of dollars per year before you print a single page. Factor in engineering time — typically 2-6 weeks for a mid-complexity mail pipeline — and the economics heavily favor buying.

A well-integrated mail API costs roughly $0.80–$2.50 per piece depending on volume and provider. At any reasonable volume under 50,000 pieces per year, that per-piece cost is almost always lower than the fully-loaded cost of internal infrastructure.

The real hidden cost is maintenance. USPS postal rates change annually. Address formats shift. Compliance requirements in healthcare and law evolve. An API vendor absorbs all of that on your behalf.


Comparing Physical Mail API Providers

Three providers dominate the developer conversation in 2026.

Lob

Lob is the most widely recognized enterprise mail API. It offers letters, postcards, and checks via REST API, with strong address verification tooling. Pricing is volume-based, and the API is well-documented with SDKs for Node, Python, Ruby, PHP, and Java.

Lob targets enterprise teams with established engineering capacity. The self-service onboarding works, but the pricing model scales for high-volume senders. Low-volume users may find it harder to justify.

PostGrid

PostGrid competes with Lob in the enterprise space and adds strong compliance features — including HIPAA-compliant mailing and address verification at the Canadian and US postal level. Their API is REST-based with similar capabilities.

PostGrid tends to get more attention from healthcare and financial services customers who need compliance documentation out of the box.

WriteToMail

WriteToMail occupies a different position. It's a SaaS platform designed for businesses, law firms, and individuals who need to send physical letters, postcards, and checks without managing any postal logistics — no printer, stamps, or post office required.

WriteToMail supports bulk mailing via CSV upload with variable data merge fields, so teams that need to send personalized letters to thousands of recipients can do so without a full API integration. It also supports PDF upload (send any existing PDF document as physical mail), AI-powered letter drafting, and templates for demand letters, cease and desist letters, and formal complaints.

For developers evaluating WriteToMail alongside API-first providers like Lob, the distinction is important: WriteToMail is optimized for usability and rapid deployment rather than deep API integration. Teams that need to wire physical mail into a complex microservices architecture will likely need an API-first provider. Teams looking to automate mail workflows with minimal engineering overhead — or give operations, legal, or billing teams a self-service tool — will find WriteToMail's approach faster to ship.

WriteToMail also offers SOC 2 compliant printing and HIPAA-compliant physical mail, which matters immediately for regulated industries.


WriteToMail as a Developer-Friendly Option

If you're building for a team that's not necessarily engineering-led — think a law firm, a property management company, or a healthcare billing department — WriteToMail's platform model makes sense.

Instead of writing API code to trigger a demand letter, a paralegal or billing coordinator can log in, use the demand letter template, upload their recipient CSV, and send a personalized batch to 500 clients before lunch. No API key required.

That's genuinely useful in contexts where the "developer" handing off the workflow isn't the person executing it daily.

For teams that want to send bulk mail without going to the post office, WriteToMail's CSV upload with variable field mapping handles name, address, and custom content substitution — the same outcome as a mail merge API call, but accessible to non-engineers.


Integration Patterns and Triggers

How you wire a physical mail API into your system depends on your stack. Three patterns cover most cases:

Event-Driven Triggers

The cleanest pattern for most apps. When a specific event fires — payment overdue, account churned, document signed — your event system publishes to a queue, and a consumer function calls the mail API.

This keeps mail logic decoupled from your core application and lets you swap providers without touching business logic.

Scheduled Batch Jobs

For use cases like monthly billing statements or annual notices, a cron job that pulls eligible records and submits batched mail requests is simpler and more predictable than event-driven architecture.

Manual Triggers via UI

Not every workflow needs to be automated. A simple internal tool that lets your support team trigger a physical letter to a specific customer — backed by the mail API — covers a lot of ground without complex infrastructure.

For teams evaluating format choices alongside this workflow, the postcard vs. letter comparison is worth reviewing before locking in template designs.


Compliance Considerations

Compliance is where developers often underestimate the complexity of physical mail automation.

HIPAA: If your application sends patient-identifiable information (PHI) in a physical letter, the printing and mail service you use must be HIPAA-compliant. Both PostGrid and WriteToMail explicitly support HIPAA-compliant physical mail.

Legal mail: Letters with legal standing — demand notices, cease and desist letters, eviction notices — often need to be sent via USPS First-Class Mail or certified mail. Verify that your provider supports the mail class required for your use case. For context on what makes a physical cease and desist letter legally credible, see what a cease and desist letter requires.

CAN-SPAM and state consumer protection laws: Physical mail isn't covered by CAN-SPAM, but several states have consumer protection statutes that govern unsolicited commercial mail. Know your recipient list composition before triggering bulk campaigns.

Address verification: Undeliverable-as-addressed (UAA) mail is a real cost. USPS returns or discards roughly 28 billion pieces of mail per year. Use CASS-certified address verification at the API level to reduce waste.


FAQ

Can I send physical mail from a serverless function? Yes. Any HTTP client in a serverless function (AWS Lambda, Vercel Edge, Cloudflare Workers) can call a physical mail API. Just account for cold start latency and handle timeouts gracefully if you're on a tight execution window.

How long does physical mail take to deliver after an API call? Most providers process and hand off to USPS within 1 business day. USPS First-Class Mail delivery then takes 1–5 business days depending on origin and destination. Factor in 2–7 business days total for end-to-end delivery SLA.

What file formats can I send via physical mail API? Lob and PostGrid accept HTML and PDF. WriteToMail supports PDF upload and also offers an online rich text editor and AI-powered drafting, which is useful for teams that don't want to maintain HTML templates.

Is physical mail API cost-effective for low-volume use cases? For under ~100 pieces per month, the per-piece pricing ($0.80–$2.50) is often more cost-effective than any internal solution. The break-even on in-house infrastructure rarely arrives below 10,000–20,000 pieces per month.

Do physical mail APIs support international delivery? Some providers do, but international mail adds complexity — customs requirements, variable delivery windows, and higher per-piece costs. Verify your target countries are supported before designing around international delivery.

What happens if the recipient's address is wrong? USPS will return the piece to the sender address (if provided) or discard it. Most API providers offer address verification at submission time, which catches the majority of formatting errors and invalid ZIP codes before the letter is printed.

Can I get delivery confirmation? USPS First-Class Mail does not include tracking. Certified Mail and Priority Mail Express include tracking, and some API providers can submit mail via those classes. For legal purposes, certified mail with return receipt is often preferable.


Actionable Next Steps

  1. Define your trigger — what event in your system should initiate a physical letter?
  2. Estimate your volume — monthly piece count determines whether a per-piece API model or a higher-tier plan makes sense
  3. Identify compliance requirements — HIPAA, legal mail class, state consumer protection laws
  4. Prototype with a single provider — Lob and WriteToMail both have accessible onboarding for initial testing
  5. Test address verification — submit a batch of your existing recipient data and review how many addresses fail validation before going live

For teams that want physical mail handled entirely online — from composing to USPS delivery — WriteToMail covers the full workflow without requiring API expertise.


Sources

  1. USPS — Direct Mail ROI Data — response rate statistics comparing physical mail to email
  2. USPS — Business Mail 101: Glossary — postal permit and bulk mail fee definitions
  3. USPS — Service Performance Reports — undeliverable-as-addressed mail volume data
  4. Lob API Documentation — developer reference for letter, postcard, and check API endpoints
  5. PostGrid Developer Docs — REST API reference for physical mail with HIPAA and compliance features
  6. WriteToMail — HIPAA-Compliant Physical Mail Guide — overview of compliance requirements for healthcare physical mail
  7. WriteToMail — Direct Mail Guide for Law Firms — legal mail use cases and best practices for physical correspondence
guide

Ready to Try Direct Mail?

Create professional letters and we'll print and mail them for you. No stamps, no trips to the post office.