{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/purolator/main/json-schema/purolator-create-shipment-response-schema.json",
  "title": "CreateShipmentResponse",
  "x-generated": "2026-10-13",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/purolator-create-void-shipment-openapi.yml#/components/schemas/CreateShipmentResponse",
  "type": "object",
  "properties": {
    "requestReference": {
      "$ref": "#/$defs/RequestReference"
    },
    "validShipment": {
      "type": "boolean"
    },
    "bannerMessages": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "shipmentDetails": {
      "$ref": "#/$defs/ShipmentDetails"
    },
    "shipmentDocuments": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ShipmentDocumentGroup"
      },
      "description": "Omitted when the response would exceed API Gateway size limits."
    },
    "outboundShipmentEstimates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ShipmentEstimateWrapper"
      },
      "description": "Present when returnRates is true, or when the outbound account sales district is 930."
    },
    "returnShipmentEstimates": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ShipmentEstimateWrapper"
      },
      "description": "Present when returnRates is true, or when the return account sales district is 930."
    },
    "errors": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/ErrorItem"
      }
    }
  },
  "$defs": {
    "DocumentEntry": {
      "type": "object",
      "properties": {
        "packagePIN": {
          "type": "string",
          "description": "Included only for CODE128 document entries."
        },
        "documentType": {
          "type": "string",
          "enum": [
            "CustomsInvoice",
            "CustomsInvoiceThermal",
            "DangerousGoodsDeclaration",
            "DomesticBillOfLading",
            "DomesticBillOfLadingThermal",
            "ExpressChequeReceipt",
            "ExpressChequeReceiptThermal",
            "FDA2877",
            "InternationalBillOfLading",
            "InternationalBillOfLadingThermal",
            "QRCode",
            "USMCA"
          ]
        },
        "description": {
          "type": "string"
        },
        "documentStatus": {
          "type": "string"
        },
        "url": {
          "type": "string",
          "format": "uri"
        },
        "data": {
          "type": "string",
          "description": "Base64 document content when responseType is BASE64."
        },
        "code128Value": {
          "type": "string"
        }
      }
    },
    "Error": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string",
          "description": "Error code"
        },
        "description": {
          "type": "string",
          "description": "Detailed error description in the requested language."
        }
      }
    },
    "ErrorItem": {
      "type": "object",
      "required": [
        "error"
      ],
      "properties": {
        "error": {
          "$ref": "#/$defs/Error"
        }
      }
    },
    "LineOfBusiness": {
      "type": "string",
      "enum": [
        "Courier",
        "Freight"
      ],
      "description": "Line of business. Case-insensitive. Only Courier is supported."
    },
    "OptionPrice": {
      "type": "object",
      "properties": {
        "option": {
          "type": "object",
          "properties": {
            "amount": {
              "type": "number",
              "format": "double"
            },
            "id": {
              "type": "string"
            },
            "description": {
              "type": "string"
            }
          }
        }
      }
    },
    "RequestReference": {
      "type": "string",
      "maxLength": 36,
      "description": "A unique identifier for the request. Can be used to match request with the response. If not provided, a random UUID is generated."
    },
    "ShipmentDate": {
      "type": "string",
      "format": "date",
      "description": "Date of shipment. Up to 10 days in advance. Date format: YYYY-MM-DD. If not present, defaults to today's date (America/Toronto)."
    },
    "ShipmentDetails": {
      "type": "object",
      "properties": {
        "shipmentPIN": {
          "type": "string"
        },
        "packagePINs": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "returnShipmentPIN": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Present for outbound+return when returnsManagement is false."
        },
        "expressChequePIN": {
          "type": "string"
        },
        "internationalOrderNumber": {
          "type": "string",
          "description": "International order number returned for ICP shipments when brokerage provider is not No Broker/Other."
        },
        "brokeragePackageNumbers": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "Brokerage package numbers returned for ICP shipments when brokerage provider is not No Broker/Other."
        }
      }
    },
    "ShipmentDocumentGroup": {
      "type": "object",
      "properties": {
        "shipmentPIN": {
          "type": "string"
        },
        "documents": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentEntry"
          }
        }
      }
    },
    "ShipmentEstimate": {
      "type": "object",
      "properties": {
        "lineOfBusiness": {
          "$ref": "#/$defs/LineOfBusiness"
        },
        "serviceId": {
          "type": "string"
        },
        "unitOfMeasurement": {
          "type": "string",
          "enum": [
            "METRIC",
            "IMPERIAL"
          ]
        },
        "shipmentDate": {
          "$ref": "#/$defs/ShipmentDate"
        },
        "expectedDeliveryDate": {
          "type": "string",
          "format": "date"
        },
        "estimatedTransitDays": {
          "type": "integer"
        },
        "basePrice": {
          "type": "number",
          "format": "double"
        },
        "surcharges": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Surcharge"
          }
        },
        "optionPrices": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/OptionPrice"
          }
        },
        "subTotal": {
          "type": "number",
          "format": "double"
        },
        "taxes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/Tax"
          }
        },
        "totalPrice": {
          "type": "number",
          "format": "double"
        }
      }
    },
    "ShipmentEstimateWrapper": {
      "type": "object",
      "properties": {
        "shipmentEstimate": {
          "$ref": "#/$defs/ShipmentEstimate"
        }
      }
    },
    "Surcharge": {
      "type": "object",
      "properties": {
        "surcharge": {
          "type": "object",
          "properties": {
            "amount": {
              "type": "number",
              "format": "double"
            },
            "type": {
              "type": "string"
            },
            "description": {
              "type": "string"
            }
          }
        }
      }
    },
    "Tax": {
      "type": "object",
      "properties": {
        "tax": {
          "type": "object",
          "properties": {
            "amount": {
              "type": "number",
              "format": "double"
            },
            "type": {
              "type": "string"
            },
            "description": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}