On this page
- How just sold postcards work with a direct mail API
- Watch the MLS feed’s RESO Web API for a Closed status
- Who gets just sold postcards by API: the farm list
- What goes on just sold and just listed postcards sent by API
- Code: send just sold postcards by API when a listing closes
- Just sold postcard questions from API senders
How just sold postcards work with a direct mail API
Three pieces of data do all the work: the listing’s status, the address that sold, and the agent’s farm list. The MLS supplies the first two; the farm list is the agent’s own.
Watch the MLS feed’s RESO Web API for a Closed status
Most MLS data reaches developers through the RESO Web API, from vendors such as Bridge, Trestle, Spark or MLS Grid. It has no webhooks, so the job reads every listing changed since its last run (filtered on ModificationTimestamp), compares each StandardStatus with the one it stored, and acts only on the change it cares about. A change to Closed sends just sold cards. A change to Coming Soon or Active sends just listed cards. The listing’s ListingKey goes into the Idempotency-Key, so a re-run never mails a farm twice for the same sale.
Who gets just sold postcards by API: the farm list
A farm is the set of homes an agent mails again and again, usually a few neighborhoods. Agents keep their own list. To build one, the owner’s mailing address for each home comes from the county assessor’s parcel data or an owner list from a provider such as PropStream; the targeted direct mail post covers both. Before each send:
- Leave out the house that sold.
- Keep one card per household.
- Run an older farm list through NCOA for owners who moved, and add
"verify": trueto check every address.
What goes on just sold and just listed postcards sent by API
- Just sold, 6x9: the sold address, the agent’s name and photo, and a number or short link to ask what their own home is worth.
- Just listed, 6x11: the listing photo, the address and the open house date, with a QR code to the listing if you like.
Both use your own HTML design with merge tags such as {{sold_address}} and {{agent_name}}, filled once for the whole batch since every home on the farm gets the same sale.
Code: send just sold postcards by API when a listing closes
# Run hourly. Env: RESO_BASE (your MLS feed's RESO Web API URL), RESO_TOKEN, AGENT_KEY, MAILR_API_KEY
# farm.csv: the agent's farm, one row per home: name, line1, line2, city, state, zip
# state.json: when the job last ran and each listing's status then (created on the first run)
import csv, datetime, json, os, re, requests
state = json.load(open("state.json")) if os.path.exists("state.json") else {"since": "2026-11-01T00:00:00Z", "status": {}}
now = datetime.datetime.now(datetime.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
norm = lambda s: re.sub(r"[^a-z0-9]", "", s.lower())
url = f"{os.environ['RESO_BASE']}/Property"
params = {"$filter": f"ModificationTimestamp gt {state['since']} and ListAgentKey eq '{os.environ['AGENT_KEY']}'",
"$select": "ListingKey,StandardStatus,UnparsedAddress,ListAgentFullName", "$top": "200"}
changed = []
while url: # the feed has no webhooks, so read what changed since the last run, page by page
page = requests.get(url, params=params, headers={"Authorization": f"Bearer {os.environ['RESO_TOKEN']}"}, timeout=60).json()
changed += page["value"]
url, params = page.get("@odata.nextLink"), None
with open("farm.csv", newline="") as f:
farm = list(csv.DictReader(f))
for l in changed:
before = state["status"].get(l["ListingKey"])
state["status"][l["ListingKey"]] = l["StandardStatus"]
if l["StandardStatus"] != "Closed" or before == "Closed":
continue # only the change to Closed sends just sold cards
street = norm(l["UnparsedAddress"].split(",")[0])
homes = [h for h in farm if norm(h["line1"]) != street] # not the house that sold
for n, start in enumerate(range(0, len(homes), 1000)):
r = requests.post("https://api.mailr.dev/v1/batches", timeout=60,
headers={"Authorization": f"Bearer {os.environ['MAILR_API_KEY']}",
"Idempotency-Key": f"just-sold-{l['ListingKey']}-{n}"}, # a re-run never mails twice
json={"kind": "postcard", "size": "6x9", "verify": True,
"front": open("mail/just-sold/front.html").read(), "back": open("mail/just-sold/back.html").read(),
"merge": {"sold_address": l["UnparsedAddress"].split(",")[0], "agent_name": l["ListAgentFullName"]},
"recipients": [{"to": {"name": h["name"][:40] or "Current Resident", "line1": h["line1"],
"line2": h["line2"] or None, "city": h["city"], "state": h["state"], "zip": h["zip"]}}
for h in homes[start:start + 1000]],
"description": f"Just sold: {l['UnparsedAddress']}"})
r.raise_for_status()
print(l["ListingKey"], r.json()["id"], r.json()["count"], r.json()["price"])
state["since"] = now
json.dump(state, open("state.json", "w"))Just sold postcard questions from API senders
Does Mailr connect to my MLS?
No. Your code reads the MLS feed, usually the RESO Web API through a vendor such as Bridge, Trestle, Spark or MLS Grid, and calls Mailr when a status changes.
When should a just sold postcard go out?
When the listing's status changes to Closed. The job above checks hourly, so the cards are in the mail within a day of the close.
How many homes should get one?
The agent's farm, whatever size it is. A batch holds up to 1,000 homes, and a larger farm goes out as several batches.
What does a just sold mailing cost?
A 6x9 postcard is $0.89 on pay as you go, printing and postage included, so a 500-home farm is $445.00. On the Agency plan ($149 a month) the card is $0.69.
Can the buyer get a card too?
Yes: a welcome-home card to the buyer at the new address, from the same status change. It's one of the moments on the real estate page.