On this page
What to personalize on direct mail with an API
Start from what you already know about each person, then pick the few fields that change the message. A name alone is polite. A name plus the product they bought plus a code they can use is a reason to come back. Size, timing and cost for the cards themselves are in postcard marketing. A holiday card often needs only the name; what else it can carry by Marketing Mail is in business Christmas cards.
- The name. First name in the greeting, full name in the address block. It’s the field you’ll have most often and the one most often missing, so plan a fallback.
- What they did. The last product, the job you finished, the event they came to. It turns a generic card into one about them.
- A code or link of their own. A promo code or short link per person tells you who acted on the card when it comes back through your checkout or analytics. A QR code per person does the same for people who’d rather scan, and a gift card claim link works the same way when the card says thank you.
- A place or a date. The nearest store, the street where the work was done, the renewal date, the event date. A date can also decide when the card goes out, as with customer birthday cards.
- Who it’s from. A founder, a trainer, a pastor. A real name signs it, and a handwriting-style font makes the signature look like one.
Personalized direct mail examples from API senders
These come from the industry pages on this site, each built on a moment the business already records: The full set, with formats and prices, is in direct mail examples. A one-use coupon code per household is in coupon mailers.
| Business | Moment | What changes per card |
|---|---|---|
| Online store | No order in 60 days | Name, last product, offer code |
| Auto repair shop | A declined repair | The declined job, a booking QR code |
| Groomer or kennel | Four months without a booking | The pet’s name |
| Real estate agent | A listing sells | The sold address, the agent’s photo |
| Church | A first gift | The fund it went to, never the amount |
| Roofer | A hail storm | The storm date |
| Gym | Last session in a package | The trainer’s name and signature |
Length limits and fallbacks for API merge fields
Every template has a fixed set of merge fields, each with a maximum length so the text fits the layout. A request that leaves one out, or sends one that’s too long, is rejected before anything prints. These are the limits on Mailr’s templates:
| Field | Most characters |
|---|---|
first_name | 14 |
promo_code | 12 |
last_product | 22 |
product_name | 22 |
company | 24 |
founder_name | 16 |
event_name | 28 |
event_date | 24 |
review_url | 28 |
cart_url | 28 |
In your own HTML design you can name fields whatever you like, up to 200 characters each. Either way, decide the fallbacks in your code before you send: “Neighbor” for a missing first name, “your last order” for a missing product. Rows whose values are too long are better fixed by hand than cut off in the middle of a word. Setting up that HTML is covered in direct mail design.
| first_name | promo_code |
|---|---|
| Ada | PEAK15 |
| (empty) | PEAK15 |
What to keep off a personalized postcard sent by API
Postcards and flats mail without an envelope, so anyone who handles one can read it. Keep these off:
- Amounts. What someone gave, owes or spent. The nonprofit and church pages name the fund a gift went to, never the amount.
- Bills and past-due notices. USPS Marketing Mail can’t carry bills or statements of account, so those go another way. The class’s other rules are in USPS Marketing Mail.
- Health, account and ID numbers. Anything you wouldn’t put on the outside of an envelope.
How to send personalized mail with an API
One request per piece, or a batch of up to 1,000 with the design once and each person’s values in merge. This script applies the fallbacks, sets aside rows that are too long, and sends the rest as 6x11 win-back postcards:
# customers.csv: one row per customer, from your store, CRM or warehouse.
# Columns: id, name, first_name, line1, line2, city, state, zip, last_product, promo_code
import csv, os, requests
LIMITS = {"first_name": 14, "last_product": 22, "promo_code": 12} # tmpl_winback's fields
def merge_for(c):
values = {
"first_name": c["first_name"].strip() or "Neighbor", # fallback when the name is missing
"last_product": c["last_product"].strip() or "your last order",
"promo_code": c["promo_code"].strip() or "PEAK15",
}
too_long = [k for k, v in values.items() if len(v) > LIMITS[k]]
return values, too_long
send, review = [], []
with open("customers.csv", newline="") as f:
for c in csv.DictReader(f):
values, too_long = merge_for(c)
if too_long: # don't cut a product name mid-word: fix these by hand
review.append({**c, "too_long": ",".join(too_long)})
continue
send.append({"to": {"name": c["name"][:40], "line1": c["line1"], "line2": c["line2"] or None,
"city": c["city"], "state": c["state"], "zip": c["zip"]},
"merge": values})
print(len(send), "to mail,", len(review), "to review")
for n, start in enumerate(range(0, len(send), 1000)):
resp = requests.post(
"https://api.mailr.dev/v1/batches",
headers={"Authorization": f"Bearer {os.environ['MAILR_API_KEY']}",
"Idempotency-Key": f"winback-2026-11-{n}"},
json={"kind": "postcard", "size": "6x11", "template": "tmpl_winback",
"recipients": send[start:start + 1000], "description": "November win-back"},
timeout=60,
)
resp.raise_for_status()
print(resp.json()["id"], resp.json()["count"], resp.json()["price"])mlr_test_ key first and open a few proofs, including the longest names and a fallback row. Test pieces never print or charge. The same steps for a whole spreadsheet are in the variable data printing guide.Personalized direct mail questions from API senders
What is personalized direct mail?
Mail where each piece carries text from the recipient's own record: their name, what they bought, a code of their own, the store nearest them. The design is the same for everyone; the values change per piece.
Is personalized direct mail the same as variable data printing?
It's the marketing side of the same thing. Variable data printing is how the printer changes text from piece to piece; personalization is deciding which of your data to print.
Does it cost more than mailing the same card to everyone?
Not with Mailr: a personalized card is the same price as a plain one, for example $0.89 for a 6x9 on pay as you go, printing and postage included.
What happens if a field is too long?
The request is rejected before anything prints, with an error naming the field and its limit. Check lengths in your own code first, as in the script above.
Can each card have a different image?
Yes, with your own HTML design: put a merge tag in the image's address, for example <img src="{{photo}}">, and send each recipient's image link as a merge value.