Poplar Direct Mail
Overview
Design professional direct mail creative using Poplar's HTML template system and send programmatic mail pieces via their API. This skill covers template creation with dynamic personalization, API integration for triggered mailings, and creative best practices for high-converting direct mail campaigns.
When to Use
- Creating HTML templates for direct mail postcards, bi-folds, tri-folds, or letters
- Building triggered/programmatic direct mail campaigns
- Integrating direct mail into marketing automation workflows
- Designing personalized mail pieces with dynamic content (names, offers, QR codes)
- Sending transactional mail (receipts, confirmations, statements)
- Setting up abandoned cart or win-back mail campaigns
Prerequisites
Installation
Set your API token:
bash
# Test token (for development - only works with mailing endpoint)
export POPLAR_API_TOKEN="test_your_token_here"
# Production token (for live mailings)
export POPLAR_API_TOKEN="your_production_token_here"
Mail Formats & Dimensions
Postcards
| Size | Final Trim | With Bleed | Pixels (300 PPI) | |
|---|
| 4" x 6" | 4" x 6" | 4.25" x 6.25" | 1275 x 1875 | |
| 6" x 9" | 6" x 9" | 6.25" x 9.25" | 1875 x 2775 | |
| 6" x 11" | 6" x 11" | 6.25" x 11.25" | 1875 x 3375 | |
Best for: Retargeting, time-sensitive promotions, simple messaging, direct mail newcomers
Bi-folds
| Format | Pixels (300 PPI) | |
|---|
| Short-fold (folds left to right) | 1725 x 5175 | |
| Long-fold (folds top to bottom) | 3375 x 2625 | |
Best for: Prospecting campaigns, new product launches, complex value propositions
Tri-folds
| Format | Pixels (300 PPI) | |
|---|
| Standard Tri-fold | 2625 x 4987 | |
Best for: Multiple product selections, detailed information, catalogs
Letters
| Format | Dimensions | |
|---|
| 8.5" x 11" (Color or B&W) | 612 x 792 px (no bleed required) | |
Best for: Financial/insurance, sensitive content, transactional mailings, professional communications
HTML Template Structure
Basic Template
html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap"
rel="stylesheet" type="text/css">
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
width: 4.25in;
height: 6.25in;
position: relative;
font-family: 'Open Sans', sans-serif;
}
.background {
position: absolute;
width: 100%;
height: 100%;
background-image: url('https://your-hosted-image.com/background.png');
background-size: cover;
}
.headline {
position: absolute;
top: 0.5in;
left: 0.375in;
font-size: 28pt;
font-weight: 700;
color: #1a1a1a;
}
.personalized-text {
position: absolute;
top: 1.2in;
left: 0.375in;
font-size: 14pt;
color: #333333;
}
.offer-box {
position: absolute;
bottom: 1in;
left: 0.375in;
width: 3.5in;
padding: 0.25in;
background-color: #ff6b35;
color: white;
text-align: center;
font-size: 18pt;
font-weight: 600;
}
</style>
</head>
<body>
<div class="background"></div>
<div class="headline">Special Offer Inside!</div>
<div class="personalized-text">
Hi {{recipient.first_name | default: "Friend"}},
</div>
<div class="offer-box">
Use code: {{promotion.promo_code}}
</div>
</body>
</html>
CSS Requirements
| Requirement | Details | |
|---|
| CSS Location | All styles in <style> tag within <head> | |
| Positioning | Use position: absolute for all elements | |
| Units | Only in (inches) or px (pixels) - no em, rem, vw, vh | |
| Image URLs | Absolute URLs only (must be publicly accessible) | |
| Fonts | Google Fonts or self-hosted .ttf/.woff files | |
Font Implementation
Google Fonts (recommended):
html
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;600;700&display=swap"
rel="stylesheet" type="text/css">
Custom fonts:
css
@font-face {
font-family: "CustomFont";
src: url("https://your-domain.com/fonts/CustomFont.ttf") format("truetype");
}
Merge Tags & Personalization
Recipient Data
liquid
{{recipient.first_name}} <!-- First name or "Current Resident" -->
{{recipient.last_name}} <!-- Last name -->
{{recipient.full_name}} <!-- Full name -->
{{recipient.address_1}} <!-- Street address -->
{{recipient.city}} <!-- City -->
{{recipient.state}} <!-- State -->
{{recipient.postal_code}} <!-- ZIP code -->
Promotion Codes
liquid
{{promotion.promo_code}} <!-- Unique promo code -->
{{promotion.qr_url}} <!-- URL for QR code generation -->
Location-Based
liquid
{{location.city}} <!-- Recipient's city -->
{{location.state}} <!-- Recipient's state -->
{{location.store_address}} <!-- Nearest store address -->
Custom Data
liquid
{{custom.purchase_amount}} <!-- Custom field from your data -->
{{custom.product_name}} <!-- Product purchased -->
{{custom.loyalty_tier}} <!-- Customer tier -->
Liquid Template Logic
Conditional Content
liquid
{% if recipient.first_name %}
Hi {{recipient.first_name | capitalize}},
{% else %}
Dear Valued Customer,
{% endif %}
Offer Tiers Based on Purchase History
liquid
{% if custom.lifetime_value >= 500 %}
<div class="offer">Enjoy 25% off your next order!</div>
{% elsif custom.lifetime_value >= 200 %}
<div class="offer">Take 15% off your next purchase!</div>
{% else %}
<div class="offer">Get $10 off orders over $50!</div>
{% endif %}
Rolling Expiration Dates
liquid
<!-- 30 days from print date -->
Expires: {{ "now" | date: "%s" | plus: 2592000 | date: "%B %e, %Y" }}
<!-- 90 days from print date -->
Expires: {{ "now" | date: "%s" | plus: 7776000 | date: "%B %e, %Y" }}
Text Formatting Filters
liquid
{{ recipient.first_name | capitalize }} <!-- Capitalizes first letter -->
{{ recipient.first_name | upcase }} <!-- ALL CAPS -->
{{ recipient.first_name | downcase }} <!-- all lowercase -->
{{ custom.price | money }} <!-- Format as currency -->
API Reference
Authentication
All requests require a Bearer token:
bash
curl -H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
https://api.heypoplar.com/v1/me
Create Mailing
Endpoint: POST https://api.heypoplar.com/v1/mailing
bash
curl -X POST https://api.heypoplar.com/v1/mailing \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"campaign_id": "your-campaign-id",
"creative_id": "your-creative-id",
"recipient": {
"first_name": "Jane",
"last_name": "Smith",
"address_1": "123 Main Street",
"address_2": "Apt 4B",
"city": "San Francisco",
"state": "CA",
"postal_code": "94102"
},
"merge_tags": {
"promo_code": "SAVE20",
"expiration_date": "December 31, 2024"
}
}'
Response (201 Created):
json
{
"id": "mailing-uuid",
"campaign_id": "campaign-uuid",
"creative_id": "creative-uuid",
"state": "processing",
"front_url": "https://app.heypoplar.com/preview/front.png",
"back_url": "https://app.heypoplar.com/preview/back.png",
"pdf_url": "https://app.heypoplar.com/preview/proof.pdf",
"total_cost": "0.89",
"created_at": "2024-01-15T10:30:00Z"
}
Schedule Future Mailing
bash
curl -X POST https://api.heypoplar.com/v1/mailing \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"campaign_id": "your-campaign-id",
"recipient": {
"full_name": "John Doe",
"address_1": "456 Oak Avenue",
"city": "Austin",
"state": "TX",
"postal_code": "78701"
},
"send_at": "2024-02-01T09:00:00Z"
}'
Get Mailing Status
Endpoint: GET https://api.heypoplar.com/v1/mailing/:id
bash
curl https://api.heypoplar.com/v1/mailing/MAILING_ID \
-H "Authorization: Bearer YOUR_TOKEN"
List Campaigns
Endpoint: GET https://api.heypoplar.com/v1/campaigns
bash
curl https://api.heypoplar.com/v1/campaigns \
-H "Authorization: Bearer YOUR_TOKEN"
List Campaign Creatives
Endpoint: GET https://api.heypoplar.com/v1/campaign/:id/creatives
bash
curl https://api.heypoplar.com/v1/campaign/CAMPAIGN_ID/creatives \
-H "Authorization: Bearer YOUR_TOKEN"
Add to Do Not Mail List
Endpoint: POST https://api.heypoplar.com/v1/do-not-mail
bash
curl -X POST https://api.heypoplar.com/v1/do-not-mail \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"email": "customer@example.com",
"address": {
"address_1": "123 Main St",
"postal_code": "94102"
}
}'
Python Scripts
Send Single Mailing
python
#!/usr/bin/env python3
"""Send a single direct mail piece via Poplar API."""
import os
import requests
import argparse
POPLAR_API_URL = "https://api.heypoplar.com/v1"
def send_mailing(
campaign_id: str,
recipient: dict,
creative_id: str = None,
merge_tags: dict = None,
send_at: str = None
) -> dict:
"""Send a mailing via Poplar API."""
token = os.environ.get("POPLAR_API_TOKEN")
if not token:
raise ValueError("POPLAR_API_TOKEN environment variable not set")
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}
payload = {
"campaign_id": campaign_id,
"recipient": recipient
}
if creative_id:
payload["creative_id"] = creative_id
if merge_tags:
payload["merge_tags"] = merge_tags
if send_at:
payload["send_at"] = send_at
response = requests.post(
f"{POPLAR_API_URL}/mailing",
headers=headers,
json=payload
)
response.raise_for_status()
return response.json()
def main():
parser = argparse.ArgumentParser(description="Send a Poplar direct mail piece")
parser.add_argument("--campaign-id", required=True, help="Campaign ID")
parser.add_argument("--creative-id", help="Creative ID (optional)")
parser.add_argument("--first-name", required=True, help="Recipient first name")
parser.add_argument("--last-name", required=True, help="Recipient last name")
parser.add_argument("--address", required=True, help="Street address")
parser.add_argument("--city", required=True, help="City")
parser.add_argument("--state", required=True, help="State (2-letter code)")
parser.add_argument("--zip", required=True, help="ZIP code")
parser.add_argument("--promo-code", help="Promo code merge tag")
args = parser.parse_args()
recipient = {
"first_name": args.first_name,
"last_name": args.last_name,
"address_1": args.address,
"city": args.city,
"state": args.state,
"postal_code": args.zip
}
merge_tags = {}
if args.promo_code:
merge_tags["promo_code"] = args.promo_code
result = send_mailing(
campaign_id=args.campaign_id,
recipient=recipient,
creative_id=args.creative_id,
merge_tags=merge_tags if merge_tags else None
)