gitlabEdit

๐Ÿ“ฎPostal Dispatch

Learn how to send physical mail through Docs-Dispatcher with MySendingBox and other postal providers.

Overview

This recipe covers:

  1. Sending physical letters via postal mail

  2. Address formatting and validation

  3. Letter specifications (color, duplex, etc.)

  4. Tracking and delivery status

  5. International mail

  6. Complete examples in 4 languages

What You'll Learn

  • Structure postal dispatch requests

  • Format addresses correctly

  • Configure letter options

  • Track delivery status

  • Handle postal webhooks

  • Complete working examples

Prerequisites

  • Docs-Dispatcher account with JWT

  • Postal provider configured (MySendingBox)

  • Template created

  • Basic REST API knowledge

Postal Service Overview

Supported providers:

Provider
Regions
Tracking
Color
Duplex

MySendingBox

USA, International

โœ…

โœ…

โœ…

Lob

USA only

โœ…

โœ…

โœ…

Typical use cases:

  • Customer invoices and statements

  • Legal notices and documents

  • Marketing campaigns

  • Government correspondence

  • Contract delivery

Step 1: Authentication

Dispatcher API uses HTTP Basic Authentication. You'll need your Dispatcher account email and password for all API calls.

Setup Credentials

circle-info

No token management needed! Unlike JWT-based APIs, Basic Auth doesn't require separate authentication endpoints or token refresh. Your credentials are sent with each request.

Quick links:

Step 2: Prepare Postal Request

Basic Postal Structure

Required Fields

Field
Type
Description

providerName

string

Postal provider: mysendingbox, lob

template.id

number

Template ID for letter content

postal.to

object

Recipient address

postal.to.name

string

Recipient name

postal.to.addressLine1

string

Street address

postal.to.city

string

City

postal.to.postalCode

string

ZIP/Postal code

postal.to.country

string

Country code (ISO 3166-1 alpha-2)

Optional Fields

Field
Type
Description

postal.from

object

Return address

postal.options.color

boolean

Color printing (default: false)

postal.options.duplex

boolean

Double-sided (default: true)

postal.options.mailType

string

Mail class (first_class, standard, etc.)

postal.options.returnEnvelope

boolean

Include return envelope

Step 3: Send Postal Mail

Domestic US Letter

Success Response:

International Letter

Step 4: Track Delivery Status

Tracking Events

Postal providers send webhook notifications for:

  • letter_created - Letter queued for printing

  • letter_in_transit - Letter shipped to recipient

  • letter_delivered - Letter delivered successfully

  • letter_returned - Letter returned to sender

  • letter_failed - Delivery failed

Webhook Payload Example

Webhook Handler (Node.js)

Complete Examples

curl (Complete Flow)

Node.js (Complete Flow)

PHP (Complete Flow)

Java (Complete Flow)

Mail Type Options

USPS (United States)

Type
Cost
Speed
Tracking

usps_first_class

$$

2-5 days

โœ…

usps_standard

$

2-8 days

โš ๏ธ Limited

usps_certified

$$$

2-5 days

โœ… Full

International

Type
Regions
Speed

usps_first_class_international

Worldwide

7-21 days

usps_priority_international

Worldwide

6-10 days

Best Practices

1. Validate Addresses

Always validate addresses before sending:

2. Use Duplex Printing

Save costs with double-sided printing:

3. Include Return Address

Error Handling

Common Errors

Invalid Address

Address Not Deliverable

Cost Estimation

Typical costs (USD):

  • Black & White, Single-sided: $0.75 - $1.25

  • Black & White, Duplex: $0.60 - $1.00

  • Color, Single-sided: $1.50 - $2.50

  • Color, Duplex: $1.25 - $2.00

  • International: $2.50 - $5.00

Next Steps

Summary

You've learned:

  • โœ… Send physical mail via postal providers

  • โœ… Format addresses correctly

  • โœ… Configure letter options

  • โœ… Track delivery status

  • โœ… Complete implementations in 4 languages

Postal dispatch bridges digital and physical document delivery!

Last updated