Direct Mail API Developer Guide & Architecture Blueprints
Programmatically dispatch 4×6, 6×9 & 6×11 postcards, windowed & windowless letters, custom PDF documents, folded notecards, $5–$100 gift cards, and 6×9 MagnaCards from your CRM or backend with 1-piece minimums, proprietary AI handwriting-style fonts, and real-time QR scan webhooks.
A Direct Mail API allows developers to programmatically send personalized physical postcards, windowed or windowless letters, folded notecards, and gift cards from any CRM or backend via REST endpoints (https://api.thanks.io/api/v2), featuring a free Test Mode sandbox, CASS address validation, and real-time QR scan webhooks.
Authorization: Bearer YOUR_API_KEY Content-Type: application/json Accept: application/json X-Subaccount-Id: sub_99201 # Optional (Agencies/SaaS)
All 6 Mail Formats Programmable via REST API & MCP
Every format includes First-Class or Standard postage, 1-piece minimum order volume, CASS address standardization, and Thanks.io's proprietary digital handwriting engine (AI Fonts with natural glyph variation and Realism Mode crossouts).
| Mail Format | REST v2 Endpoint | Pro Plan ($199/mo) | Business ($49/mo) | Pay-As-You-Go ($0/mo) | Developer Capabilities |
|---|---|---|---|---|---|
| Postcards (4×6, 6×9, 6×11) | POST /api/v2/recipients/postcard | $0.64 (4×6) | $0.77 (4×6) | $1.18 (4×6) | Saved Creative ID or inline front_image_url, AI handwriting-style fonts, Realism Mode, dynamic Street View, per-recipient QR tracking. |
| Windowed Letters (8.5×11) | POST /api/v2/recipients/letter | $0.79 | $0.83 | $1.20 | Single or multi-page letters via saved Creative ID, handwritten-style text template, or custom rendered pdf_url upload. |
| Windowless Letters (Real First-Class Stamp) | POST /api/v2/recipients/windowlessletter | $0.99 | $1.35 | $1.62 | Executive outer envelope with a real First-Class stamp and handwritten-style recipient/return addressing for maximum open rates. |
| Folded Notecards (5×4 in Envelope) | POST /api/v2/recipients/notecard | $1.49 | $1.83 | $2.46 | Premium folded greeting card inside a handwritten-style outer envelope with natural glyph variation and Realism Mode crossouts. |
| Branded Gift Cards ($5–$100) | POST /api/v2/recipients/giftcard | Notecard + Face Value | Notecard + Face Value | Business / Pro Plans | Deliver Amazon, Starbucks, Home Depot, Visa, or Target gift cards ($5–$100) paired inside a personalized folded notecard or postcard. |
| 6×9 MagnaCards (Pop-Out Magnet) | POST /api/v2/recipients/magnacard | $1.04 | $1.43 | $1.78 | Oversized 6×9 glossy mailer featuring a detachable laminated business-card magnet built for long-term kitchen fridge retention. |
4 Production Direct Mail API Blueprints
Switch between Node.js / TypeScript, Python, and cURL to implement single-piece CRM triggers, custom PDF or windowless letters, geospatial neighbor radius blasts, and idempotent webhook consumers.
1. Single-Piece Triggered Postcard with Saved Creative ID & Merge Variables
Trigger a 1-piece personalized 4×6, 6×9, or 6×11 postcard from any CRM lifecycle event using a pre-approved Creative ID, custom merge variables (%CUSTOM1%–%CUSTOM4%), and optional absentee property address for dynamic Google Street View.
- Reference a saved creative_id so marketing controls artwork & handwriting font without code deploys
- Inject %CUSTOM1% through %CUSTOM4% for dynamic offer amounts, renewal dates, or rep phone numbers
- Pass property_address + property_postal_code to render Google Street View of an absentee property while mailing the owner's residence
// Node.js 20+ / TypeScript — Triggered Postcard with Creative ID & Merge Variables
const THANKS_IO_API_KEY = process.env.THANKS_IO_API_KEY!;
interface SendPostcardPayload {
creative_id: number;
size: "4x6" | "6x9" | "6x11";
postage_class?: "first_class" | "standard";
recipients: Array<{
name: string;
address: string;
city: string;
province: string;
postal_code: string;
country: string;
email?: string;
custom1?: string;
custom2?: string;
property_address?: string;
property_postal_code?: string;
}>;
}
export async function triggerCrmPostcard() {
const payload: SendPostcardPayload = {
creative_id: 48291, // Saved Creative in Thanks.io Dashboard
size: "6x9",
postage_class: "first_class",
recipients: [
{
name: "Jordan Vance",
address: "742 Evergreen Terrace",
city: "Austin",
province: "TX",
postal_code: "78701",
country: "US",
email: "[email protected]",
custom1: "$250 Onboarding Credit",
custom2: "Acct-88412",
// Optional: Display Street View of subject property while mailing owner's address
property_address: "1104 Congress Ave, Austin, TX",
property_postal_code: "78701",
},
],
};
const response = await fetch("https://api.thanks.io/api/v2/recipients/postcard", {
method: "POST",
headers: {
"Authorization": `Bearer ${THANKS_IO_API_KEY}`,
"Content-Type": "application/json",
"Accept": "application/json",
// Optional for multi-tenant SaaS / agencies:
// "X-Subaccount-Id": "sub_99201"
},
body: JSON.stringify(payload),
});
if (!response.ok) {
throw new Error(`Thanks.io API Error (${response.status}): ${await response.text()}`);
}
return await response.json();
}{
"status": "queued",
"order_id": 9184022,
"mode": "production",
"format": "postcard_6x9",
"recipients_accepted": 1,
"cass_verified": true,
"estimated_dispatch": "Same-Day (Before 11:00 AM CT)"
}Direct Mail API Architecture & Bidirectional Webhook Lifecycle
Close the attribution loop between backend CRM triggers and physical mailbox engagement with real-time JSON webhooks.
CRM / Backend Event
Deal stage change, invoice dunning trigger, or nightly cron job fires in your application.
POST /api/v2/recipients/{format}
Your server dispatches a JSON request with creative_id, recipient address, and %CUSTOM1%–%CUSTOM4%.
Same-Day Print (<11am CT)
CASS-verified orders submitted before 11:00 AM CT are rendered, printed, and cut the same business day.
USPS First-Class / Standard Stream
Inducted into USPS with Intelligent Mail Barcode (IMb) scan events tracked automatically.
Recipient QR Code Scan
The recipient scans their personalized tracking QR code on the postcard, letter, or notecard.
Webhook POST to Your Endpoint
Thanks.io POSTs qr.scanned or order_item.delivered JSON with event_id to your webhook listener.
Sandbox to Production Readiness Checklist
Follow this 4-step engineering checklist to validate payloads in API Testing Mode, verify rendered proofs, and cut over to live USPS production safely.
Enable API Testing Mode (Sandbox)
Navigate to Account Settings -> API Access -> API Settings -> Test Mode in your Thanks.io dashboard. While Test Mode is enabled, all POST requests validate your JSON schema, Bearer token, and address fields without queuing physical print jobs or billing your card.
Generate Proof Previews Before Live Dispatch
Lock in your front artwork, AI handwriting-style font (handwriting_id), Realism Mode toggle, and %CUSTOM1%–%CUSTOM4% merge variables inside a saved Creative ID, or inspect rendered proofs using the preview-order tool before disabling Test Mode.
Verify CASS Address Standardization & Multi-Tenant Headers
Ensure your CRM integration passes complete street address, city, state/province, and 5-digit ZIP/postal code. If you are building a multi-tenant SaaS or agency platform, test scoping requests with the X-Subaccount-Id header or OAuth 2.0 bearer tokens.
Test Webhook Idempotency & Cut Over Before 11:00 AM CT
Fire a test payload to your webhook consumer from Settings -> Webhooks -> Test Event, verify your handler deduplicates by event_id and returns HTTP 200 within 3 seconds, then switch Test Mode off. Orders received before 11:00 AM Central Time print and enter the USPS stream the same business day.
Explore Related API Guides, MCP & CRM Integrations
Compare Thanks.io against legacy print APIs, connect AI agents via our hosted MCP server, or deploy turnkey CRM integrations.
Postcard API Hub
Return to the central Postcard & Direct Mail API overview, endpoint reference, and pricing calculator.
Hosted Direct Mail MCP Server
Connect Claude Desktop, Cursor, Windsurf, or custom AI agents directly to https://mcp.thanks.io/mcp.
AI Agent Direct Mail Workflows
Discover how autonomous SDR and lifecycle agents research prospects and dispatch physical mail.
Thanks.io vs. Lob API
Compare REST API developer ergonomics, $0/mo Pay-as-you-go access, AI handwriting, and per-piece rates vs. Lob.
Thanks.io vs. PostGrid
See how Thanks.io's 6 programmable formats, gift cards, and free QR scan webhooks stack up against PostGrid.
Zapier Direct Mail Automation
Prefer low-code triggers? Connect 8,000+ apps to Thanks.io with 7 verified Zapier actions.
HubSpot Direct Mail Integration
Trigger postcards, windowless letters, and gift cards directly inside HubSpot Workflows.
GoHighLevel Direct Mail Guide
Automate multi-tenant sub-account mailers and webhook callbacks from HighLevel workflows.
Thanks.io Webhooks Deep Dive
Full payload schemas for qr.scanned, order_item.delivered, and order.status_updated events.
Direct Mail REST API & CRM Automation FAQs
Direct answers to common engineering questions on Test Mode sandboxes, handwritten-style card APIs, PDF letters, and OAuth 2.0 sub-accounts.
Ship Your First Direct Mail API Integration in 10 Minutes
Generate your Personal Access Token, enable API Testing Mode to validate payloads for free, and dispatch physical postcards, letters, and gift cards with zero minimums.