Track Yanwen (…YP / YW…) parcels and extract the final-mile USPS tracking number in one API call.
Yanwen Logistics (S10 …YP and YW… waybills) consolidates cross-border e-commerce shipments from China and hands US-bound parcels to USPS (or domestic consolidators) after port arrival. Querying GET /v1/track/:number on lastscanned returns Yanwen's international scan history and surfaces the final-mile USPS barcode in the top-level message field ('Handed to USPS as 420...').
Barcode transition: Yanwen to USPS
When Yanwen clears customs and hands off to USPS, lastscanned surfaces the secondary tracking number in the top-level message field.
- Origin / middle-mile carrier
- Yanwen (yanwen)
- Yanwen S10 / Commercial Waybill
- 2 letters + 9 digits + YP (S10 check digit) or YW + 3 letters + 12 digits
- Origin example
- UV123456785YP
- Final-mile carrier
- USPS (usps)
- USPS Domestic IMpb
- 92… / 94… (22 digits) or 420+ZIP+92… (30 digits)
- Final-mile example
- 420100019261290100130612345678
- Extracted in .message
- Handed to USPS as 420100019261290100130612345678
How the Yanwen → USPS handoff works
Follow the parcel across both networks without waiting on asynchronous webhooks or losing visibility at the handoff boundary.
- 1. Pass 1 S10 check-digit validation on …YP waybills
- lastscanned validates the UPU S10 Mod-11 check digit on 13-character …YP numbers (and matches 17-character YW… numbers) to route immediately to yanwen.
- 2. Extract the exchange USPS barcode from message
- When Yanwen generates the US domestic label (exchangeNumber), lastscanned normalizes it into message: 'Handed to USPS as 420...'.
- 3. Follow the USPS barcode to delivery
- Query GET /v1/track/420... to retrieve USPS regional distribution and local carrier delivery scans.
- Yanwen regex & check digit
- /^[A-Z]{2}\d{9}YP$/ with s10(n) validation, or /^YW[A-Z]{3}\d{12}$/.
- Handoff field
- Top-level message string: 'Handed to USPS as <number>'.
- Batch support
- Track up to 100 Yanwen and USPS numbers simultaneously via GET /v1/track?numbers=...
Chain Yanwen → USPS in code or MCP
Resolve both legs synchronously in TypeScript, curl, or your AI support agent via Streamable HTTP MCP.
REST (Synchronous GET)
# 1. Query Yanwen origin waybill (extracts final-mile barcode in .message):
curl "https://api.lastscanned.com/v1/track/UV123456785YP" \
-H "Authorization: Bearer lsk_live_YOUR_API_KEY"
# 2. Query the extracted USPS barcode:
curl "https://api.lastscanned.com/v1/track/420100019261290100130612345678" \
-H "Authorization: Bearer lsk_live_YOUR_API_KEY"TypeScript (Automatic Handoff Chaining)
const headers = { Authorization: `Bearer ${process.env.LASTSCANNED_API_KEY}` };
const originRes = await fetch(`https://api.lastscanned.com/v1/track/${encodeURIComponent(number)}`, { headers });
const originPkg = await originRes.json();
// Extract secondary barcode from top-level message ("Handed to USPS as 420100019261290100130612345678")
const handoff = originPkg.message?.match(/^Handed to (.+?) as ([A-Z0-9-]+)$/i);
if (handoff) {
const [, , lastMileNumber] = handoff;
const destRes = await fetch(`https://api.lastscanned.com/v1/track/${encodeURIComponent(lastMileNumber)}`, { headers });
const destPkg = await destRes.json();
}Remote MCP (Claude Code / Cursor / ChatGPT)
claude mcp add --transport http lastscanned https://mcp.lastscanned.com \
--header "Authorization: Bearer lsk_live_YOUR_API_KEY"Yanwen to USPS Last-Mile Handoff Tracking FAQ
- How do I find the USPS tracking number for a Yanwen (…YP) package?
- Paste your Yanwen tracking number (ending in YP or starting with YW) into the lookup above, or call GET /v1/track/:number. The top-level message field returns the USPS exchange tracking number.
- Why does my Yanwen tracking number have a 30-digit USPS exchange number starting with 420?
- USPS Intelligent Mail package barcodes (IMpb) often prepend '420' plus the 5-digit destination ZIP code ahead of the 22-digit 92… tracking number. lastscanned's USPS detector natively accepts both the 30-digit 420+ZIP+92… format and the 22-digit 92… format.
- Can AI agents resolve Yanwen-to-USPS handoffs automatically?
- Yes. When connected to https://mcp.lastscanned.com, an AI agent sees the 'Handed to USPS as ...' message in the first tool result and can immediately invoke track_package on the USPS barcode.
Other carrier handoff guides
Explore cross-border last-mile barcode extraction and domestic USPS consolidator overrides across all 31 carriers.
- OSM Worldwide to USPS Handoff TrackingOSM Worldwide → USPS
- Pitney Bowes to USPS Handoff TrackingPitney Bowes → USPS
- YunExpress to UniUni Last-Mile Handoff TrackingYunExpress → UniUni
- YunExpress to USPS Last-Mile Handoff TrackingYunExpress → USPS
- Yanwen to UniUni Last-Mile Handoff TrackingYanwen → UniUni
- Cainiao to USPS Last-Mile Handoff TrackingCainiao → USPS
- Cainiao to SpeedX Last-Mile Handoff TrackingCainiao → SpeedX
- 4PX to USPS Last-Mile Handoff Tracking4PX → USPS
- CNE Express to USPS Last-Mile Handoff TrackingCNE Express → USPS
- Asendia USA to USPS / Postal Handoff TrackingAsendia → USPS / Postal
- UBI Smart Parcel to Australia Post / Local Last-Mile Handoff TrackingUBI Smart Parcel → Local Last-Mile