for Magento 2
Version 3.0.0Jscriptz USPSv3 is a modern USPS shipping integration for Magento 2 that uses the new USPS REST APIs with OAuth2 authentication. This module provides real-time shipping rates, transit time information, and address validation capabilities using USPS's Shipping Options API.
Modern JSON-based APIs with OAuth2 authentication
Get live shipping rates directly from USPS
Display estimated delivery dates at checkout
Intelligent caching for improved performance
After purchasing the extension, log in to your Jscriptz account to get your Composer authentication token:
Create or update your auth.json file in your Magento root directory:
{
"http-basic": {
"packages.jscriptz.com": {
"username": "YOUR_LICENSE_KEY",
"password": "YOUR_ACCESS_TOKEN"
}
}
}
Replace:
YOUR_LICENSE_KEY - Your license key from My Licenses pageYOUR_ACCESS_TOKEN - The token you copied in Step 1Add the Jscriptz package repository and install the module:
# Add the Jscriptz repository (first time only)
composer config repositories.jscriptz composer https://packages.jscriptz.com
# Install USPSv3 (includes ShippingCore dependency)
composer require jscriptz/module-uspsv3
# Enable the modules
bin/magento module:enable Jscriptz_ShippingCore Jscriptz_USPSv3
# Run setup upgrade
bin/magento setup:upgrade
# Compile DI (production mode)
bin/magento setup:di:compile
# Deploy static content (production mode)
bin/magento setup:static-content:deploy -f
# Clear cache
bin/magento cache:flush
After installation, you need to activate your license in the Magento admin:
Before configuring the module in Magento, you need to create an API project in the USPS Developer Portal to obtain your API credentials.
Visit developers.usps.com and create a free developer account if you don't already have one.
Complete the registration process to get access to the USPS APIs. You'll need to provide basic business information.
After registering, USPS provides a guided setup process to help you create your API credentials.
When creating your API project, select the following APIs:
After your project is created, you'll receive your API credentials. You'll need:
| Environment | Token URL | API Base URL |
|---|---|---|
| Sandbox | https://apis-tem.usps.com/oauth2/v3/token |
https://apis-tem.usps.com |
| Production | https://api.usps.com/oauth2/v3/token |
https://api.usps.com |
Configure the module in the Magento Admin at:
Stores > Configuration > Jscriptz > Jscriptz USPSv3
| Setting | Description |
|---|---|
| Enabled | Enable or disable the USPSv3 shipping method |
| Title | The carrier title shown at checkout (default: "USPS") |
| Environment | Select Sandbox for testing or Production for live rates |
| Setting | Description |
|---|---|
| Consumer Key | Your USPS Consumer Key from the Developer Portal |
| Consumer Secret | Your USPS Consumer Secret from the Developer Portal |
| Setting | Description |
|---|---|
| Allowed Methods | Select which USPS mail classes to offer (leave empty for all) |
| Price Type | Retail, Commercial, or Commercial Plus pricing |
| Maximum Package Weight | Maximum weight per package in lbs (USPS limit: 70 lbs) |
| Handling Fee | Fixed amount added to each shipping rate |
| Free Shipping Threshold | Cart subtotal for free shipping (0 = disabled) |
| Setting | Description |
|---|---|
| Enable Rate Caching | Cache API responses to improve performance |
| Cache TTL | How long to cache rates in seconds (default: 3600) |
| Use Cache on API Failure | Return cached rates if USPS API is unavailable |
| Setting | Description |
|---|---|
| Enable Address Validation | Validate shipping addresses using USPS API |
| Auto-Correct Addresses | Automatically apply USPS address corrections |
| Setting | Description |
|---|---|
| Ship to Applicable Countries | All countries or specific countries only |
| Ship to Specific Countries | Select allowed destination countries |
| Show Method if Not Applicable | Show USPS option even when unavailable |
| Sort Order | Position in shipping method list |
| Setting | Description |
|---|---|
| Debug Mode | Log API requests and responses to uspsv3.log |
apis-tem.usps.com.
Enable Debug Mode to log detailed API information:
var/log/uspsv3.log[USPSv3]# View USPSv3 debug logs
tail -f var/log/uspsv3.log
| Mail Class Code | Service Name | Transit Time |
|---|---|---|
USPS_GROUND_ADVANTAGE |
USPS Ground Advantage | 2-5 business days |
PRIORITY_MAIL |
Priority Mail | 1-3 business days |
PRIORITY_MAIL_EXPRESS |
Priority Mail Express | 1-2 days, guaranteed |
PARCEL_SELECT |
Parcel Select | 2-8 business days |
PARCEL_SELECT_LIGHTWEIGHT |
Parcel Select Lightweight | 2-8 days (items < 1 lb) |
MEDIA_MAIL |
Media Mail | 2-8 days (books, CDs only) |
LIBRARY_MAIL |
Library Mail | 2-8 days (library materials) |
BOUND_PRINTED_MATTER |
Bound Printed Matter | 2-8 days (catalogs, directories) |
| Mail Class Code | Service Name |
|---|---|
PRIORITY_MAIL_INTERNATIONAL |
Priority Mail International |
PRIORITY_MAIL_EXPRESS_INTERNATIONAL |
Priority Mail Express International |
FIRST_CLASS_PACKAGE_INTERNATIONAL |
First-Class Package International |
GLOBAL_EXPRESS_GUARANTEED |
Global Express Guaranteed |
| Code | Description |
|---|---|
RETAIL |
Standard retail pricing (default) |
COMMERCIAL |
Discounted commercial pricing (requires business account) |
COMMERCIAL_PLUS |
Additional discounts for high-volume shippers |
| Service | Maximum Weight |
|---|---|
| Most USPS Services | 70 lbs |
| First-Class Package | 13 oz |
| Parcel Select Lightweight | 1 lb |
Solution:
Solution:
If rates seem outdated:
bin/magento cache:flushTransit times come from the USPS Shipping Options API response. If not displayed:
commitment.scheduleDeliveryDate in the API response
Yes, Jscriptz USPSv3 uses the carrier code uspsv3 and operates independently of Magento's core USPS module (usps). You can run both simultaneously, though we recommend disabling the core module to avoid customer confusion.
No! Unlike UPS and FedEx, USPS does not require an account number to use their APIs. You only need API credentials from the Developer Portal. However, for Commercial or Commercial Plus pricing, you may need a business relationship with USPS.
Retail is standard pricing available to everyone. Commercial pricing offers discounts for businesses that ship regularly. Commercial Plus provides additional discounts for high-volume shippers. Most stores start with Retail pricing.
The Shipping Options API (v3) returns both pricing AND transit times in a single API call, reducing latency and improving checkout performance. This is more efficient than the older approach of making separate calls for rates and delivery estimates.
The default TTL of 3600 seconds (1 hour) works well for most stores. USPS rates don't change as frequently as carrier rates, so caching is very effective. For high-traffic stores, keep caching enabled to reduce API calls.
Yes, set a Free Shipping Threshold amount. When the cart subtotal exceeds this amount, all USPS rates will show as $0.00.
Most USPS services support packages up to 70 lbs. This is lower than UPS and FedEx (150 lbs). First-Class Package is limited to 13 oz.
USPS Ground Advantage replaced several services in 2023, including First-Class Package Service, Parcel Select Ground, and Retail Ground. It's now the primary ground shipping option for packages up to 70 lbs.
Yes, the module supports international USPS services including Priority Mail International, Priority Mail Express International, First-Class Package International, and Global Express Guaranteed.
USPSv3 works seamlessly with the Jscriptz_ShippingCore module, which provides enhanced shipment management features in the Magento admin.
When ShippingCore is installed, the Sales > Shipments grid is enhanced with additional columns and mass actions:
| Column | Description |
|---|---|
| Tracking Number | Displays tracking number(s) with clickable link to carrier tracking |
| Carrier | Shows carrier name (USPS, UPS, FedEx, etc.) |
| Label Status | Indicates whether a shipping label has been generated |
| Tracking Status | Shows if tracking notification has been sent to customer |
| Shipping Price | Displays the shipping amount charged for the order |
| Label | Action link to view/download shipping label (when available) |
Process multiple shipments at once with these mass actions: