Back to Postcard API Hub
    Postcard API Silo • Spoke #2
    At-Least-Once JSON Webhooks
    Business ($49/mo) & Pro ($199/mo)

    Direct Mail Webhooks & QR Scan Tracking API: JSON Schemas, Idempotency & CRM Sync

    Direct Answer — Direct Mail Webhooks & QR Attribution

    Thanks.io direct mail webhooks push real-time JSON events to your backend for QR code scans (qr.scanned), USPS First Class delivery (order_item.delivered), and print or order transitions (order.status_updated and order_item.status_updated). Included on Business ($49/month) and Professional ($199/month) plans with zero piece minimums, webhooks use at-least-once delivery with unique event_id deduplication so Slack, HubSpot, and Postgres sync reliably.

    Turn physical postcards, windowed and windowless letters, folded notecards, and 6×9 MagnaCards—rendered with Thanks.io's proprietary digital handwritten-style engine—into an observable event stream your engineering team can route directly into PostgreSQL, Redis, Slack, HubSpot, or Zapier.

    Built-in Webhook Test Button & API TriggerUnique Per-Recipient QR CodesZero Minimum Orders (Postage Included)
    Supported Webhook Event Stream
    HTTPS JSON POST
    qr.scannedReal-Time

    Recipient scans their unique per-piece QR code. Works on Standard & First Class mail.

    order_item.deliveredFirst Class IMb

    USPS Intelligent Mail Barcode destination scan. Requires First Class (+$0.05 / +$0.21).

    order_item.status_updatedPer-Piece

    Granular piece state updates (queued, printed, mailed) across batch orders.

    order.status_updatedOrder-Level

    Batch transitions (submitted -> in_production -> completed) for ops & billing.

    Delivery: At-Least-Once (event_id)Inspect Schemas ↓
    4 Events
    QR Scans, USPS Delivery, Item & Order State
    $49/mo
    Business Plan Unlocks Webhooks + QR Tracking
    +$0.05
    First Class IMb Upgrade on 4×6 & 6×9 Postcards
    event_id
    Unique Key for Idempotent Retry Deduplication
    Interactive Schema Explorer

    Thanks.io Webhook Event Payloads & Field Schemas

    Select any webhook event below to inspect its JSON payload structure, copy a test fixture, and review required fields and postage prerequisites.

    POSTqr.scanned
    {
      "event_id": "evt_01J9Z8K4X7V2M9Q3R5",
      "event_type": "qr.scanned",
      "occurred_at": "2026-11-29T14:22:18Z",
      "account_id": 18420,
      "subaccount_id": null,
      "data": {
        "order_id": 9184022,
        "order_item_id": 44019283,
        "recipient_id": 7731054,
        "creative_id": 48291,
        "mailing_list_id": 12044,
        "mail_type": "postcard_6x9",
        "name": "Jordan Vance",
        "company": "Northstar Logistics",
        "email": "[email protected]",
        "phone": "+15125550194",
        "address": "742 Evergreen Terrace",
        "city": "Austin",
        "province": "TX",
        "postal_code": "78701",
        "country": "US",
        "scan_url": "https://qr.thanks.io/s/jv88412",
        "destination_url": "https://app.yourcompany.com/offer?cid=hs_449102",
        "custom1": "hs_449102",
        "custom2": "enterprise_renewal_q4",
        "custom3": "rep_sara_chen",
        "custom4": "deal_99120",
        "user_agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X)",
        "ip_address": "198.51.100.42"
      }
    }
    Engineering Note: Recipients often scan a card more than once (for example, re-opening the offer link later). Deduplicate transport retries by event_id, and decide in your business logic whether repeat scans by the same recipient_id should update a scan counter or trigger a fresh rep alert.
    qr.scanned
    Real-Time Engagement

    Emitted the moment a recipient scans the per-recipient QR code printed on a postcard, letter, folded notecard, gift card, or 6×9 MagnaCard. Carries recipient identity, custom merge tags (custom1–custom4), creative ID, and scan metadata so your CRM or Slack channel can react immediately.

    Trigger Timing
    Fires immediately when a recipient scans their unique QR code
    Plan Tier
    Business ($49/mo) or Professional ($199/mo)
    Postage Requirement
    Works on both Standard Mail and First Class Mail
    Key Payload Fields7 documented fields
    FieldTypeDescription
    event_idreqstringGlobally unique delivery identifier. Store this key in Postgres or Redis to deduplicate at-least-once retries.
    event_typereqstringConstant string "qr.scanned" for real-time QR code scan events.
    occurred_atreqstring (ISO-8601)UTC timestamp when Thanks.io recorded the QR redirect hit.
    data.order_id / data.order_item_idreqintegerParent order ID and individual mailpiece ID for joining back to your send log.
    data.recipient_idreqintegerThanks.io recipient identifier across orders, Global Scan List, and Lead Board cards.
    data.custom1 – data.custom4string | nullYour pass-through foreign keys (CRM contact ID, deal ID, campaign slug, account owner) supplied at send time.
    data.scan_url / data.destination_urlreqstring (URL)Per-recipient tracking short URL and resolved landing page URL configured on the creative or API send.
    Copy-Paste Engineering Recipes

    Idempotent Webhook Consumers & Downstream Sync (Postgres, Slack & HubSpot)

    Pick a downstream architecture and switch between Node.js / TypeScript, Python / FastAPI, and SQL or cURL to deploy deduplicated attribution pipelines.

    Idempotent Core

    1. Idempotent Webhook Consumer with Postgres Unique Key & Fast 200 ACK

    Safely ingest at-least-once Thanks.io webhooks without duplicate CRM writes or double notifications. Persists every raw payload with a UNIQUE constraint on event_id and hands processing off to an async worker.

    Best For
    Production SaaS backends, data warehouses, and multi-tenant attribution pipelines
    Architectural Guarantees
    • Deduplicates retries atomically via Postgres INSERT ... ON CONFLICT (event_id) DO NOTHING
    • Returns HTTP 200 OK immediately (< 100ms) so upstream timeouts never trigger cascading retries
    • Retains full raw JSONB payloads for replayability and attribution auditing
    // Node.js / Express + PostgreSQL (pg) — Atomic Idempotent Webhook Receiver
    import express, { Request, Response } from "express";
    import { Pool } from "pg";
    
    const app = express();
    app.use(express.json({ limit: "1mb" }));
    
    const pool = new Pool({ connectionString: process.env.DATABASE_URL });
    const WEBHOOK_PATH_TOKEN = process.env.THANKSIO_WEBHOOK_TOKEN!;
    
    interface ThanksIoEvent {
      event_id: string;
      event_type:
        | "qr.scanned"
        | "order_item.delivered"
        | "order_item.status_updated"
        | "order.status_updated";
      occurred_at: string;
      data: Record<string, unknown>;
    }
    
    app.post("/webhooks/thanksio/:token", async (req: Request, res: Response) => {
      if (req.params.token !== WEBHOOK_PATH_TOKEN) {
        return res.status(401).json({ error: "Invalid webhook token" });
      }
    
      const event = req.body as ThanksIoEvent;
      if (!event?.event_id || !event?.event_type) {
        return res.status(400).json({ error: "Missing event_id or event_type" });
      }
    
      try {
        // Atomic deduplication: returns 1 row only on first-ever receipt of event_id
        const result = await pool.query(
          `INSERT INTO thanksio_webhook_events
             (event_id, event_type, occurred_at, order_id, recipient_id, external_crm_id, payload)
           VALUES ($1, $2, $3, $4, $5, $6, $7)
           ON CONFLICT (event_id) DO NOTHING
           RETURNING event_id`,
          [
            event.event_id,
            event.event_type,
            event.occurred_at,
            event.data?.order_id ?? null,
            event.data?.recipient_id ?? null,
            event.data?.custom1 ?? null, // Pass-through CRM contact ID
            JSON.stringify(event),
          ]
        );
    
        if (result.rowCount === 0) {
          // Duplicate retry — acknowledge 200 OK without re-running side effects
          return res.status(200).json({ ok: true, duplicate: true });
        }
    
        // Enqueue background job (BullMQ / SQS / pg-boss) and ACK immediately
        queueMicrotask(() => {
          void processAttributionEvent(event).catch((err) =>
            console.error("Async webhook worker failed:", event.event_id, err)
          );
        });
    
        return res.status(200).json({ ok: true, duplicate: false });
      } catch (err) {
        console.error("Database ingest error:", err);
        return res.status(500).json({ error: "Temporary ingest failure" });
      }
    });
    
    async function processAttributionEvent(event: ThanksIoEvent) {
      if (event.event_type === "qr.scanned") {
        // Route to Slack, HubSpot, or internal lead scoring
        console.log("Processing QR scan for CRM ID:", event.data.custom1);
      } else if (event.event_type === "order_item.delivered") {
        console.log("Logging USPS delivery for Order Item:", event.data.order_item_id);
      }
    }
    Interactive Attribution & Postage Planner

    Compare Standard vs. First Class IMb Webhook Coverage & Monthly Cost

    All Thanks.io rates include printing and postage with zero minimum order quantities. Webhooks and QR tracking unlock on Business ($49/mo) and Professional ($199/mo)—choose your mail format and postage class below to see exact unit economics and event visibility.

    Lowest-cost QR-tracked postcard; +$0.05 unlocks First Class USPS IMb delivery webhooks

    Pay as you go ($0/mo) supports API sends but does not include QR tracking or webhooks.

    Typically 5–10 business days + USPS IMb delivery webhooks & return-to-sender.

    500 pieces / mo
    Estimated Monthly Total
    $459.00
    Per-Piece Rate
    $0.82
    Blended: $0.92/pc
    4×6 Postcard (Business base)$0.77 / pc
    Postage upgrade (First Class)+$0.05 / pc
    Mail subtotal (500 pcs)$410.00
    Business subscription (webhooks + QR)$49.00 / mo
    Active Webhook Events for This Selection
    • qr.scanned — Real-time per-recipient QR scans
    • order_item.delivered — Active via USPS First Class IMb (typically 5–10 bus. days)
    • order.status_updated & order_item.status_updated
    Per-Recipient QR Architecture

    3 Ways to Attach Tracked QR Codes (Plus Call Attribution)

    Every recipient receives a unique tracked QR URL so you always know exactly who scanned, which creative drove the hit, and when it happened—without sharing generic static QR codes.

    01
    Dashboard Creatives -> API creative_id

    Saved Creative IDs (Decoupled Design & Engineering)

    Configure the QR code destination URL (or Thanks.io's default branded landing page) inside a saved Creative in the dashboard. Even a QR code already printed inside uploaded artwork can be converted into a tracked per-recipient QR code.

    Best when: Marketing iterates on landing URLs, artwork, and handwritten-style copy while engineering only passes creative_id and recipient fields.
    02
    POST /api/v2/recipients/*

    Inline API Parameter (qrcode_url + Merge Tags)

    Pass qrcode_url directly in your send payload with dynamic merge variables such as %CUSTOM1% and %CUSTOM2%. Thanks.io encodes a unique per-recipient tracking URL that records the scan, fires qr.scanned, and redirects cleanly to your destination.

    Best when: Every recipient needs a unique personalized route, pre-filled checkout URL, or per-deal booking link generated by your backend.
    03
    All QR Scans + Lead Board Stage Webhooks

    Global Scan List & Lead Board Automation

    Every scanned recipient automatically enters the Global Scan List (All QR Scans) and appears as a card on your Lead Board (New -> Contacted -> Follow Up -> Done). Business and Professional accounts can trigger follow-up drips or fire stage-change webhooks.

    Best when: You want both engineering webhooks AND an immediate no-code operational queue for reps working warm scanners and AI Receptionist callers.

    Capture Callers Alongside QR Scanners with %YOUR_AI_PHONE%

    Some recipients prefer dialing a phone number rather than scanning a QR code. On Business and Professional plans, your main account's first 24/7 AI Receptionist number is $0/month ($3/month per sub-account number, $0.20/minute for answered calls) and logs every qualified caller onto the same Lead Board alongside your QR scans.

    Explore AI Receptionist
    Production Hardening Checklist

    4 Rules for Bulletproof Direct Mail Webhook Consumers

    Verify every item below in staging before pointing live campaign volume at your webhook endpoint.

    01
    Idempotency

    Deduplicate Every Delivery on event_id

    Thanks.io delivers webhooks with at-least-once semantics, meaning network timeouts or transient 5xx responses can cause the same event to be retried. Store event_id as a PRIMARY KEY in Postgres or an atomic Redis SETNX key before running any CRM or Slack side effect.

    INSERT INTO thanksio_webhook_events (event_id, ...) ON CONFLICT (event_id) DO NOTHING
    02
    Latency & Throughput

    Return HTTP 200 OK in Under 3 Seconds

    Never block the webhook HTTP response while calling slower downstream APIs (HubSpot, Salesforce, Slack, enrichment providers). Validate the request, persist or enqueue the event, return HTTP 200 OK immediately, and process fan-out in an async worker.

    ACK 200 OK (< 150ms) -> Enqueue to BullMQ / SQS / FastAPI BackgroundTasks
    03
    Data Correlation

    Pass Foreign Keys in custom1–custom4 at Send Time

    Matching incoming webhooks back to your CRM by street address or display name is error-prone after USPS CASS standardization. Always pass your immutable internal CRM contact ID in custom1 and campaign slug in custom2 so every webhook joins cleanly.

    recipient.custom1 = "hs_449102" | recipient.custom2 = "q4_renewal"
    04
    Pre-Flight Testing

    Validate with Test Mode + Built-In Webhook Test Trigger

    Enable API Testing Mode under Account Settings -> API Access to verify send payloads without printing or billing, then trigger synthetic webhook payloads from Webhook Settings (or POST /api/v2/webhooks/{id}/test) twice in a row to confirm duplicate suppression works.

    POST /api/v2/webhooks/{id}/test (verify 1st=processed, 2nd=duplicate)
    Postcard API Silo & Ecosystem

    Related API Guides, FAQs & CRM Integrations

    Explore the rest of the Thanks.io developer documentation, compare legacy direct mail APIs, or wire up no-code webhook workflows.

    Developer FAQ

    Direct Mail Webhooks & QR Tracking FAQs

    Straight answers on supported event types, First Class USPS IMb requirements, retry idempotency, and CRM correlation.

    Zero Minimum Orders • Built-In Test Mode & Webhook Test Trigger

    Turn Physical Mail into Real-Time CRM & Slack Events

    Create your Thanks.io account, validate send payloads for free in Test Mode, and unlock per-recipient QR tracking plus real-time webhooks on Business ($49/mo) or Professional ($199/mo).