{
  "info": {
    "name": "Almighty Dispatch Partner API v1.2",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "description": "Set the collection variable apiKey to the key your operator gave you (a tdk_test_ key is a sandbox: nothing real is created). Run Quote first to get a vehicleClassId, then Create booking."
  },
  "auth": {
    "type": "apikey",
    "apikey": [
      {
        "key": "key",
        "value": "x-api-key",
        "type": "string"
      },
      {
        "key": "value",
        "value": "{{apiKey}}",
        "type": "string"
      },
      {
        "key": "in",
        "value": "header",
        "type": "string"
      }
    ]
  },
  "variable": [
    {
      "key": "baseUrl",
      "value": "https://www.almightydispatch.com/api/v1"
    },
    {
      "key": "apiKey",
      "value": "PASTE_YOUR_KEY_HERE"
    },
    {
      "key": "vehicleClassId",
      "value": ""
    },
    {
      "key": "externalRef",
      "value": "TEST-1"
    },
    {
      "key": "ref",
      "value": ""
    }
  ],
  "item": [
    {
      "name": "Quote a fare (all vehicle classes)",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.fares && j.fares.length) pm.collectionVariables.set('vehicleClassId', j.fares[0].vehicleClassId);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/fare",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"pickup\": \"10 Station Road, Hornchurch RM12 6AA\",\n  \"dropoff\": \"Heathrow Airport Terminal 5, TW6 2GA\",\n  \"distance\": 32.4,\n  \"date\": \"2026-11-02\",\n  \"time\": \"06:30\"\n}"
        }
      }
    },
    {
      "name": "Create booking",
      "event": [
        {
          "listen": "test",
          "script": {
            "type": "text/javascript",
            "exec": [
              "const j = pm.response.json();",
              "if (j.bookings && j.bookings.length) pm.collectionVariables.set('ref', j.bookings[0].ref);"
            ]
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/bookings",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"customer\": { \"name\": \"API Test\", \"phone\": \"+447700900999\" },\n  \"booking\": {\n    \"pickup\": \"10 Station Road, Hornchurch RM12 6AA\",\n    \"dropoff\": \"Heathrow Airport Terminal 5, TW6 2GA\",\n    \"pickupLat\": 51.5545, \"pickupLng\": 0.2209,\n    \"dropoffLat\": 51.4700, \"dropoffLng\": -0.4543,\n    \"distance\": 32.4,\n    \"date\": \"2026-11-02\",\n    \"time\": \"06:30\",\n    \"vehicleClassId\": \"{{vehicleClassId}}\",\n    \"externalRef\": \"{{externalRef}}\"\n  }\n}"
        }
      }
    },
    {
      "name": "Check booking by ref",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/bookings?ref={{ref}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "bookings"
          ],
          "query": [
            {
              "key": "ref",
              "value": "{{ref}}"
            }
          ]
        }
      }
    },
    {
      "name": "Check booking by externalRef",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/bookings?externalRef={{externalRef}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "bookings"
          ],
          "query": [
            {
              "key": "externalRef",
              "value": "{{externalRef}}"
            }
          ]
        }
      }
    },
    {
      "name": "Request a change (amend)",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/requests",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"type\": \"amend\",\n  \"externalRef\": \"{{externalRef}}\",\n  \"reason\": \"Flight delayed\",\n  \"changes\": { \"time\": \"10:30\" }\n}"
        }
      }
    },
    {
      "name": "Request a cancel",
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json"
          }
        ],
        "url": "{{baseUrl}}/requests",
        "body": {
          "mode": "raw",
          "raw": "{\n  \"type\": \"cancel\",\n  \"externalRef\": \"{{externalRef}}\",\n  \"reason\": \"Passenger no longer travelling\"\n}"
        }
      }
    },
    {
      "name": "Check requests for a booking",
      "request": {
        "method": "GET",
        "url": {
          "raw": "{{baseUrl}}/requests?ref={{ref}}",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "requests"
          ],
          "query": [
            {
              "key": "ref",
              "value": "{{ref}}"
            }
          ]
        }
      }
    }
  ]
}