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

B2B direct mail by API: cards and letters to the accounts your team is working

B2B direct mail goes to people at the companies you sell to, at their office. Sent through a direct mail API, the mail follows the account: a card to each buyer when an account goes on your target list, an invite before your event, a welcome letter when the deal closes, each sent from the CRM record that already has the stage and the address. Below: where office addresses come from, the checks that matter for business addresses, which stages send what, the formats, and the code.

On this page
  1. Where B2B direct mail addresses come from, by API
  2. Checking office addresses before a B2B API send
  3. Which account stages send B2B direct mail by API
  4. B2B direct mail formats and prices by API
  5. Code: mail the buyers at your target accounts by API
  6. How to measure B2B direct mail sent by API
  7. B2B direct mail questions from API senders

Where B2B direct mail addresses come from, by API

Most of the work is getting a full street address for the office. Each tool gets there differently:

SourceWhere the office address is
HubSpot or SalesforceThe company or account record you already keep
ZoomInfoEnrich Contacts: the street, city, state and ZIP where each person works
ApolloThe contact has the city and state; the street is on the account, joined by account id
ClayAn enrichment column, sent row by row from an HTTP API column

Whichever it is, keep the person’s name and the company apart: the name goes on the first line and the company on its own line below it.

Checking office addresses before a B2B API send

namecompanyaddresscheck
Dana ColeNorthwind500 Main St Ste 400Deliverable, business
Raj PatelContoso1 Market StSuite missing
Lena OrtizFabrikam22 Oak LnResidential
Sam WuTailspin9 Harbor WayUndeliverable
Office addresses need a second look. A building that needs a suite number comes back as deliverable but missing a unit, and the residential flag shows when a “work” address is a home. Names and addresses here are made up.
  • Suites. An office building usually needs a suite or floor. Without one, the check comes back deliverable_missing_unit: the building is real, but the piece may not reach the person. Find the suite before you send.
  • Homes. The check also says whether an address is residential. A “work” address that comes back residential is someone’s home, and you decide whether to mail it.
  • Old offices. Companies move and people change jobs, so check addresses close to the send, not when the list was built.

What each result means is in CASS-certified address verification, and USPS’s own address API is compared in USPS address verification API. Small businesses often get mail at a private mailbox; how to spot and address one is in CMRA addresses.

Which account stages send B2B direct mail by API

Account added to the target listA 6x9 card to each buyer at the officeBuyer picked for the field eventAn event invite three weeks outDeal moves to Closed wonA welcome letter to the team, mailed flatRenewal 60 days outA card from their account manager
Mail follows the account. Each stage your CRM already tracks can send one piece, to the people at that account, without anyone exporting a list.

The stages already live in your CRM, so the mail can go out from the change itself. A HubSpot workflow on a deal moving to Closed won, or a Salesforce record-triggered flow on an opportunity, calls the API once; an Idempotency-Key built from the record id keeps a repeated trigger from sending twice. For lists you build outside the CRM, the Apollo, ZoomInfo and Clay pages each have a script that mails only the contacts added since the last run.

B2B direct mail formats and prices by API

PieceGood forPrice
6x9 postcardA short message to a buyer$0.89
5.5x8.5 postcardAn invite to a dinner or event$0.89
8.5x11 letter, mailed flatA letter from a founder or the account team$0.95
11x17 folded mailerA case study or a product story$1.39

Pay as you go prices, with printing, addressing and postage; plan prices and campaign totals are in direct mail cost. Put the person’s name and their company on the front, where they see it before anything else; which other fields to change per card is in personalized direct mail.

Code: mail the buyers at your target accounts by API

This checks every office address, sets aside the ones that need a person to look at them, and mails a 6x9 card to the rest with each buyer’s name, company and a code of their own:

# Run when the target list changes. Env: MAILR_API_KEY.
# buyers.csv: contact_id (up to 8 characters), account, first_name, name, company, line1, line2, city, state, zip
# mail/abm/front.html and back.html: your design, with {{first_name}}, {{company}} and {{promo_code}} in it
import csv, os, requests

API = "https://api.mailr.dev/v1"
H = {"Authorization": f"Bearer {os.environ['MAILR_API_KEY']}"}
mailed = set(open("mailed.csv").read().split()) if os.path.exists("mailed.csv") else set()

with open("buyers.csv", newline="") as f:
    buyers = [b for b in csv.DictReader(f) if b["contact_id"] not in mailed]

# 1. Check every office address and sort out the ones that need a person to look at them.
send, fix = [], []
for start in range(0, len(buyers), 1000):
    chunk = buyers[start:start + 1000]
    r = requests.post(f"{API}/addresses/verify", headers=H, timeout=120,
        json={"addresses": [{"name": b["name"][:40], "company": b["company"][:40] or None, "line1": b["line1"],
                             "line2": b["line2"] or None, "city": b["city"], "state": b["state"], "zip": b["zip"]}
                            for b in chunk]})
    r.raise_for_status()
    for b, v in zip(chunk, r.json()["data"]):
        if v["deliverability"] == "deliverable" and v["residential"] is not True:
            send.append({**b, "to": v["address"]})
        else:  # a missing suite, a home address or an address USPS doesn't deliver to
            fix.append([b["contact_id"], b["company"], v["deliverability"], "home" if v["residential"] else ""])

with open("fix.csv", "w", newline="") as f:
    csv.writer(f).writerows(fix)

# 2. Mail the rest, 1,000 per request, each with a code that names the contact.
front, back = open("mail/abm/front.html").read(), open("mail/abm/back.html").read()
for n, start in enumerate(range(0, len(send), 1000)):
    chunk = send[start:start + 1000]
    r = requests.post(f"{API}/batches", timeout=120, headers={**H, "Idempotency-Key": f"abm-q1-{n}-{chunk[0]['contact_id']}"},
        json={"kind": "postcard", "size": "6x9", "front": front, "back": back,
              "recipients": [{"to": b["to"], "merge": {"first_name": b["first_name"][:14],
                                                      "company": b["company"][:24],
                                                      "promo_code": f"Q1-{b['contact_id']}"}} for b in chunk],
              "description": "Target accounts, Q1"})
    r.raise_for_status()
    with open("mailed.csv", "a") as f:
        f.write("".join(b["contact_id"] + "\n" for b in chunk))
    print(r.json()["id"], r.json()["count"], r.json()["price"])
Run it with an mlr_test_ key first: the address check is simulated, the cards are proofed, and nothing prints or charges.

How to measure B2B direct mail sent by API

  • A code or short link per contact, so a visit or a booking points back to the person and the account.
  • Meetings booked at mailed accounts in the weeks after the cards are mailed, from the same CRM that sent them.
  • Accounts you didn’t mail. Leave a random slice of the target list out and compare, the way direct mail campaign sets up a holdout.

B2B direct mail questions from API senders

What is B2B direct mail?

Mail from one business to people at another: a card to a buyer at a target account, an invite to an event, a welcome letter when a deal closes. It's addressed to a person, at their office, by company name.

Can I put the company name in the address?

Yes. Send it as company in the address, up to 40 characters, and it prints on its own line under the person's name.

What about people who work from home?

The address check marks each address residential or not, so you can see when a work address is a home. Whether you mail those is up to you; the script above sets them aside for a person to decide.

Which format works best for B2B mail?

A 6x9 card for a short message or an invite, at $0.89. A letter-style 8.5x11 flat when it should read like a letter from a founder, at $0.95. Prices are pay as you go with postage.

Can the mail go out from HubSpot or Salesforce directly?

Yes. A workflow in HubSpot or a record-triggered flow in Salesforce can call the API when a deal changes stage; both are set up on their integration pages.

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.