How do I detect the carrier from a tracking number?
Send the number to GET /v1/track/{number} with no ?carrier=. lastscanned detects the carrier in that same call, so there is no separate detect request. Detection is two passes over 551 carriers: a strict match (prefix, length, check digit) and then a looser match. A number that matches nothing fails immediately with HTTP 400 and code unknown_carrier.
Try it
curl "https://api.lastscanned.com/v1/track/1Z000Y770414233027" \
-H "Authorization: Bearer lsk_live_YOUR_KEY"# GLS US has no auto-detected format
curl "https://api.lastscanned.com/v1/track/YOUR_GLS_US_NUMBER?carrier=glsus" \
-H "Authorization: Bearer lsk_live_YOUR_KEY"
# A leased ocean container (owner codes such as TGHU or TCNU)
curl "https://api.lastscanned.com/v1/track/YOUR_CONTAINER_NUMBER?carrier=msc" \
-H "Authorization: Bearer lsk_live_YOUR_KEY"
# A 92… barcode detects as USPS. Pass the partner to ask them directly.
curl "https://api.lastscanned.com/v1/track/YOUR_USPS_NUMBER?carrier=osm" \
-H "Authorization: Bearer lsk_live_YOUR_KEY"Detect, then track
| Option | How it works | Price | Notes |
|---|---|---|---|
| lastscanned | GET /v1/track/{number} with no carrier parameter. Detection and the live status are one call. | Free: 5 numbers a day. Pro: $7.99/mo for 1,000 unique numbers, then $0.015 each. | 551 carriers. A failed detection is not a lookup. |
| AfterShip | POST /trackings. The quick start says you can omit the courier slug and AfterShip will try to detect it from your preferred courier list. | As published on November 21, 2026: Tracking Essentials is $59/mo ($49/mo billed annually) for 1,000 shipments and does not list the API or webhooks. Premium, which lists API and webhooks, is $118/mo ($99/mo billed annually) for 1,000 shipments. Overage is 1.3× the plan's unit price (list price divided by the included quota). Above 5,000 shipments a month is custom. No free plan is listed; the page offers a free trial. | Detection happens as part of creating a tracking, which needs an AfterShip API key. |
| EasyPost | Tracker.create in the published sample takes both a tracking code and a carrier. | As published on November 21, 2026: the pricing page lists the Tracking API at $0.01 to $0.03 per shipment and Advanced Tracking at $0.03 per shipment (contact sales). The tracking page says every shipment whose label is bought through EasyPost comes with a free tracker. Bring Your Own Carrier Accounts is $20/mo plus a per-label fee. | A carrier field is in the sample. A separate detect-only price was not on the page. |
| Shippo | Tracking on a Shippo account. | 2¢ per track on API Starter, as published on November 21, 2026. | A detect-only endpoint was not on the API pricing page read that day. |
Detection notes from lastscanned format reference and AfterShip API quick start, read on November 21, 2026. They can change.
Details
What detection does
The number is trimmed and upper-cased. Pass 1 keeps the first carrier whose strict rule matches, including check digits (UPS 1Z Mod-10, UPU S10, DHL Express). Pass 2 runs only if pass 1 matched nobody, and it covers secondary shapes such as some UniUni, GOFO, Purolator and OSM formats. One carrier wins. A later not_found does not try the next carrier.
When ?carrier= is required
GLS US numbers are not auto-detected, so pass ?carrier=glsus. A leased container (owner codes such as TGHU and TCNU) can sail with any of the six lines, so pass the line, for example ?carrier=msc. Consolidator barcodes that start with 92 detect as USPS. Pass ?carrier=osm or ?carrier=pitneybowes when you want that partner's scans rather than USPS.
FAQ
- Do I need a separate API call to detect the carrier?
- No. GET /v1/track/{number} detects the carrier and returns the tracking result. There is no detect-only endpoint.
- What happens if the number matches no carrier?
- HTTP 400 with code unknown_carrier, before a carrier is asked. That response is not a billed lookup.
- Which numbers detect with no ?carrier=?
- UPS 1Z, USPS IMpb (92, 93, 94 or 95, including a leading 420 ZIP), FedEx 12, 15 or 20 digits, DHL Express 10 digits, and the other formats in the format reference.
- When is ?carrier= required?
- GLS US, a leased ocean container, and a 92… barcode when you want OSM Worldwide or Pitney Bowes instead of USPS.