{
  "info": {
    "_postman_id": "a1b2c3d4-route-planning-webhook-demo",
    "name": "Route Planning — Webhook ingest demo",
    "description": "Three demo payloads for POST /rest/route-planning/webhook/orders.\n\n**Setup**\n1. Set collection variables: `baseUrl`, `contextPath`, `tenantId`, `webhookSecret`.\n2. Configure server secret (`routeplanning.webhook.secret` or per-tenant property).\n3. Send any request — the collection pre-request script signs the raw JSON body.\n\n**After success**\n- Open Route planning → Session history → **Open** the returned `sessionId`.\n- Location review should show route **start already set** from ingest (standalone depot or linked pickup row).\n- TCMS booking pickup address uses the ingested depot — not dummy defaults.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
  },
  "variable": [
    { "key": "baseUrl", "value": "https://localhost:8443" },
    { "key": "tenantId", "value": "your-tenant-id" },
    { "key": "webhookSecret", "value": "your-webhook-secret" }
  ],
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          "const secret = pm.collectionVariables.get('webhookSecret');",
          "const tenantId = pm.collectionVariables.get('tenantId');",
          "const body = pm.request.body && pm.request.body.mode === 'raw' ? pm.request.body.raw : '';",
          "if (!secret) {",
          "  throw new Error('Set collection variable webhookSecret before sending.');",
          "}",
          "if (!tenantId) {",
          "  throw new Error('Set collection variable tenantId before sending.');",
          "}",
          "const signature = CryptoJS.HmacSHA256(body, secret).toString(CryptoJS.enc.Hex);",
          "pm.request.headers.upsert({ key: 'Content-Type', value: 'application/json' });",
          "pm.request.headers.upsert({ key: 'X-Tenant-Id', value: tenantId });",
          "pm.request.headers.upsert({ key: 'X-Signature', value: 'sha256=' + signature });",
          "pm.request.headers.upsert({ key: 'X-Idempotency-Key', value: pm.variables.replaceIn('{{$guid}}') });"
        ]
      }
    }
  ],
  "item": [
    {
      "name": "Demo 1 — Standalone depot (depot object)",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"planningDate\": \"2026-06-12\",\n  \"planningTimezone\": \"Asia/Kuala_Lumpur\",\n  \"customerId\": \"1001\",\n  \"customerName\": \"Acme Trading Sdn Bhd\",\n  \"depot\": {\n    \"name\": \"Shah Alam Main DC\",\n    \"address\": \"Lot 7 Jalan Industri 1, Seksyen 15\",\n    \"city\": \"Shah Alam\",\n    \"state\": \"Selangor\",\n    \"pincode\": \"40000\",\n    \"lat\": 3.0738,\n    \"lng\": 101.5183\n  },\n  \"orders\": [\n    {\n      \"externalOrderId\": \"SO-DEMO-1001\",\n      \"customerName\": \"Acme Trading Sdn Bhd\",\n      \"address\": \"12 Jalan Ampang\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"50450\",\n      \"lat\": 3.1578,\n      \"lng\": 101.712,\n      \"serviceTimeMinutes\": 15,\n      \"weightKg\": 120,\n      \"volumeM3\": 1.2,\n      \"picName\": \"Ahmad Rizal\",\n      \"picPhone\": \"+60123456789\",\n      \"timeWindowStart\": \"08:00\",\n      \"timeWindowEnd\": \"17:00\",\n      \"notes\": \"Demo 1 — standalone depot\"\n    },\n    {\n      \"externalOrderId\": \"SO-DEMO-1002\",\n      \"customerName\": \"Beta Retail\",\n      \"address\": \"88 Jalan Tun Razak\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"50400\",\n      \"lat\": 3.1612,\n      \"lng\": 101.7145,\n      \"serviceTimeMinutes\": 10,\n      \"weightKg\": 45,\n      \"volumeM3\": 0.4,\n      \"picName\": \"Siti Aminah\",\n      \"picPhone\": \"+60198765432\",\n      \"timeWindowStart\": \"09:00\",\n      \"timeWindowEnd\": \"12:00\"\n    },\n    {\n      \"externalOrderId\": \"SO-DEMO-1003\",\n      \"customerName\": \"Gamma Hub\",\n      \"address\": \"5 Persiaran KLCC\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"50088\",\n      \"lat\": 3.1579,\n      \"lng\": 101.7116,\n      \"serviceTimeMinutes\": 20,\n      \"weightKg\": 200,\n      \"volumeM3\": 2.0,\n      \"picName\": \"Ops Desk\",\n      \"picPhone\": \"+60312345678\",\n      \"timeWindowStart\": \"07:30\",\n      \"timeWindowEnd\": \"11:00\"\n    }\n  ]\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": "{{baseUrl}}/rest/route-planning/webhook/orders",
        "description": "Pickup is a separate `depot` object (not a delivery stop). Route start is pre-configured; Route setup step is skipped when depot coords are valid."
      },
      "response": []
    },
    {
      "name": "Demo 2 — Pickup row linked (sourceOrderId)",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"planningDate\": \"2026-06-12\",\n  \"planningTimezone\": \"Asia/Kuala_Lumpur\",\n  \"customerId\": \"1001\",\n  \"customerName\": \"Acme Trading Sdn Bhd\",\n  \"depot\": {\n    \"name\": \"Central warehouse — Set as start\",\n    \"sourceOrderId\": \"WH-START\",\n    \"address\": \"Lot 12 Jalan Logistik 3\",\n    \"city\": \"Shah Alam\",\n    \"state\": \"Selangor\",\n    \"pincode\": \"40150\",\n    \"lat\": 3.0472,\n    \"lng\": 101.5245\n  },\n  \"orders\": [\n    {\n      \"externalOrderId\": \"WH-START\",\n      \"customerName\": \"Acme Trading Sdn Bhd\",\n      \"address\": \"Lot 12 Jalan Logistik 3\",\n      \"city\": \"Shah Alam\",\n      \"state\": \"Selangor\",\n      \"pincode\": \"40150\",\n      \"lat\": 3.0472,\n      \"lng\": 101.5245,\n      \"serviceTimeMinutes\": 5,\n      \"weightKg\": 1,\n      \"volumeM3\": 0.01,\n      \"picName\": \"Warehouse gate\",\n      \"picPhone\": \"+60311112222\",\n      \"notes\": \"Pickup row — Set as start pre-selected in Location review\"\n    },\n    {\n      \"externalOrderId\": \"SO-DEMO-2001\",\n      \"customerName\": \"Delta Mart\",\n      \"address\": \"21 Jalan Bukit Bintang\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"55100\",\n      \"lat\": 3.147,\n      \"lng\": 101.7105,\n      \"serviceTimeMinutes\": 12,\n      \"weightKg\": 35,\n      \"volumeM3\": 0.3,\n      \"picName\": \"Lee Wei\",\n      \"picPhone\": \"+60112233445\",\n      \"timeWindowStart\": \"10:00\",\n      \"timeWindowEnd\": \"14:00\"\n    },\n    {\n      \"externalOrderId\": \"SO-DEMO-2002\",\n      \"customerName\": \"Epsilon Pharmacy\",\n      \"address\": \"10 Jalan Sultan Ismail\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"50250\",\n      \"lat\": 3.1555,\n      \"lng\": 101.7058,\n      \"serviceTimeMinutes\": 8,\n      \"weightKg\": 18,\n      \"volumeM3\": 0.1,\n      \"picName\": \"Nurul\",\n      \"picPhone\": \"+60187654321\",\n      \"timeWindowStart\": \"08:30\",\n      \"timeWindowEnd\": \"16:00\",\n      \"fragile\": true\n    }\n  ]\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": "{{baseUrl}}/rest/route-planning/webhook/orders",
        "description": "Includes a pickup stop in `orders` plus `depot.sourceOrderId`. Server links stop id → route start; Location review shows **Set as start** on that row."
      },
      "response": []
    },
    {
      "name": "Demo 3 — pickupLocation alias (3 deliveries)",
      "request": {
        "method": "POST",
        "header": [],
        "body": {
          "mode": "raw",
          "raw": "{\n  \"planningDate\": \"2026-06-12\",\n  \"planningTimezone\": \"Asia/Kuala_Lumpur\",\n  \"customerId\": \"1002\",\n  \"customerName\": \"Beta Retail Group\",\n  \"pickupLocation\": {\n    \"name\": \"Petaling Jaya Cross-dock\",\n    \"address\": \"18 Jalan SS7/26, Kelana Jaya\",\n    \"city\": \"Petaling Jaya\",\n    \"state\": \"Selangor\",\n    \"pincode\": \"47301\",\n    \"lat\": 3.1073,\n    \"lng\": 101.5917\n  },\n  \"orders\": [\n    {\n      \"externalOrderId\": \"SO-DEMO-3001\",\n      \"customerName\": \"Beta Retail Group\",\n      \"address\": \"2 Jalan Stesen Sentral\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"50470\",\n      \"lat\": 3.1345,\n      \"lng\": 101.6869,\n      \"serviceTimeMinutes\": 15,\n      \"weightKg\": 55,\n      \"volumeM3\": 0.5,\n      \"picName\": \"Kumar\",\n      \"picPhone\": \"+60176668899\",\n      \"timeWindowStart\": \"08:00\",\n      \"timeWindowEnd\": \"18:00\"\n    },\n    {\n      \"externalOrderId\": \"SO-DEMO-3002\",\n      \"customerName\": \"Zeta Warehouse\",\n      \"address\": \"3 Jalan Klang Lama\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"58000\",\n      \"lat\": 3.0985,\n      \"lng\": 101.6752,\n      \"serviceTimeMinutes\": 25,\n      \"weightKg\": 350,\n      \"volumeM3\": 3.5,\n      \"picName\": \"Ravi\",\n      \"picPhone\": \"+60195556677\",\n      \"timeWindowStart\": \"09:00\",\n      \"timeWindowEnd\": \"15:00\"\n    },\n    {\n      \"externalOrderId\": \"SO-DEMO-3003\",\n      \"customerName\": \"Eta Cafe Supply\",\n      \"address\": \"15 Jalan Pudu\",\n      \"city\": \"Kuala Lumpur\",\n      \"state\": \"Wilayah Persekutuan\",\n      \"pincode\": \"55100\",\n      \"lat\": 3.1402,\n      \"lng\": 101.7089,\n      \"serviceTimeMinutes\": 10,\n      \"weightKg\": 22,\n      \"volumeM3\": 0.2,\n      \"picName\": \"Mei Ling\",\n      \"picPhone\": \"+60134445566\",\n      \"timeWindowStart\": \"11:00\",\n      \"timeWindowEnd\": \"13:00\"\n    }\n  ]\n}",
          "options": { "raw": { "language": "json" } }
        },
        "url": "{{baseUrl}}/rest/route-planning/webhook/orders",
        "description": "Same as `depot` but uses the `pickupLocation` field name (alias). Booking pickup address is taken from this object."
      },
      "response": []
    }
  ]
}
