Skip to content

mail-safety

Applies to: **/mail/**, **/lob/**, **/postscanmail/**, **/letters/**, **/postcards/**

Physical mail sends are irreversible. Once a mail item enters the USPS stream, it cannot be recalled. Every Lob API call that creates a mail item costs real money and cannot be undone.

Before ANY Lob send operation, check the environment:

Terminal window
# Check which key is loaded
echo $LOB_API_KEY | cut -c1-8
# test_live → test (safe, free)
# live_live → LIVE (real money, irreversible)
Key PrefixEnvironmentCostSafe to run?
test_Test / sandboxFreeYes
live_Production~$0.89–$9.00/itemOnly with explicit confirmation
Unset / unknownUnknownUnknownBlock — require confirmation

NEVER call a Lob live endpoint without explicit user confirmation. This includes:

  • POST /v1/letters
  • POST /v1/postcards
  • POST /v1/checks
  • POST /v1/self_mailers

When LOB_ENVIRONMENT is live or unset, emit a warning before proceeding:

⚠ LOB_ENVIRONMENT is set to "live" — this send will cost real money and cannot be recalled.
Confirm: type YES to proceed or NO to abort.

Only continue on explicit YES. Never infer confirmation from context.

Mail TypeTest CostLive Cost
Postcard (4x6)Free~$0.89
Letter (single page)Free~$1.19
Certified letterFree~$9.00
CheckFree~$2.00

Lob enforces 3 sends/minute on the live API. Batch operations must include delays:

// Never exceed 3 sends/minute on live
const RATE_LIMIT_MS = 20_000; // 20 seconds between sends for safety margin

PostScanMail has no sandbox environment. Every API call hits production. This applies to:

  • Creating scan rules
  • Forwarding mail items
  • Shredding mail items (destructive — cannot be undone)
  • Updating mailbox settings

Always confirm intent with the user before write operations. Read-only calls (GET endpoints) are safe.

When both Lob and PostScanMail are involved in the same workflow, verify environment for each independently:

✓ Lob key prefix: test_ → safe
✗ PostScanMail: no sandbox → confirm before write ops

Never assume that a safe Lob environment implies PostScanMail safety.

Always call Lob’s address verification endpoint BEFORE sending a live mail item:

Terminal window
curl -X POST "https://api.lob.com/v1/us_verifications" \
-u "$LOB_API_KEY:" \
--data-urlencode "primary_line=185 Berry St" \
--data-urlencode "city=San Francisco" \
--data-urlencode "state=CA" \
--data-urlencode "zip_code=94107"

Reject sends where deliverability is undeliverable — saves cost and avoids returned mail charges.