Updated December 2026. Codes and rules verified against carrier documentation; see references at the end.
USPS tracking events carry a two-character eventCode (for example GX label created, OF out for delivery, 01 delivered) plus a USPS.com status category, while UPS events carry a one- or two-letter status type (M, I, D, X, MV, U) and a numeric statusCode. To show one status in your app, map both into a small normalized set: label_created, in_transit, out_for_delivery, delivered, exception and returned. Map on the code first and use the event text, category or type to break ties, because a few codes (USPS GX and 10, for example) cover more than one meaning.
For what each status means to a recipient, see USPS tracking statuses explained.
| API | Endpoint (production) | Notes from the carrier spec |
|---|---|---|
| USPS Tracking v3r2 | POST https://apis.usps.com/tracking/v3r2/tracking | Body is an array of 1 to 35 tracking requests; tracking numbers are 4 to 34 characters. OAuth scope tracking. |
| USPS Tracking v3 (legacy) | https://apis.usps.com/tracking/v3 | USPS says the legacy Tracking 3.0 and Subscriptions 3.0 APIs retire July 31, 2027. Migrate to v3r2. |
| USPS Subscriptions - Tracking v3r2 | https://apis.usps.com/subscriptions-tracking/v3r2/subscriptions | Push notifications by Mailer ID (MID) or tracking number. |
| UPS Track API | GET https://onlinetools.ups.com/api/track/v1/details/{inquiryNumber} | Inquiry numbers are 7 to 34 characters. Data rolls off after a 120-day retention period. Test host: wwwcie.ups.com. |
| UPS Track Alert v2 | POST https://onlinetools.ups.com/api/track/v2/subscription/{type}/package | Webhook subscriptions for 1Z and 1R (Roadie) tracking numbers. |
USPS notes that v3r2 can show different messaging, and sometimes different events, than USPS.com and legacy v3.
The API points to Pub 199 Appendix G-4 for eventCode values, which now refers you to the PostalPro list "USPS Domestic Tracking Scan Events." The table below uses its November 2026 edition. The status category column is what USPS.com shows; v3r2 returns the same idea in statusCategory.
| eventCode | Event (USPS.com wording) | Status category | Normalize to |
|---|---|---|---|
| GX | Shipping Label Created, USPS Awaiting Item | Pre-Shipment | label_created |
| GX | Label Cancelled | Pre-Shipment | exception (voided) |
| MA | Pre-Shipment, USPS Awaiting Item (manifest received) | Pre-Shipment | label_created |
| 03 | USPS picked up item / USPS in possession of item | Accepted | in_transit |
| OA | Accepted at USPS Origin Facility | Accepted | in_transit |
| SF | Departed Post Office | In Transit | in_transit |
| 10 | Arrived at / Processing at USPS Facility | In Transit | in_transit |
| A1, E1, A2 | Arrived at / Departed USPS Facility; In Transit to Next Facility | In Transit | in_transit |
| 07 | Arrived at Post Office | In Transit | in_transit |
| OF | Out for Delivery | Out for Delivery | out_for_delivery |
| 59 | Out for Delivery / Out for Redelivery | Out for Delivery | out_for_delivery |
| 01 | Delivered (mailbox, front door, parcel locker, PO Box and other attributes) | Delivered | delivered |
| 43 | Picked Up (delivered at a postal facility) | Delivered | delivered |
| 02 | Notice Left (subcodes 54, 55, 56) | Delivery Attempt: Action Needed | exception |
| 14 | Available for Pickup | Available for Pickup | exception |
| 30 | No Access to Delivery Location | Alert | exception |
| 57 | Delivery Exception, Local Weather Delay | Alert | exception |
| DX | Awaiting Delivery (no delivery event within 18 hours of out for delivery) | Alert | exception |
| 44 | Intercepted; item overweight, oversize or damaged, pickup required; hazmat hold | Alert | exception |
| 04 | Refused (being returned to sender) | Alert | returned |
| 09 | Return to Sender (subcodes 21 to 29) | Alert | returned |
| 21, 22, 23, 26, 27 | No Such Number, Insufficient Address, Moved Left No Address, Vacant, Unclaimed | Alert | returned |
Three codes need the event text as well as the code. GX covers both label created and label cancelled. 10 is normally a facility scan, but USPS also uses it for "Seized by USPS for Counterfeit Postage" and "Unpaid postage, item will not be delivered," both in the Alert category. 01 with the "Delivered, To Original Sender" wording is a delivered return, which your customer sees very differently from a delivery.
The Tracking API appendix lists these under "Package Activity Types." Track Alert uses the same letters with slightly different definitions, which matters for out for delivery.
| Type | Track API appendix | Track Alert definition | Normalize to |
|---|---|---|---|
| M | Billing Information Received | Manifest | label_created |
| MV | Billing Information Voided | Manifest Void | exception (voided) |
| I | In Transit, Out for Delivery | In-progress (on the way) | in_transit, or out_for_delivery by statusCode |
| D | Delivered | Delivery information: loaded on delivery vehicle, out for delivery, delivered | delivered or out_for_delivery by statusCode |
| X | Exception | Package Exception | exception, or returned by statusCode |
| U | Updates (Track Alert API only) | Updated delivery date or time | keep previous status |
| NA | Not Available | Not listed | unknown |
| DO, DD, W | Freight only (delivered origin CFS, delivered destination CFS, warehousing) | Not listed | handle separately |
The numeric statusCode (the "Status/Description Codes" table in the appendix; Track Alert calls it descriptionCode) is more specific. API examples show it zero-padded, such as '003' and 021, so compare it as an integer.
| statusCode | UPS description | Normalize to |
|---|---|---|
| 3, 157 | Shipment Ready for UPS | label_created |
| 7 | Shipment Information Voided | exception (voided) |
| 5, 10, 25 | On the Way | in_transit |
| 38 | Picked Up by UPS | in_transit |
| 6, 21, 37, 89, 91, 146, 162 | Out for Delivery | out_for_delivery |
| 11 | Delivered | delivered |
| 26 | Delivered by Local Post Office | delivered |
| 143 | Delivered to Agent | delivered |
| 13 | Exception | exception |
| 29 | Exception: Action Required | exception |
| 22, 24 | First Attempt Made / Final Attempt Made | exception |
| 17 | Held for Customer Pickup | exception |
| 34, 35, 36 | Returned to Sender / Returning to Sender | returned |
Map specific codes first (returned beats delivered), then the carrier's category or type. These two functions pass test cases built from the tables above. The code sets also include a few related codes from the same carrier lists that the tables leave out.
# USPS Tracking v3r2: map one trackingEvents[] item (or the top-level
# status fields) to a normalized status. Codes: PTR Domestic Scan Events.
USPS_RETURNED = {"04", "09", "21", "22", "23", "24", "25", "26", "27", "28", "29"}
USPS_DELIVERED = {"01", "17", "43", "60"}
USPS_OUT_FOR_DELIVERY = {"OF", "59"}
USPS_LABEL = {"GX", "MA"}
USPS_EXCEPTION = {"02", "14", "30", "44", "54", "55", "56", "57", "DX"}
USPS_EXCEPTION_CATEGORIES = ("alert", "delivery attempt", "available for")
def normalize_usps(event_code, event_type="", status_category=""):
code = (event_code or "").strip().upper()
text = (event_type or "").lower()
category = (status_category or "").lower()
if code in USPS_RETURNED or "original sender" in text:
return "returned"
if code in USPS_DELIVERED:
return "delivered"
if code in USPS_OUT_FOR_DELIVERY:
return "out_for_delivery"
if code in USPS_LABEL:
return "exception" if "cancel" in text else "label_created"
if (code in USPS_EXCEPTION or category.startswith(USPS_EXCEPTION_CATEGORIES)
or "seized" in text or "unpaid postage" in text):
return "exception"
return "in_transit"
# UPS Track API (currentStatus / activity[].status) or Track Alert
# (activityStatus). Codes: UPS Tracking API appendix.
UPS_DELIVERED = {11, 26, 143}
UPS_OUT_FOR_DELIVERY = {6, 21, 37, 89, 91, 146, 162}
UPS_RETURNED = {34, 35, 36, 67, 81}
UPS_LABEL = {3, 80, 157, 166}
UPS_EXCEPTION = {7, 13, 17, 22, 24, 29}
def normalize_ups(status_type, status_code="", description=""):
t = (status_type or "").strip().upper()
num = int(status_code) if str(status_code).strip().isdigit() else None
for codes, label in ((UPS_RETURNED, "returned"), (UPS_DELIVERED, "delivered"),
(UPS_OUT_FOR_DELIVERY, "out_for_delivery"),
(UPS_LABEL, "label_created"), (UPS_EXCEPTION, "exception")):
if num in codes:
return label
if t == "M":
return "label_created"
if t in ("X", "MV"):
return "exception"
if t == "D": # Track Alert also uses D for out-for-delivery scans
return "delivered" if (description or "").lower().startswith("delivered") else "out_for_delivery"
if t == "U": # date/time update only: keep the previous status
return None
if t == "I":
return "in_transit"
return "unknown"
Pickup-ready events map to exception here because the recipient has to act; add a seventh status if you message pickup differently. Store the raw code, type and text beside the normalized value so you can remap history when carriers add codes.
Both carriers offer push. Polling is still useful for backfill: UPS states that Track Alert keeps no history, so call the Track API for events before you subscribed.
| Item | USPS Subscriptions - Tracking v3r2 | UPS Track Alert v2 |
|---|---|---|
| Subscribe by | Mailer ID or single tracking number | Tracking numbers, up to 100 per request (error VSS220 above that) |
| Event filter | ALL_UPDATES, DELIVERY_ACTIVITY, PACKAGE_DELAYED; SCAN_EVENT_EXTRACT for MID subscriptions | Optional preferences D, I, M, X (enhanced users) |
| How long it lasts | USPS may delete a subscription after 30 days with no traffic to the listener URL; warning email at 25 days | 14 days per tracking number; resubscribe if not delivered |
| Failed deliveries | Retries for 24 hours, then suspends every subscription on that listener URL and discards pending events | Not stated in the FAQ or spec |
| Security | Optional IP allowlisting and HMAC-SHA256 in the X-HMAC header (32-character secret) | HTTPS on port 443 only; in v2, webhook credentials are managed on the UPS Manage Webhook Credentials page |
| Other limits | Up to 10 unique listener URLs per Home CRID | CIE test numbers 1ZCIETST0111111114, 1ZCIETST0422222228, 1ZCIEPIC0111111116 |
If you poll, cache. UPS's tracking best practices say to avoid redundant calls for the same number and warn that frequent polling can lead to throttling. USPS states that its APIs have usage limits and that higher limits are requested through USPS API Support; the tracking spec documents HTTP 429 with a Retry-After header. Batch USPS lookups up to the 35-item request limit.
To verify a USPS notification, concatenate the body's timestamp and payload strings, HMAC them with your secret using SHA-256, Base64-encode the result and compare it with X-HMAC. The payload field is itself a JSON string.
import base64, hashlib, hmac, json
def verify_usps_notification(raw_body: bytes, x_hmac: str, secret: str):
"""Return the parsed tracking payload if X-HMAC matches, else None."""
body = json.loads(raw_body)
message = (body["timestamp"] + body["payload"]).encode("utf-8")
digest = hmac.new(secret.encode("utf-8"), message, hashlib.sha256).digest()
expected = base64.b64encode(digest).decode("ascii")
if not hmac.compare_digest(expected.encode(), (x_hmac or "").encode()):
return None
return json.loads(body["payload"]) # payload is a JSON string
Return HTTP 200 quickly and process the event on a queue. A slow handler that times out for a day can suspend every USPS subscription on that URL.
activity most recent first but milestones oldest first.MA as electronic manifest data that "does not signify receipt of the shipment." Don't start delivery-time SLAs until an Accepted or first in-transit scan.uniqueTrackingID and mailingDate to separate them, and event 46 flags a duplicate label ID.For retry and error patterns in agent tools that call these APIs, see error handling for shipping agents. If you are still on USPS Web Tools, start with the USPS Web Tools retirement and migration guide.
GX is "Shipping Label Created, USPS Awaiting Item." USPS has not scanned the package yet. The same code is also used for "Label Cancelled," so check the event text before you mark a shipment as created.
For USPS, use eventCode OF or 59. For UPS, use statusCode 6, 21, 37, 89, 91, 146 or 162. The Track API appendix lists out for delivery under type I, while the Track Alert FAQ includes it under type D, so the letter alone is ambiguous.
USPS says Tracking 3.0 legacy and Subscriptions Tracking 3.0 legacy retire July 31, 2027. The replacements are Tracking v3r2 and Subscriptions - Tracking v3r2.
X is an exception. Read the numeric statusCode for detail: in the appendix, 34 to 36 are returns to sender and 22 and 24 are delivery attempts.
Ship.com gives you USPS and UPS labels at up to 89% off USPS and up to 87% off UPS without your own carrier accounts, from your code through the REST API or from AI agents through the MCP server. Every account starts with a 30-day free trial, no credit card required. Read the Ship MCP setup guide or See plans and pricing.