Integration Guide

How do I normalize tracking statuses across different carriers?

Published: 2026-10-19 • By Vansh Madan, founder of ClearTrack

Map every courier's raw status text onto one small, fixed set of statuses that you own, and store the original text next to the normalized value. In practice that means a rules table per carrier for codes, phrases and abbreviations, a generic fallback for phrases the table doesn't know, and an explicit unknown path that you log and review instead of guessing. The ClearTrack Tracking API does this for 11 Indian carriers and returns one of 11 statuses, plus a coarser current_stage field built for automation.

I maintain the mapping tables behind that API. Most of what follows is what broke along the way.

Why do tracking statuses differ between couriers?

Each courier built its tracking system for its own operations team, not for your code. The differences show up in four places.

Vocabulary. Some feeds send a readable phrase like "Shipment Picked Up". Delhivery's shipment API also carries a short StatusCode such as DL, UD or RT next to the text. Scan remarks are often abbreviated by whoever typed them at the hub, so you get strings like DRLCK for a locked door.

Same word, different stage. "Manifested" is the one that taught me this. In our mapping tables, Delhivery's "Manifested" means the label exists and the parcel is waiting for pickup, so it maps to awaiting_pickup. Xpressbees' "Manifested" maps to order_placed. A single global lookup table can't hold both, which is why carrier-specific rules have to run first.

Negation and substrings. "Undelivered" contains "delivered". A naive includes("delivered") check will mark a failed attempt as delivered and fire a "your order has arrived" message. Negative phrases have to be checked before positive ones.

Shape. Delhivery's tracking_details list arrives oldest-first, while other feeds we read arrive newest-first. Dates come as ISO timestamps, as 15/09/2026 11:21, or as 15-Sep-2026 11:21, sometimes with date and time in separate fields. And scan text sometimes includes the receiver's name or phone number, which you probably don't want in your database or your customer emails.

What should a normalized status model look like?

Keep it small. Every status you add is a branch in someone's notification logic. This is the set ClearTrack returns in the top-level status field:

StatusMeaningTerminal
pendingRegistered, waiting for the first network scanNo
order_placedOrder manifest or shipping label createdNo
awaiting_pickupScheduled for pickup with the courierNo
picked_upCollected by the courier or booked at a branchNo
shippedDispatched from the sorting center into the linehaul networkNo
in_transitMoving between hubsNo
out_for_deliveryAssigned to a local delivery executiveNo
deliveredDelivered to the recipientYes
exceptionDelay, address problem or other issueNo
returnedReturned to sender, RTO completedYes
cancelledCancelled before dispatchYes

Eleven values is still too many to automate against directly. Nobody sends a different email for picked_up versus shipped. So the API also returns insights.current_stage, which groups the lifecycle into the buckets you actually act on: booked, in_transit, out_for_delivery, delivery_attempted, delivered, rto_in_progress, rto_delivered, exception, cancelled and unknown.

Two of those stages don't exist in status at all. delivery_attempted and rto_in_progress are the two moments where someone on your side should do something, so they get their own values. Use status for display, and current_stage for workflows.

Every scan event also gets its own code (booked, picked_up, dispatched, received, out_for_delivery, delivery_attempted, delivered and so on). current_stage is derived from the code of the latest event.

How do I map raw courier statuses myself?

If you only ship with one or two couriers, a hand-written mapper is reasonable. This is the order of operations that worked for me:

  1. Squash the string: lowercase it and strip spaces, underscores and hyphens, so "Out For Delivery", "out_for_delivery" and "OUT-FOR-DELIVERY" all become outfordelivery.
  2. Check carrier-specific rules first.
  3. Then check generic rules, with negative phrases before positive ones.
  4. If nothing matches, return unknown and log the carrier and raw text. Never fall through to a guess.
  5. Store the raw text next to the normalized value.

A minimal version in Node.js:

javascript
const squash = (s = "") => s.toLowerCase().replace(/[\s_\-]+/g, "");

// Checked first: the same word can mean different things per carrier
const CARRIER_RULES = {
  delhivery: [["manifested", "awaiting_pickup"]],
  xpressbees: [["manifested", "order_placed"]],
};

// Checked second, in order: negatives before positives
const GENERIC_RULES = [
  ["undelivered", "exception"],
  ["deliveryfailed", "exception"],
  ["returntosender", "returned"],
  ["outfordelivery", "out_for_delivery"],
  ["delivered", "delivered"],
  ["intransit", "in_transit"],
  ["dispatched", "shipped"],
  ["pickedup", "picked_up"],
  ["cancel", "cancelled"],
];

function normalizeStatus(carrier, rawText) {
  const s = squash(rawText);
  if (!s) return { status: "pending", raw: rawText };
  const rules = [...(CARRIER_RULES[carrier] || []), ...GENERIC_RULES];
  for (const [token, status] of rules) {
    if (s.includes(token)) return { status, raw: rawText };
  }
  console.warn(`unmapped status from ${carrier}: "${rawText}"`);
  return { status: "unknown", raw: rawText };
}

console.log(normalizeStatus("delhivery", "Manifested"));  // awaiting_pickup
console.log(normalizeStatus("bluedart", "Undelivered"));  // exception, not delivered
console.log(normalizeStatus("ekart", "Some new phrase")); // unknown, and logged

The table is the easy part. The ongoing work is keeping it current: couriers add phrases, hubs invent abbreviations, and every new carrier brings its own date format and event order. Budget time to read the unknown log every week.

How should I handle statuses I've never seen?

Don't guess forward. A shipment wrongly marked delivered is worse than one marked unknown, because the first one stops your follow-ups and the second one only looks untidy. Keep the last status you were confident about, show the raw text to your support team, and alert if the same unknown phrase keeps appearing.

Here is how ClearTrack handles it, so you know what you're getting. An empty status becomes pending. A scan whose text we can't classify gets the event code unknown, keeps its original wording in status_text, and goes into a log (with phone numbers and email addresses masked) that I review to add mappings. An unclassified scan still proves someone touched the parcel, so it still counts as activity for stuck-shipment detection. current_stage is unknown only when there are no scan events to read at all.

How do I get normalized statuses from the ClearTrack API?

One endpoint covers every supported carrier. You pass the carrier slug and the AWB, and authenticate with the X-API-Key header:

bash
curl -s "https://api.cleartrackpromise.in/v1/track/indiapost/TEST00000001IN" \
  -H "X-API-Key: YOUR_API_KEY"

The same call from Node.js 18 or later:

javascript
async function main() {
  const res = await fetch(
    "https://api.cleartrackpromise.in/v1/track/delhivery/TESTAWB000001",
    { headers: { "X-API-Key": "YOUR_API_KEY" } }
  );
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
  const t = await res.json();
  console.log(t.status, t.insights.current_stage, t.stale);
  for (const e of t.events) console.log(e.timestamp, e.code, e.status_text);
}
main();

The response has the same shape for every carrier. Trimmed to the fields that matter here:

json
{
  "tracking_number": "TEST00000001IN",
  "carrier": "indiapost",
  "status": "in_transit",
  "status_text": "In Transit: Package in transit",
  "is_delivered": false,
  "is_rto": false,
  "cached": true,
  "stale": false,
  "insights": {
    "current_stage": "in_transit",
    "requires_attention": false,
    "attention_reason": null
  },
  "events": [
    {
      "timestamp": "2026-10-14T07:15:00.000Z",
      "status": "in_transit",
      "code": "dispatched",
      "status_text": "Item Dispatched from Sorting Center"
    },
    {
      "timestamp": "2026-10-14T06:30:00.000Z",
      "status": "picked_up",
      "code": "booked",
      "status_text": "Item Booked"
    }
  ]
}

These are a few raw scan strings from our mapping tables and what the API produces when each one is the latest scan:

Raw scan textEvent codecurrent_stageNDR reason_code
Item Bookedbookedbookednone
Shipment Picked Uppicked_upin_transitnone
Item Dispatcheddispatchedin_transitnone
Out for Deliveryout_for_deliveryout_for_deliverynone
DRLCKdelivery_attempteddelivery_attemptedpremises_closed
Address improperdelivery_attempteddelivery_attemptedaddress_issue
Shipment Delivereddelivereddeliverednone

Failed attempts are also listed under delivery_attempts.attempts, each with one of six reason codes: customer_unavailable, address_issue, refused, premises_closed, cod_not_ready or other. The NDR reason codes reference covers how those are assigned.

What are the limits?

Responses are cached. An in-transit shipment can be up to 30 minutes old; after that, the next request refreshes from the carrier. Delivered, returned and cancelled shipments are cached permanently, since they won't change. If the carrier's service is down and we have an earlier checkpoint, you get HTTP 200 with stale: true, so check that flag before acting on a status. Status text is cleaned of recipient names and phone numbers, which means it's not always word-for-word what the courier sent.

Plans are prepaid in INR; Starter is ₹399 for 1,500 lookups over 30 days, GST included. See pricing for the other plans, or start a free trial (100 lookups for 14 days) to test it on your own AWBs. The full enum reference is in the statuses docs, and the API docs cover authentication and errors.

Frequently asked questions

What is the difference between status and current_stage?

status is one of 11 values describing the shipment's overall state, for display. insights.current_stage is one of 10 coarser workflow stages derived from the latest scan, and includes delivery_attempted and rto_in_progress, which are the stages that usually need action.

Which statuses does ClearTrack normalize to?

Eleven: pending, order_placed, awaiting_pickup, picked_up, shipped, in_transit, out_for_delivery, delivered, exception, returned and cancelled. Of these, delivered, returned and cancelled are terminal.

Does the API return the courier's original status text?

Yes. Both the shipment and each event have a status_text field with the courier's wording, after recipient names and phone numbers are stripped out.

What happens when a courier sends a status ClearTrack doesn't recognize?

The event gets the code unknown and keeps its original text in status_text, and the phrase is logged so a mapping can be added. current_stage is unknown only when there are no scan events at all.

Which carriers does the API normalize?

Delhivery, Blue Dart, Trackon, Shiprocket, Shree Maruti Courier, India Post, Speed Post, Shadowfax, Xpressbees, Ekart Logistics and The Professional Couriers.

Related guides

ClearTrack is not affiliated with, endorsed by, or sponsored by any courier company.