Laravel USPS v13.3 20 APIs

Complete USPS API v3 (OAuth2) for Laravel 10–13 — 20 API domains, 80+ endpoints, REST routes, input validation

The legacy USPS Web Tools XML API was retired January 2026. This package uses the new OAuth2-based REST/JSON API at apis.usps.com with automatic token management and per-scope caching.

Installation

composer require johnpaulmedina/laravel-usps

Configuration

php artisan vendor:publish --tag=usps-config
USPS_CLIENT_ID=your-client-id
USPS_CLIENT_SECRET=your-client-secret

Register at developer.usps.com for credentials.

Artisan Commands

# Validate an address
php artisan usps:validate "1600 Pennsylvania Ave NW" --state=DC --zip=20500

# Track packages
php artisan usps:track 9400111899223456789012

# ZIP code lookup
php artisan usps:zip 33101

# Calculate shipping rates
php artisan usps:price 20500 33101 16 --mail-class=PRIORITY_MAIL

# Delivery estimates
php artisan usps:standards 20500 33101

# Find USPS locations
php artisan usps:locations 33101 --type=post-office --radius=5

All commands output formatted tables to the console.

REST API Routes

Publish routes to your app:

php artisan vendor:publish --tag=usps-routes

27 routes under /api/usps/ with Form Request validation. 13 controllers, 26 request classes.

Input Validation

All inputs are automatically normalized and validated:

API Domains

Addresses
Validate, standardize, ZIP/city lookup
3 endpoints
Tracking
Track packages, notifications, proof of delivery
3 endpoints
Domestic Labels
Create, cancel, reprint, branding, indicia, IMB
12 endpoints
International Labels
Create, reprint, cancel international labels
4 endpoints
Domestic Prices
Base rates, extra services, total rates, letters
5 endpoints
International Prices
International postage rate calculations
5 endpoints
Service Standards
Delivery estimates and standards by ZIP
2 endpoints
Standards Directory
Bulk service standard data with pagination
2 endpoints
Standards Files
Download service standard data files
2 endpoints
Intl Standards
International delivery standard messages
1 endpoint
Locations
Post offices, dropoff locations, parcel lockers
3 endpoints
Carrier Pickup
Schedule, get, update, cancel pickups
5 endpoints
Containers
Container labels, package management, manifests
5 endpoints
Payments
Payment authorization tokens, account inquiry
2 endpoints
Mail Campaigns
Informed Delivery mail campaigns, IMBs
9 endpoints
Pkg Campaigns
Informed Delivery package campaigns
6 endpoints
Adjustments
Shipping charge adjustments by tracking number
1 endpoint
Disputes
Create disputes for pricing adjustments
1 endpoint
Appointments
FAST facility appointments, availability
4 endpoints

Endpoint Reference

Addresses Usps::validate()

Validate Response

{
  "address": {
    "Address2": "1600 PENNSYLVANIA AVE NW",
    "Address1": "",
    "City": "WASHINGTON",
    "State": "DC",
    "Zip5": "20500",
    "Zip4": "0005"
  },
  "additionalInfo": {
    "DPVConfirmation": "Y",
    "business": "Y",
    "vacant": "N"
  }
}

When Apartment is Missing

{
  "address": { "Address2": "100 S BISCAYNE BLVD", ... },
  "corrections": [{
    "code": "32",
    "text": "...more information is needed (apartment, suite, or box number)..."
  }],
  "additionalInfo": { "DPVConfirmation": "D" }
}

DPV (Delivery Point Validation)

Confirms whether the address is a real USPS deliverable location — down to the apartment/suite level.

CodeMeaning
YFull match — street and unit confirmed
DPrimary confirmed, apartment/suite missing
SPrimary confirmed, apartment/suite doesn't match
NNot a valid delivery point

Correction codes: 32 = apartment needed, 22 = multiple addresses found

City/State Lookup Response

{ "city": "WASHINGTON", "state": "DC", "ZIPCode": "20500" }

ZIP Code Lookup Response

{
  "address": {
    "streetAddress": "1600 PENNSYLVANIA AVE NW",
    "city": "WASHINGTON",
    "state": "DC",
    "ZIPCode": "20500",
    "ZIPPlus4": "0005"
  }
}

State names auto-convert (Florida → FL). ZIP+4 auto-splits (20500-0005 → 20500 + 0005).
Full USPS Address API docs →

Tracking Usps::tracking()

Domestic Labels Usps::labels()

International Labels Usps::internationalLabels()

Domestic Prices Usps::domesticPrices()

International Prices Usps::internationalPrices()

Service Standards Usps::serviceStandards()

Service Standards Directory Usps::serviceStandardsDirectory()

Service Standards Files Usps::serviceStandardsFiles()

International Service Standards Usps::internationalServiceStandards()

Locations Usps::locations()

Carrier Pickup Usps::carrierPickup()

Containers Usps::containers()

Payments Usps::payments()

Informed Delivery Campaigns Usps::campaigns()

Package Campaigns Usps::packageCampaigns()

Adjustments Usps::adjustments()

Disputes Usps::disputes()

Appointments Usps::appointments()

Shipping Options Usps::shippingOptions()

SCAN Forms Usps::scanForms()

Requirements

PHP8.1+
Laravel10, 11, 12, 13
USPS Credentialsdeveloper.usps.com