{
  "info": {
    "name": "ILS — Tracking Mobile API",
    "_postman_id": "b3f1f9d2-9f1b-4d6d-9e1a-1c2a3b4c5d01",
    "description": "Mobile-app endpoints for the Indian Logistics Services tracking feature.\n\nSource: prfiles/tracking/api/\nDocs:   documentation/api/tracking.md\n\nAll endpoints share the same URL — `action` selects the operation.\nAuthentication: header `Auth-Token` + body `shop`.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "auth": {
    "type": "noauth"
  },
  "variable": [
    {
      "key": "base_url",
      "value": "https://ils.shopiapps.in/prfiles/tracking/api",
      "type": "string"
    },
    {
      "key": "shop",
      "value": "examplestore.myshopify.com",
      "type": "string"
    },
    {
      "key": "auth_token",
      "value": "REPLACE_WITH_MOBILE_APP_ACCESS_TOKEN",
      "type": "string"
    },
    {
      "key": "awb_no",
      "value": "DLV1234567890",
      "type": "string"
    },
    {
      "key": "order_name",
      "value": "#1042",
      "type": "string"
    },
    {
      "key": "order_email",
      "value": "customer@example.com",
      "type": "string"
    }
  ],
  "event": [
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.test('JSON envelope present', function () {",
          "    pm.response.to.be.json;",
          "    var body = pm.response.json();",
          "    pm.expect(body).to.have.property('success');",
          "    pm.expect(body).to.have.property('code');",
          "    pm.expect(body).to.have.property('message');",
          "});"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "01 — Get Tracking Settings",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",                 "type": "text" },
            { "key": "action", "value": "get_tracking_settings",    "type": "text" }
          ]
        },
        "url": {
          "raw": "{{base_url}}/",
          "host": [ "{{base_url}}" ],
          "path": [ "" ]
        },
        "description": "Returns the merchant's tracking-page configuration: theme colours, copy, date/time formats, track method and step labels.\n\nUse this on app launch / first render of the tracking screen."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Returns 200 on valid shop+token', function () {",
              "    pm.response.to.have.status(200);",
              "    var body = pm.response.json();",
              "    pm.expect(body.success).to.eql(true);",
              "    pm.expect(body.data).to.have.property('track_enable');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "02 — AWB Login (track by AWB)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",      "type": "text" },
            { "key": "action", "value": "awb_login",     "type": "text" },
            { "key": "awb_no", "value": "{{awb_no}}",    "type": "text" }
          ]
        },
        "url": {
          "raw": "{{base_url}}/",
          "host": [ "{{base_url}}" ],
          "path": [ "" ]
        },
        "description": "Verifies that an AWB number exists for this shop. Use when the customer chooses to log in with an AWB / tracking number."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Returns awb on success', function () {",
              "    var body = pm.response.json();",
              "    if (body.success) {",
              "        pm.expect(body.data).to.have.property('awb');",
              "    }",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "03 — AWB Login with Order (track by order #)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",        "value": "{{shop}}",          "type": "text" },
            { "key": "action",      "value": "awb_login_with_order","type": "text" },
            { "key": "order_name",  "value": "{{order_name}}",    "type": "text" },
            { "key": "order_email", "value": "{{order_email}}",   "type": "text", "description": "Optional — email OR 10-digit phone." }
          ]
        },
        "url": {
          "raw": "{{base_url}}/",
          "host": [ "{{base_url}}" ],
          "path": [ "" ]
        },
        "description": "Looks up shipment(s) by order number, optionally cross-checked with email/phone (when track_method requires it).\n\nReturns the primary AWB plus a multiple_tracking[] array when the order has more than one shipment."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Stores awb_no for chained requests', function () {",
              "    var body = pm.response.json();",
              "    if (body.success && body.data && body.data.awb) {",
              "        pm.collectionVariables.set('awb_no', body.data.awb);",
              "    }",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "04 — Get Tracking Info (full payload)",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",            "type": "text" },
            { "key": "action", "value": "get_tracking_info",   "type": "text" },
            { "key": "awb_no", "value": "{{awb_no}}",          "type": "text" }
          ]
        },
        "url": {
          "raw": "{{base_url}}/",
          "host": [ "{{base_url}}" ],
          "path": [ "" ]
        },
        "description": "Returns the complete tracking payload for a confirmed AWB:\n  - order_data        : customer + totals\n  - shipment_data     : courier history + processStep\n  - lineitems_data    : product titles, qty, image, handle\n\nprocess_step values: 1=Ordered, 2=Ready to ship, 3=In transit, 4=Out for delivery, 5=Delivered."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Returns full tracking payload on success', function () {",
              "    var body = pm.response.json();",
              "    if (body.success) {",
              "        pm.expect(body.data).to.have.property('order_data');",
              "        pm.expect(body.data).to.have.property('shipment_data');",
              "        pm.expect(body.data).to.have.property('lineitems_data');",
              "        pm.expect(body.data).to.have.property('process_step');",
              "    }",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "Negative — Missing Auth-Token",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",              "type": "text" },
            { "key": "action", "value": "get_tracking_settings", "type": "text" }
          ]
        },
        "url": {
          "raw": "{{base_url}}/",
          "host": [ "{{base_url}}" ],
          "path": [ "" ]
        },
        "description": "Sanity check: request without the Auth-Token header must return 401 UNAUTHORIZED."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Rejects with 401 UNAUTHORIZED', function () {",
              "    pm.response.to.have.status(401);",
              "    var body = pm.response.json();",
              "    pm.expect(body.success).to.eql(false);",
              "    pm.expect(body.code).to.eql('UNAUTHORIZED');",
              "});"
            ]
          }
        }
      ]
    },
    {
      "name": "Negative — Unknown action",
      "request": {
        "method": "POST",
        "header": [
          { "key": "Auth-Token", "value": "{{auth_token}}", "type": "text" }
        ],
        "body": {
          "mode": "urlencoded",
          "urlencoded": [
            { "key": "shop",   "value": "{{shop}}",       "type": "text" },
            { "key": "action", "value": "does_not_exist", "type": "text" }
          ]
        },
        "url": {
          "raw": "{{base_url}}/",
          "host": [ "{{base_url}}" ],
          "path": [ "" ]
        },
        "description": "Unknown action must return 400 INVALID_INPUT."
      },
      "response": [],
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "pm.test('Rejects with 400 INVALID_INPUT', function () {",
              "    pm.response.to.have.status(400);",
              "    var body = pm.response.json();",
              "    pm.expect(body.success).to.eql(false);",
              "    pm.expect(body.code).to.eql('INVALID_INPUT');",
              "});"
            ]
          }
        }
      ]
    }
  ]
}
