Direct mail API for developers and growth teams. Read the docs →

Targeted direct mail: how to build the list for an API mailing

Targeted direct mail goes only to the people a list picks: customers who haven’t ordered in 60 days, homeowners on three streets, new owners in your ZIP codes, the offices of companies you sell to. The list is most of the work: where it comes from decides who gets a piece. Every list ends the same way, as rows with a name and an address, cleaned once and sent to a direct mail API in batches of up to 1,000. The opposite is Every Door Direct Mail, which reaches every address on a route with no names.

On this page
  1. Where a targeted API mailing list comes from
  2. How to narrow a list before an API mailing
  3. New movers and new homeowners on an API mailing list
  4. Clean the list, then send it by API
  5. Targeted API mail or Every Door Direct Mail
  6. Targeted direct mail questions from API senders

Where a targeted API mailing list comes from

Your customersPublic recordsBought owner listsBusiness listsOne row per householdBatches of 1,000
Where targeted lists come from. Your own customers, public records, bought owner lists and business lists all end the same way: rows with a name and an address, cleaned once, sent in batches of up to 1,000.
SourceWho it reachesWhere the addresses come from
Your own customersPast buyers, lapsed customers, membersYour database, CRM or a spreadsheet export
Public recordsNew owners, people building or remodelingCounty recorder sales and city permits, with the owner’s mailing address from the assessor (public records guide)
Bought consumer listsHomeowners or absentee owners in an areaExports from DataZapp or PropStream
Business listsCompanies, or people by roleData Axle, Apollo, ZoomInfo or a Clay table
Neighbors of a jobThe street around work you just finishedAn owner list for that street, as roofers use after a new roof, or an agent’s farm for just sold postcards

Your own customers are the list you already have and the one that knows you. If some of them gave you only an email, an email to address lookup can match part of them to mailing addresses. The others reach people who don’t know you yet, so the card has to say who you are and why you’re writing. Running the mailing itself, with a group held out to measure it, is in direct mail campaign.

How to narrow a list before an API mailing

A list from any source is wider than the people you want. Each of these is a line of code before the send: What to send once the list is ready is in direct mail examples.

  • Recency: customers whose last order or visit was more than 60 days ago.
  • Place: the ZIP codes or the distance you actually serve.
  • Ownership or property: homeowners, absentee owners, a recent pool permit. Owner lists carry this; your own data may not.
  • Exclusions: anyone mailed in the last 30 days, anyone who asked not to get mail, and existing customers on a prospect list.
Everyone in the export12,400In ZIP codes you serve6,100Homeowners only3,900Not mailed in the last 30 days3,650
Narrow it before you send. Each filter is a line of your own code; the counts here are an example. What’s left goes out as four batches.

New movers and new homeowners on an API mailing list

People who just moved are worth mailing, but one tool is off limits for finding them. NCOA updates the records already on your list, and the USPS form every list owner signs says NCOALink may not be used to create or maintain new movers’ lists. For new owners in your area, use the county’s recorded sales, which name each buyer, or ask your list provider what it offers. Use NCOA for what it’s for: keeping your own list current. The whole job, from recorded sales to a welcome card, is in new homeowner mailing list.

Clean the list, then send it by API

  1. One card per household. Combine the sources and dedupe on a normalized address.
  2. Update old lists for moves. Anything not updated in the last 95 days goes through NCOA first.
  3. Check every address. Add "verify": true, or sort the list first with the address check, as in CASS address verification.
  4. Keep a record of what you mailed, so next month’s run skips this month’s households.

This script does all four for two sources, your customers and an owner list, and mails what’s left as 6x9 postcards:

# Combine two sources, keep one card per household, skip anyone mailed in the last 30 days, then send.
# customers.csv and owners.csv: name, first_name, line1, line2, city, state, zip (owners.csv from your list provider)
# mailed.csv: key, date of every address you've mailed before (this script appends to it)
import csv, datetime, os, re, requests

SERVE = {"85201", "85203", "85204", "85210"}   # ZIP codes you serve
today = datetime.date.today()

def key(r):  # one key per household: street line plus ZIP, normalized
    return re.sub(r"[^a-z0-9]", "", f"{r['line1']}{r.get('line2') or ''}".lower()) + r["zip"][:5]

recent = set()
if os.path.exists("mailed.csv"):
    with open("mailed.csv", newline="") as f:
        recent = {k for k, d in csv.reader(f) if (today - datetime.date.fromisoformat(d)).days < 30}

seen, rows = set(), []
for path in ["customers.csv", "owners.csv"]:
    with open(path, newline="") as f:
        for r in csv.DictReader(f):
            k = key(r)
            if r["zip"][:5] in SERVE and k not in seen and k not in recent:
                seen.add(k)
                rows.append(r)

print(len(rows), "households to mail")
for n, start in enumerate(range(0, len(rows), 1000)):
    chunk = rows[start:start + 1000]
    resp = requests.post(
        "https://api.mailr.dev/v1/batches",
        headers={"Authorization": f"Bearer {os.environ['MAILR_API_KEY']}",
                 "Idempotency-Key": f"spring-target-{today.isoformat()}-{n}"},
        json={"kind": "postcard", "size": "6x9", "verify": True,
              "front": open("mail/front.html").read(), "back": open("mail/back.html").read(),
              "recipients": [{"to": {"name": r["name"][:40], "line1": r["line1"], "line2": r["line2"] or None,
                                     "city": r["city"], "state": r["state"], "zip": r["zip"]},
                              "merge": {"first_name": (r["first_name"] or "Neighbor")[:14]}} for r in chunk]},
        timeout=60,
    )
    resp.raise_for_status()
    with open("mailed.csv", "a", newline="") as f:
        csv.writer(f).writerows([key(r), today.isoformat()] for r in chunk)
    print(resp.json()["id"], resp.json()["count"], resp.json()["price"])
With an mlr_test_ key the batches are checked, priced and proofed, and nothing prints or charges.

Targeted API mail or Every Door Direct Mail

Every Door Direct Mail skips the list: USPS delivers to every address on the carrier routes you pick, with no names, for less postage per piece. It suits an announcement every household should see. Targeted mail suits everything else: a certain kind of customer, a few streets, a name on the piece. The two are compared side by side in how to mail flyers to a neighborhood. Once the list is set, postcard marketing covers the card itself. USPS’s own options are laid out in USPS direct mail.

Targeted direct mail questions from API senders

What is targeted direct mail?

Mail sent only to the people a list picks, by name and address, instead of to every address in an area. The opposite is Every Door Direct Mail, which reaches every address on a carrier route without names.

Does Mailr sell mailing lists?

No. Mailr mails the addresses you send. Lists come from your own data, public records, or a provider you choose, such as DataZapp, PropStream, Data Axle, Apollo or ZoomInfo.

How do I mail people who just moved into my area?

Use the county's recorded sales, which show each new owner, or ask your list provider what it offers. NCOA can't do it: the USPS form every list owner signs says NCOALink may not be used to create or maintain new movers' lists.

How do I keep from mailing the same household twice?

Dedupe on a normalized address before you send, and keep a record of what you've mailed so the next run skips it. An Idempotency-Key on each batch also stops a retried request from mailing twice.

What does a targeted mailing cost?

The list, from whoever sells it, plus the mail: a 6x9 postcard is $0.89 on pay as you go, printing and postage included, and an address check is 7¢ more if you add "verify": true.

START SENDING

Put your first postcard in the mail

Create a key, send a test to yourself, and check the proof before anything prints.

Start sending
  • Postcards, flats and folded mailers
  • A proof before anything prints
  • Free test mode: nothing prints, nothing charges
  • A status for every piece

Free price sheet

Get the price sheet by email

Every postcard, letter, mailer and print product on every plan, with postage included.

We’ll email you the price sheet. By continuing you agree to the Terms and Privacy Policy.

Download the template kit?

mailr-kit.zip · about 310 KB · 59 text files

Only HTML, JSON and Markdown files. No programs, scripts or macros, nothing that installs or runs.