{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/purolator/main/json-schema/purolator-online-tracking-response-schema.json",
  "title": "OnlineTrackingResponse",
  "x-generated": "2026-10-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/purolator-tracking-openapi.yml#/components/schemas/OnlineTrackingResponse",
  "type": "object",
  "properties": {
    "searchResult": {
      "type": "array",
      "description": "Array of all the search requests",
      "items": {
        "$ref": "#/$defs/SearchResult"
      }
    },
    "errors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/CodeSubCodeDesc"
      }
    }
  },
  "$defs": {
    "CodeDesc": {
      "type": "object",
      "required": [
        "code",
        "description"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "Shipment status code"
        },
        "description": {
          "type": "string",
          "description": "Shipment status description"
        }
      }
    },
    "CodeSubCodeDesc": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Shipment status code"
        },
        "description": {
          "type": "string",
          "description": "Shipment status description"
        }
      }
    },
    "DeliveryDetails": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the person who actually recieved the package"
        },
        "deliveryDateTime": {
          "type": "string",
          "format": "date-time",
          "description": "Delivery date of the package"
        },
        "image": {
          "type": "string",
          "description": "Proof of delivery image (Signature or Scanner Photo)"
        },
        "locationCode": {
          "type": "string",
          "description": "Package delivery location code"
        },
        "locationDescription": {
          "type": "string",
          "description": "Package delivery location"
        }
      },
      "description": "package delivery details"
    },
    "Event": {
      "type": "object",
      "properties": {
        "dateTime": {
          "type": "string",
          "format": "date-time",
          "description": "Local Timestamp associated with the current scan"
        },
        "code": {
          "type": "string",
          "description": "Scan code associated with the event"
        },
        "reasonCode": {
          "type": "string",
          "description": "Scan reason code associated with the event"
        },
        "description": {
          "type": "string",
          "description": "Description of the event"
        },
        "terminal": {
          "type": "string",
          "description": "Local terminal from scan"
        },
        "routeId": {
          "type": "string",
          "description": "Local route from scan"
        },
        "location": {
          "$ref": "#/$defs/Location"
        },
        "x12": {
          "$ref": "#/$defs/ExternalEvent"
        },
        "xreference": {
          "type": "string",
          "description": "The new pin for an overlable shipment"
        }
      },
      "description": "Array of scan events"
    },
    "ExternalEvent": {
      "type": "object",
      "properties": {
        "AT701": {
          "type": "string"
        },
        "AT702": {
          "type": "string"
        }
      }
    },
    "Location": {
      "type": "object",
      "properties": {
        "streetaddress1": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "streetaddress2": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "city": {
          "type": "string",
          "description": "city name associated with the event"
        },
        "provinceState": {
          "type": "string",
          "description": "Province name associated with the event"
        },
        "postalCode": {
          "type": "string"
        },
        "countryCode": {
          "type": "string",
          "description": "country name associated with the event"
        }
      },
      "description": "Event location details"
    },
    "NameValue": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "Service Name"
        },
        "value": {
          "type": "string",
          "description": "Service Value"
        },
        "description": {
          "type": "string",
          "description": "Service Description"
        }
      }
    },
    "Package": {
      "type": "object",
      "required": [
        "pin"
      ],
      "properties": {
        "id": {
          "type": "integer",
          "description": "The array index value",
          "format": "int32"
        },
        "pin": {
          "type": "string",
          "description": "Package Pin"
        },
        "status": {
          "$ref": "#/$defs/packageCodeSubCodeDesc"
        },
        "estimatedDeliveryDate": {
          "type": "string",
          "format": "date",
          "description": "estimated delivery date of the package"
        },
        "transitDays": {
          "type": "integer",
          "format": "int32",
          "description": "Number of days it has been in transit"
        },
        "packageCreated": {
          "type": "string",
          "format": "date",
          "description": "Revised shipment date from piece state"
        },
        "packageReceived": {
          "type": "string",
          "format": "date-time",
          "description": "The date that the shipment was inducted"
        },
        "lastEvent": {
          "$ref": "#/$defs/Event"
        },
        "details": {
          "$ref": "#/$defs/PackageDetails"
        },
        "events": {
          "type": "array",
          "description": "Array of scan events",
          "items": {
            "$ref": "#/$defs/Event"
          }
        }
      }
    },
    "PackageDetails": {
      "type": "object",
      "properties": {
        "references": {
          "type": "array",
          "description": "Array of all references",
          "items": {
            "type": "string",
            "description": "Tracking Reference defined when creating the package"
          }
        },
        "services": {
          "type": "array",
          "description": "Array of package service details",
          "items": {
            "$ref": "#/$defs/NameValue"
          }
        },
        "weight": {
          "$ref": "#/$defs/PackageWeight"
        },
        "holdForPickupLocationId": {
          "type": "string",
          "description": "Hold for pickup location id"
        },
        "deliveryDetails": {
          "$ref": "#/$defs/DeliveryDetails"
        }
      },
      "description": "Array of the package services used"
    },
    "PackageWeight": {
      "type": "object",
      "properties": {
        "declaredUnit": {
          "type": "string",
          "description": "Unit of the declared package weight"
        },
        "declaredValue": {
          "type": "number",
          "description": "Declared package weight",
          "format": "double"
        },
        "actualUnit": {
          "type": "string",
          "description": "Unit of the package weight"
        },
        "actualValue": {
          "type": "number",
          "description": "Actual package weight",
          "format": "double"
        }
      },
      "description": "Shipment weight details"
    },
    "Receiver": {
      "type": "object",
      "properties": {
        "streetAddress1": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "streetAddress2": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "streetAddress3": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "city": {
          "type": "string",
          "description": "Destination city"
        },
        "provinceState": {
          "type": "string",
          "description": "Destination province"
        },
        "countryCode": {
          "type": "string",
          "description": "Destination countryCode"
        },
        "postalzipcode": {
          "type": "string",
          "description": "Origin shipper address"
        }
      },
      "description": "Object containing all reciever details"
    },
    "SearchResult": {
      "type": "object",
      "required": [
        "pin"
      ],
      "properties": {
        "pin": {
          "type": "object",
          "required": [
            "trackingId"
          ],
          "properties": {
            "trackingId": {
              "type": "string",
              "description": "The pin or reference that was searched"
            },
            "shipmentDateFrom": {
              "type": "string",
              "description": "Date provided for duplicate pins"
            },
            "shipmentDateTo": {
              "type": "string",
              "description": "Date provided for duplicate pins"
            },
            "status": {
              "type": "string",
              "description": "Status of the search (Found/Not Found/Error/Overflow/etc...)"
            },
            "type": {
              "type": "string",
              "description": "What type of data was the search value (PIN or Reference)",
              "format": "int32"
            },
            "errors": {
              "type": "array",
              "items": {
                "$ref": "#/$defs/CodeSubCodeDesc"
              }
            },
            "shipment": {
              "$ref": "#/$defs/Shipment"
            }
          }
        }
      },
      "description": "Search result for a single tracking query"
    },
    "Shipment": {
      "type": "object",
      "required": [
        "shipmentPin"
      ],
      "properties": {
        "shipmentPin": {
          "type": "string",
          "description": "Lead pin"
        },
        "status": {
          "$ref": "#/$defs/CodeDesc"
        },
        "shipmentCreated": {
          "type": "string",
          "description": "Shipment date",
          "format": "date"
        },
        "pieceTotalCount": {
          "type": "integer",
          "description": "Total number of the pieces in the shipment",
          "format": "int32"
        },
        "details": {
          "$ref": "#/$defs/ShipmentDetails"
        },
        "package": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Package"
          },
          "description": "An array of all packages within the shipment"
        }
      },
      "description": "Array of all unique shipments found in the requested searches"
    },
    "ShipmentDetails": {
      "type": "object",
      "properties": {
        "references": {
          "type": "array",
          "description": "Array of all references",
          "items": {
            "type": "string",
            "description": "Array of all references"
          }
        },
        "returnShipment": {
          "type": "boolean",
          "description": "Flag to identify a return shipment"
        },
        "product": {
          "$ref": "#/$defs/CodeDesc"
        },
        "services": {
          "type": "array",
          "description": "Array of package service details",
          "items": {
            "$ref": "#/$defs/NameValue"
          }
        },
        "shipper": {
          "$ref": "#/$defs/Shipper"
        },
        "receiver": {
          "$ref": "#/$defs/Receiver"
        },
        "note": {
          "type": "string"
        },
        "weight": {
          "$ref": "#/$defs/ShipmentWeight"
        }
      },
      "description": "The shipment details object tied to the shipmentDetails API option"
    },
    "ShipmentWeight": {
      "type": "object",
      "properties": {
        "unit": {
          "type": "string",
          "description": "Unit of the shipment weight"
        },
        "value": {
          "type": "number",
          "description": "Actual weight of the shipment",
          "format": "double"
        }
      },
      "description": "Shipment weight details"
    },
    "Shipper": {
      "type": "object",
      "properties": {
        "streetAddress1": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "streetAddress2": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "streetAddress3": {
          "type": "string",
          "description": "Address of the scan location"
        },
        "city": {
          "type": "string",
          "description": "Origin city"
        },
        "provinceState": {
          "type": "string",
          "description": "Origin province / state"
        },
        "countryCode": {
          "type": "string",
          "description": "Origin country code"
        },
        "postalzipcode": {
          "type": "string",
          "description": "Origin shipper address"
        }
      },
      "description": "Object containing all shipper details"
    },
    "packageCodeSubCodeDesc": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Shipment status code"
        },
        "description": {
          "type": "string",
          "description": "Shipment status description"
        },
        "subCode": {
          "type": "string",
          "description": "status subcode"
        },
        "subDescription": {
          "type": "string",
          "description": "status subdescription"
        }
      }
    }
  }
}