Convert Cainiao / AliExpress (LP… & AP…) tracking numbers to their US final-mile USPS barcode.
Cainiao Smart Logistics (LP + 14–17 digits and AP + 14 digits) handles global fulfillment for AliExpress and Alibaba marketplaces. When a parcel enters the United States and transitions to USPS, lastscanned extracts the destination USPS tracking number directly into the top-level message field ('Handed to USPS as 92...').
Barcode transition: Cainiao to USPS
When Cainiao clears customs and hands off to USPS, lastscanned surfaces the secondary tracking number in the top-level message field.
- Origin / middle-mile carrier
- Cainiao (cainiao)
- Cainiao Waybill
- LP + 14–17 digits or AP + 14 digits (/^(LP\d{14,17}|AP\d{14})$/)
- Origin example
- LP00658129481029
- Final-mile carrier
- USPS (usps)
- USPS Domestic IMpb
- 92… / 94… (22 digits) or 420+ZIP+92… (30 digits)
- Final-mile example
- 9261290100130612345678
- Extracted in .message
- Handed to USPS as 9261290100130612345678
How the Cainiao → USPS handoff works
Follow the parcel across both networks without waiting on asynchronous webhooks or losing visibility at the handoff boundary.
- 1. Query the Cainiao LP… or AP… waybill
- Call GET /v1/track/LP00658129481029. lastscanned auto-detects cainiao in Pass 1 and returns export consolidation and linehaul scans.
- 2. Extract the USPS barcode from message
- When Cainiao links a destination postal barcode, lastscanned populates message: 'Handed to USPS as 92...'.
- 3. Query the USPS barcode for final delivery
- Call GET /v1/track/92... to get local US post office sorting, out_for_delivery, and delivered timestamps.
- Cainiao auto-detection
- /^(LP\d{14,17}|AP\d{14})$/ routes to cainiao in Pass 1.
- Handoff extraction
- Surfaced in top-level message ('Handed to USPS as <number>').
- Consistent JSON shape
- Identical TrackingResult TypeScript interface across both Cainiao and USPS.
Chain Cainiao → 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 Cainiao origin waybill (extracts final-mile barcode in .message):
curl "https://api.lastscanned.com/v1/track/LP00658129481029" \
-H "Authorization: Bearer lsk_live_YOUR_API_KEY"
# 2. Query the extracted USPS barcode:
curl "https://api.lastscanned.com/v1/track/9261290100130612345678" \
-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 9261290100130612345678")
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"Cainiao to USPS Last-Mile Handoff Tracking FAQ
- How do I convert an AliExpress LP… tracking number into a USPS tracking number?
- Enter the LP… tracking number into the lookup above or call GET /v1/track/LP... on lastscanned. When a domestic postal label has been assigned, the response includes 'Handed to USPS as 92...' in the top-level message field.
- What if Cainiao handed my LP… package to SpeedX, UniUni, or OnTrac instead of USPS?
- lastscanned identifies the actual last-mile courier assigned by Cainiao and reports it in message (for example, 'Handed to SpeedX as SPX...' or 'Handed to UniUni as UUS...'), and supports all of those regional couriers natively.
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 USPS Last-Mile Handoff TrackingYanwen → USPS
- Yanwen to UniUni Last-Mile Handoff TrackingYanwen → UniUni
- 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