{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.freightutils.com/schema/consignment-object.v1.json",
  "title": "FreightUtils consignment object v1",
  "description": "One typed description of a load that every FreightUtils check can read (consignment-object.v1): lines[] (what is carried), journey, vehicle and options. Only lines[] is required. Accepted as the `consignment` argument of consignment_calculator, shipment_summary and adr_exemption_calculator (REST and MCP), and validated by validate (type: consignment). A check that needs a field the object lacks answers MISSING_INPUT and names it in missing_inputs. Parties are not part of v1. Not the consignment calculator's own request contract, which is /schema/consignment.v1.json.",
  "type": "object",
  "properties": {
    "lines": {
      "minItems": 1,
      "maxItems": 50,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "description": {
            "description": "What the line is, at most 200 characters.",
            "type": "string",
            "maxLength": 200
          },
          "un_number": {
            "description": "UN number of a dangerous-goods line.",
            "type": "string",
            "pattern": "^(?:UN\\s?)?\\d{4}$"
          },
          "packing_group": {
            "description": "Packing group, to pin one ADR Table A row of a multi-row UN.",
            "type": "string",
            "enum": [
              "I",
              "II",
              "III"
            ]
          },
          "variant_index": {
            "description": "ADR Table A variant index (as adr_lookup returns it), to pin one row.",
            "type": "integer",
            "minimum": 0,
            "maximum": 1000
          },
          "quantity": {
            "description": "The dangerous-goods quantity (ADR 1.1.3.6.3), separate from the gross mass of the packages.",
            "type": "object",
            "properties": {
              "value": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000000000,
                "description": "The dangerous-goods quantity for the whole line, all packages together."
              },
              "unit": {
                "description": "\"L\" or \"kg\" — checked against the dimension ADR 1.1.3.6.3 counts for the row.",
                "type": "string",
                "enum": [
                  "L",
                  "kg"
                ]
              },
              "basis": {
                "description": "\"net\" (the goods) or \"gross\" (with packaging). 1.1.3.6.3 counts net; a gross figure scores no points.",
                "type": "string",
                "enum": [
                  "net",
                  "gross"
                ]
              }
            },
            "required": [
              "value"
            ],
            "additionalProperties": false
          },
          "packages": {
            "description": "The pieces: how many, of what type, and their total gross mass.",
            "type": "object",
            "properties": {
              "count": {
                "type": "integer",
                "exclusiveMinimum": 0,
                "maximum": 100000,
                "description": "Number of identical packages (pieces) on the line."
              },
              "type": {
                "description": "Package type, e.g. \"pallet\", \"drum\", \"carton\".",
                "type": "string",
                "maxLength": 40
              },
              "gross_kg": {
                "description": "Gross mass of ALL the line's packages together, in kg.",
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 1000000
              }
            },
            "required": [
              "count"
            ],
            "additionalProperties": false
          },
          "hs_code": {
            "description": "HS / tariff commodity code, 6–10 digits.",
            "type": "string",
            "pattern": "^\\d{6,10}$"
          },
          "value": {
            "description": "Customs value of the whole line (all packages together).",
            "type": "object",
            "properties": {
              "amount": {
                "type": "number",
                "minimum": 0,
                "maximum": 1000000000000,
                "description": "The amount, 0 or more."
              },
              "currency": {
                "type": "string",
                "pattern": "^[A-Z]{3}$",
                "description": "ISO 4217 currency code, e.g. \"GBP\"."
              }
            },
            "required": [
              "amount",
              "currency"
            ],
            "additionalProperties": false
          },
          "dims": {
            "description": "Dimensions of ONE package: { l, w, h, unit: mm | cm | m | in }.",
            "type": "object",
            "properties": {
              "l": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 100000
              },
              "w": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 100000
              },
              "h": {
                "type": "number",
                "exclusiveMinimum": 0,
                "maximum": 100000
              },
              "unit": {
                "type": "string",
                "enum": [
                  "mm",
                  "cm",
                  "m",
                  "in"
                ]
              }
            },
            "required": [
              "l",
              "w",
              "h",
              "unit"
            ],
            "additionalProperties": false
          },
          "stackable": {
            "description": "Whether the packages may be stacked.",
            "type": "boolean"
          }
        },
        "additionalProperties": false
      },
      "description": "The lines of the load. Required."
    },
    "journey": {
      "type": "object",
      "properties": {
        "origin": {
          "description": "UN/LOCODE or ISO country code of the origin.",
          "type": "string",
          "pattern": "^[A-Za-z]{2}(?:\\s?[A-Za-z2-9]{3})?$"
        },
        "destination": {
          "description": "UN/LOCODE or ISO country code of the destination.",
          "type": "string",
          "pattern": "^[A-Za-z]{2}(?:\\s?[A-Za-z2-9]{3})?$"
        },
        "date": {
          "description": "Date of carriage, YYYY-MM-DD.",
          "type": "string",
          "pattern": "^\\d{4}-\\d{2}-\\d{2}$"
        },
        "tunnels_on_route": {
          "description": "ADR tunnel categories on the route (A–E).",
          "maxItems": 20,
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "A",
              "B",
              "C",
              "D",
              "E"
            ]
          }
        },
        "mode": {
          "description": "road | air | sea | multimodal.",
          "type": "string",
          "enum": [
            "road",
            "air",
            "sea",
            "multimodal"
          ]
        }
      },
      "additionalProperties": false
    },
    "vehicle": {
      "type": "object",
      "properties": {
        "type": {
          "description": "Vehicle type, e.g. \"artic\", \"rigid 7.5 t\".",
          "type": "string",
          "maxLength": 60
        },
        "max_mass_t": {
          "description": "Maximum permissible mass, tonnes.",
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 100
        },
        "axles": {
          "type": "integer",
          "minimum": 1,
          "maximum": 12
        }
      },
      "additionalProperties": false
    },
    "options": {
      "type": "object",
      "properties": {
        "air_volumetric_divisor": {
          "description": "IATA volumetric divisor, cm³/kg (default 6000).",
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 10000
        },
        "container_number": {
          "description": "ISO 6346 container number (check digit validated, advisory).",
          "type": "string",
          "maxLength": 20
        },
        "awb_number": {
          "description": "IATA air waybill number (check digit validated, advisory).",
          "type": "string",
          "maxLength": 20
        },
        "incoterm": {
          "description": "Incoterms 2020 rule.",
          "type": "string",
          "enum": [
            "EXW",
            "FCA",
            "FAS",
            "FOB",
            "CFR",
            "CIF",
            "CPT",
            "CIP",
            "DAP",
            "DPU",
            "DDP"
          ]
        },
        "freight_cost": {
          "description": "Freight cost for the customs value.",
          "type": "object",
          "properties": {
            "amount": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "The amount, 0 or more."
            },
            "currency": {
              "type": "string",
              "pattern": "^[A-Z]{3}$",
              "description": "ISO 4217 currency code, e.g. \"GBP\"."
            }
          },
          "required": [
            "amount",
            "currency"
          ],
          "additionalProperties": false
        },
        "insurance_cost": {
          "description": "Insurance cost for the customs value.",
          "type": "object",
          "properties": {
            "amount": {
              "type": "number",
              "minimum": 0,
              "maximum": 1000000000000,
              "description": "The amount, 0 or more."
            },
            "currency": {
              "type": "string",
              "pattern": "^[A-Z]{3}$",
              "description": "ISO 4217 currency code, e.g. \"GBP\"."
            }
          },
          "required": [
            "amount",
            "currency"
          ],
          "additionalProperties": false
        }
      },
      "additionalProperties": false
    }
  },
  "required": [
    "lines"
  ],
  "additionalProperties": false
}
