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

Gift card mailers: put a gift card code on a postcard by API

A gift card mailer sent from code is a personalized postcard: get a gift card code or claim link for each recipient from your gift card provider’s API, then print it on the card as a merge field, a QR code, or both. Postcards and flats mail without an envelope, so anyone who handles one can read it. The safer thing to print is a link that needs a claim step, not a code anyone can spend. Mailr prints and mails the card; your gift card provider bills the face value.

On this page
  1. Gift card code, link or QR code on API mail
  2. Mail a gift card safely by API with a claim link
  3. Gift card mailers for thank-yous, referrals and visits from API events
  4. Gift card expiry and fine print as API merge fields
  5. How to send gift card mailers with the API
  6. Tracking gift card redemption from API mail
  7. Gift card mailer questions from API senders

The gift card is one more merge field on a personalized postcard. You can print three things in it, and they differ in who can use them.

What printsWhat the recipient doesWho can use it
The gift card codeTypes it at checkoutAnyone who reads the card
A claim linkOpens it and signs inThe customer, after the claim step
A QR code of the claim linkScans it and signs inThe customer, after the claim step

Print the link and its QR code side by side, for people who type and people who scan. Each QR code is an image of that recipient’s own link, made and hosted as in QR code postcards.

A postcard has no envelope. Neither does a flat: Mailr’s 8.5x11 letters mail flat and open. An 11x17 folded mailer hides its inside panels behind a fold, but a fold isn’t an envelope. Treat every piece as open mail: anyone who picks it up can read it, including whoever else lives at the address. If your list hasn’t been checked for moves, run it through NCOA before a gift card send.

A claim link keeps the money off the card. The link carries a random token, like acme.co/g/k7Qm2xPa on Ada’s card. When someone opens it, your claim page asks for something only the customer has: a sign-in to their account, or a one-time code sent to the email you have on file. Then your server orders the gift card from your provider’s API and emails it to that customer. Someone who finds the card can open the link, but can’t claim the gift.

Scanned or typed: acme.co/g/k7Qm2xPaCustomer signs in to claimPOST your gift card provider’s API$25 gift card emailed to Ada
The card carries a link, not the money. Ada’s link opens a sign-in. Only after she signs in does your server order the $25 gift card from your provider, and it reaches her by email.

If your provider’s API can order a card on demand, ordering at claim time has a second benefit: you only buy the gift cards people claim. A card that’s lost or thrown away costs you the mail piece and nothing more.

Make the token random. The link leads to money, so nobody should be able to find the next one by counting up from their own. To print the code itself instead, get it from your provider’s API before the send and put it in a field like gift_code.

Gift card mailers for thank-yous, referrals and visits from API events

The card should say why it came. Pick a moment your system already records and mail on it:

  • A first order. The thank-you card a store mails on a customer’s first order, with a gift card toward the next one instead of a discount code. The webhook side is in Shopify postcards.
  • A referral that became a customer. Mail the person who sent them when the new customer’s first order or first visit is recorded, not when the link is shared.
  • An appointment kept. A first visit, a finished job, a renewed plan. Mail on the status change in your booking tool or CRM.
  • Feedback. A gift card for a private survey is fine. Public reviews are different: Google’s Maps policy doesn’t allow incentives for posting a review, and the FTC’s review rule (16 CFR 465.4) bars incentives tied to a positive or negative one. Mail the review request card on its own.

More moments, each with the event that sends it and its format, are in direct mail examples.

Gift card expiry and fine print as API merge fields

Two dates can matter, and they aren’t the same. The claim-by date is yours: how long the link works. The gift card’s own expiry, if it has one, comes from your provider. With a claim link, the postcard only needs the first, and the card arrives later with its own terms.

If you print the code itself, the code’s terms go on the postcard. The federal gift card rule (12 CFR 1005.20) gives most gift cards at least five years before their funds expire. A card given as a reward or promotion can expire sooner, but only if the card, code or other device says on its front that it’s promotional and when its funds expire, and gives any fees and a toll-free number for fee information. Print the text your provider gives you.

Thanks, Ada.A $25 gift card is yours.acme.co/g/k7Qm2xPaClaim by March 31, 2027first_namegift_amountclaim_urlqr_imageclaim_by
Where each merge field prints. The name, the claim link and its QR image are Ada’s own; the amount and the claim-by date are the same on every card in the send, so they go in the batch’s shared merge.

Shared values, like the amount, the claim-by date and a terms link, go in the batch’s merge. Each person’s values go in their recipient entry and win over the shared ones. Avoid the field name promo_code, which Mailr caps at 12 characters in any design; a name of your own, like gift_code, takes up to 200. Set fine print at 8 pt or larger, the smallest text Mailr’s templates print, and don’t style the card like a check, which Mailr’s Terms don’t allow.

How to send gift card mailers with the API

This script gives each customer a random claim link, makes a QR image of it, and sends 6x9 postcards in batches of up to 1,000, with the shared values in merge and each person’s link in theirs. It saves each piece id next to its token, so a claim can be traced to the card that was mailed. The request fields are in the batch docs.

# pip install segno requests. customers.csv: id, name, first_name, line1, line2, city, state, zip
# Each customer gets a random claim link (acme.co/g/<token>) and a QR image of it. No gift card is bought here:
# your claim page orders one from your gift card provider's API after the customer signs in.
import csv, os, pathlib, secrets, sqlite3, requests, segno

db = sqlite3.connect("gifts.db")
db.execute("create table if not exists gifts (customer_id text primary key, token text unique, piece_id text, claimed_at text)")
OUT = pathlib.Path("public/qr")             # whatever your web server or bucket serves at https://acme.co/qr/
OUT.mkdir(parents=True, exist_ok=True)

def token_for(customer_id):
    row = db.execute("select token from gifts where customer_id = ?", (customer_id,)).fetchone()
    if row:
        return row[0]                       # a rerun reuses the link it already made
    token = secrets.token_urlsafe(6)        # 8 random characters, so nobody finds links by counting
    db.execute("insert into gifts (customer_id, token) values (?, ?)", (customer_id, token))
    return token

recipients, tokens = [], []
with open("customers.csv", newline="") as f:
    for c in csv.DictReader(f):
        token = token_for(c["id"])
        segno.make(f"https://acme.co/g/{token}", error="m").save(str(OUT / f"{token}.png"), scale=10, border=4)
        tokens.append(token)
        recipients.append({
            "to": {"name": c["name"][:40], "line1": c["line1"], "line2": c["line2"] or None,
                   "city": c["city"], "state": c["state"], "zip": c["zip"]},
            "merge": {"first_name": c["first_name"].strip()[:14] or "friend", "claim_url": f"acme.co/g/{token}",
                      "qr_image": f"https://acme.co/qr/{token}.png"},
        })
db.commit()

# Upload public/qr first, then send. Shared values go in the batch's merge; each recipient's own values sit on top.
for n, start in enumerate(range(0, len(recipients), 1000)):
    resp = requests.post(
        "https://api.mailr.dev/v1/batches",
        headers={"Authorization": f"Bearer {os.environ['MAILR_API_KEY']}", "Idempotency-Key": f"gift-thanks-2026-11-{n}"},
        json={"kind": "postcard", "size": "6x9",
              "front": open("mail/front.html").read(), "back": open("mail/back.html").read(),
              "merge": {"gift_amount": "$25", "claim_by": "March 31, 2027", "terms_url": "acme.co/gift-terms"},
              "recipients": recipients[start:start + 1000], "description": "Thank-you gift cards"},
        timeout=60,
    )
    resp.raise_for_status()
    batch = resp.json()
    for token, piece in zip(tokens[start:start + 1000], batch["pieces"]):  # pieces come back in recipient order
        db.execute("update gifts set piece_id = ? where token = ?", (piece["id"], token))
    db.commit()
    print(batch["id"], batch["count"], batch["price"])
Send it with an mlr_test_ key first and scan a few proofs with your phone, straight off the screen. Test pieces never print or charge.

Mailr charges for the mail piece only: $0.89 for a 6x9 postcard on pay as you go, or $0.69 on Agency, printing and postage included. Mailr doesn’t sell gift cards; your provider bills the face value and any fees of its own.

Tracking gift card redemption from API mail

Three records answer three questions:

  • Who looked. Your web server logs every visit to a claim link, scanned or typed.
  • Who claimed. The claimed_at column in your own table, set by the claim page.
  • Who spent it. Only your provider sees a gift card redeemed. If its API or dashboard reports redemptions, save the provider’s order id at claim time and join on it.

Each token maps to one Mailr piece id, and the piece’s status says when it was handed to USPS. Count each card’s response from its mailed status, which you get by polling the piece or from a webhook. Claims divided by cards mailed is the claim rate for that send.

Gift card mailer questions from API senders

Can I mail a physical gift card with Mailr?

No. Mailr prints postcards and flats and mails them without an envelope, so there's nothing to hold a plastic card. The gift goes on the piece as a code, a claim link or a QR code.

Does Mailr sell gift cards or charge the face value?

No. Mailr charges for the mail piece only, for example $0.89 for a 6x9 postcard on pay as you go, printing and postage included. Your gift card provider bills the face value and any fees of its own.

Is it safe to print a gift card code on a postcard?

Anyone who handles a postcard can read it, and a code that works on its own can be spent by whoever reads it. A claim link that makes the customer sign in keeps the gift with the customer, and if the card is ordered at claim time, a lost postcard costs only the mail piece.

Can every postcard have its own gift card QR code?

Yes. Make one QR image per recipient from their claim link, host it, and send the image's link as a merge value. A design with <img src="{{qr_image}}"> prints each person's own code.

Can I offer a gift card for a review?

Not for a public review on Google, whose Maps policy doesn't allow incentives for posting one. And never on condition that a review is positive or negative: the FTC's rule (16 CFR 465.4) bars that for any business. A gift card for a survey that isn't published is outside both.

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.