Shiprocket Integration — Tracking Webhook Reference

By Engineering Team•October 11, 2026•5 min read

Shiprocket doesn’t call back synchronously — after GeneratePickup runs (see the fulfillment API reference), it pushes a webhook to POST /shipment/webhook/shiprocket every time the shipment’s status changes. This receiver was originally built against the documented payload shape, with no real traffic to verify it against. Once real traffic arrived, two assumptions broke.

A real, verified payload

{
  "awb": 59629792084,
  "current_status": "Delivered",
  "order_id": "13905312",
  "current_timestamp": "2021-07-02 16:41:59",
  "current_status_id": 7,
  "shipment_status": "Delivered",
  "shipment_status_id": 7,
  "scans": [
    { "date": "2019-06-25 12:08:00", "activity": "SHIPMENT DELIVERED", "location": "PATIALA" },
    { "date": "2019-06-25 10:18:00", "activity": "SHIPMENT OUT FOR DELIVERY", "location": "PATIALA" },
    { "date": "2019-06-24 18:56:00", "activity": "SHIPMENT PICKED UP", "location": "COD PROCESSING CENTRE I" }
  ]
}

(scans[] trimmed above — the live payload carries the full scan history, newest-first, back to pickup.)

Field table

Field Go type Notes
awb json.Number Arrives as a bare JSON number on the wire — declaring it string fails unmarshalling
order_id json.Number Shiprocket’s own order id — this is the lookup key. shipment_id is never sent on this webhook
courier_name string
current_status string Human-readable status label
current_status_id json.Number Only 7 (Delivered) is verified against real traffic so far
current_timestamp string "2006-01-02 15:04:05" layout
shipment_status / shipment_status_id string / json.Number Mirrors current_status/current_status_id in observed traffic
channel_order_id / channel string Placeholder text in every sample seen so far — never populated by real Shiprocket sandbox data
scans[] {date, activity, location}[] Newest-first

Header: X-Api-Key, checked against SHIPROCKET_WEBHOOK_TOKEN — not a bearer token like the outbound calls use.

The two bugs real traffic exposed

The receiver’s original code had a comment admitting “no real Shiprocket tracking-webhook payload has been observed yet.” Once one arrived, two assumptions failed:

  1. Wrong lookup key. The receiver assumed each webhook would carry our shipment ID. It only ever carries Shiprocket’s own order_id — a different identifier shipment-service already stored (from Step 1’s composite "<tenant_id>:<order_id>", see the fulfillment reference) but wasn’t using to look the order back up. Fixed by adding a lookup keyed on Shiprocket’s order_id instead of the local shipment ID.
  2. Wrong field type. awb arrives as a bare JSON number, not a string. A string-typed field fails json.Unmarshal the instant a real numeric value shows up (json: cannot unmarshal number into Go struct field ... of type string). Fixed by declaring it json.Number, the same type already used for order_id/current_status_id.

Neither would have been caught by re-reading Shiprocket’s documentation more carefully — both only surfaced once a real payload was in hand. Treat “works against the docs” and “works against production traffic” as two separate milestones for any inbound webhook, not one.

Processing

  1. Resolve (tenant_id, order_id) by Shiprocket’s order_id — never trusted from elsewhere in the payload, and dropped with a not-found error if no matching order exists.
  2. Validate the event.
  3. Update the order’s shipment status.
  4. Persist the scan into shipment_shiprocket_tracking (one document per order, scans[] holding full history newest-first).
  5. Publish one document-audit event, fire-and-forget (see shipment-service’s “Document audit trail” section).

Response

{ "success": true }