{
   "$schema": "https://json-schema.org/draft/2020-12/schema",
   "$id": "https://api.thebigalice.com/schema/customs/simple_shipment/v1/schema.json",
   "$defs": {
      "iso31661_alpha_2": {
         "type": "string",
         "description": "The country code must be represented in *ISO 3166-1 alpha-2*.",
         "maxLength": 2,
         "examples": [
            "IT"
         ]
      },
      "person_or_company": {
         "type": "object",
         "description": "Person or Company",
         "additionalProperties": false,
         "required": [
            "name",
            "address",
            "city",
            "postal_code",
            "country"
         ],
         "examples": [
            {
               "eori": "IT00852040112",
               "name": "Laghezza S.p.A.",
               "address": "Via San Bartolomeo, 103",
               "city": "La Spezia",
               "postal_code": "19125",
               "province": "SP",
               "country": "IT"
            }
         ],
         "properties": {
            "eori": {
               "type": "string",
               "maxLength": 18,
               "title": "Only EU, The EORI of the person or the company.",
               "examples": [
                  "IT00852040112"
               ]
            },
            "name": {
               "type": "string",
               "maxLength": 45,
               "title": "The name of the person or the company.",
               "examples": [
                  "Laghezza S.p.A."
               ]
            },
            "address": {
               "type": "string",
               "maxLength": 45,
               "title": "The address of the person or the company.",
               "examples": [
                  "Via San Bartolomeo, 103"
               ]
            },
            "city": {
               "type": "string",
               "maxLength": 45,
               "title": "The city of the person or the company.",
               "examples": [
                  "La Spezia"
               ]
            },
            "postal_code": {
               "type": "string",
               "maxLength": 9,
               "title": "The postal code of the person or the company.",
               "examples": [
                  "19125"
               ]
            },
            "province": {
               "type": "string",
               "maxLength": 2,
               "title": "The province of the person or the company.",
               "examples": [
                  "SP"
               ]
            },
            "country": {
               "type": "string",
               "title": "The country code of the person or the company."
            }
         }
      },
      "amount": {
         "type": "object",
         "description": "Amount with currency",
         "additionalProperties": false,
         "required": [
            "amount",
            "currency"
         ],
         "examples": [
            {
               "amount": 11.20,
               "currency": "USD"
            }
         ],
         "properties": {
            "amount": {
               "type": "number",
               "minimum": 0,
               "required": true,
               "title": "The amount.",
               "examples": [
                  11.20
               ]
            },
            "currency": {
               "type": "string",
               "maxLength": 3,
               "required": true,
               "title": "The currency of amount.",
               "examples": [
                  "USD"
               ]
            }
         }
      }
   },
   "type": "object",
   "title": "Simple Shipment",
   "description": "Simple representation of shipment for customs purposes.",
   "additionalProperties": false,
   "required": [
      "schema_id",
      "customer_shipment_reference",
      "shipment_date",
      "consignee",
      "consignor",
      "total_packages_number",
      "total_gross_mass_in_kg",
      "total_net_mass_in_kg",
      "items"
   ],
   "examples": [
      {
         "schema_id": "https://api.thebigalice.com/schema/customs/simple_shipment/v1/schema.json",
         "shipment_date": "2023-03-01",
         "customer_shipment_reference": "2023/121/A",
         "customer_department_code": "001",
         "customer_branch_code": "SP",
         "consignee": {
            "eori": "IT00852040112",
            "name": "Laghezza S.p.A.",
            "address": "Via San Bartolomeo, 103",
            "city": "La Spezia",
            "postal_code": "19125",
            "province": "SP",
            "country": "IT"
         },
         "consignor": {
            "eori": "IT00852040112",
            "name": "Laghezza S.p.A.",
            "address": "Via San Bartolomeo, 103",
            "city": "La Spezia",
            "postal_code": "19125",
            "province": "SP",
            "country": "IT"
         },
         "dispatch_country": "IT",
         "destination_country": "IT",
         "delivery_terms": "FCA",
         "means_of_transport_country": "IT",
         "means_of_transport_identity": "EE111FF",
         "total_packages_number": 20,
         "total_gross_mass_in_kg": 12.300,
         "total_net_mass_in_kg": 10.000,
         "items": [
            {
               "goods_description": "Plug Valves for pipes",
               "goods_customs_heading": "84818081",
               "packages_type": "CT",
               "packages_number": 10.0,
               "gross_mass_in_kg": 2.300,
               "net_mass_in_kg": 2.000,
               "goods_amount": {
                  "currency": "EUR",
                  "amount": 12.10
               },
               "freight_extra_ue_amount": {
                  "currency": "EUR",
                  "amount": 1.00
               },
               "freight_ue_amount": {
                  "currency": "EUR",
                  "amount": 1.00
               },
               "freight_local_amount": {
                  "currency": "EUR",
                  "amount": 1.00
               },
               "origin_country": "IT",
               "marks_and_numbers": "SN123456"
            },
            {
               "goods_description": "Butterfly Valve",
               "goods_customs_heading": "84818087",
               "packages_type": "CT",
               "packages_number": 10.0,
               "gross_mass_in_kg": 10.000,
               "net_mass_in_kg": 8.000,
               "goods_amount": {
                  "currency": "EUR",
                  "amount": 12.10
               },
               "freight_extra_ue_amount": {
                  "currency": "EUR",
                  "amount": 1.00
               },
               "freight_ue_amount": {
                  "currency": "EUR",
                  "amount": 1.00
               },
               "freight_local_amount": {
                  "currency": "EUR",
                  "amount": 1.00
               },
               "origin_country": "IT",
               "marks_and_numbers": "SN443212"
            }
         ],
         "containers": [
            "MSCU1234567",
            "MSCU9876543"
         ]
      }
   ],
   "properties": {
      "schema_id": {
         "type": "string",
         "title": "The Id of the JSON schema",
         "examples": [
            "https://api.thebigalice.com/schema/customs/simple_shipment/v1/schema.json"
         ]
      },
      "shipment_date": {
         "type": "string",
         "format": "date",
         "title": "The shipment date",
         "examples": [
            "1970-01-01"
         ]
      },
      "customer_shipment_reference": {
         "type": "string",
         "maxLength": 13,
         "title": "The customer reference of the shipment.",
         "examples": [
            "121212/A"
         ]
      },
      "customer_department_code": {
         "type": "string",
         "maxLength": 3,
         "title": "The customer department code.",
         "examples": [
            "001"
         ]
      },
      "customer_branch_code": {
         "type": "string",
         "maxLength": 3,
         "title": "The customer branch code.",
         "examples": [
            "SP"
         ]
      },
      "consignee": {
         "title": "The consignee.",
         "description": "Refer to *Box 8* of *Commission Delegated Regulation (EU) 2016/341*.",
         "$ref": "#/$defs/person_or_company"
      },
      "consignor": {
         "title": "The consignor/exporter.",
         "description": "Refer to *Box 2* of *Commission Delegated Regulation (EU) 2016/341*.",
         "$ref": "#/$defs/person_or_company"
      },
      "dispatch_country": {
         "$ref": "#/$defs/iso31661_alpha_2",
         "title": "The country of dispatch/export.",
         "description": "Refer to *Box 15* of *Commission Delegated Regulation (EU) 2016/341*."
      },
      "destination_country": {
         "title": "The country code of destination.",
         "$ref": "#/$defs/iso31661_alpha_2",
         "description": "Refer to *Box 17* of *Commission Delegated Regulation (EU) 2016/341*."
      },
      "delivery_terms": {
         "type": "string",
         "maxLength": 3,
         "title": "The delivery terms.",
         "description": "Refer to *Box 20* of *Commission Delegated Regulation (EU) 2016/341*.",
         "examples": [
            "FCA"
         ]
      },
      "means_of_transport_country": {
         "title": "The country code of transport means.",
         "$ref": "#/$defs/iso31661_alpha_2",
         "description": "Refer to *Box 18/21* of *Commission Delegated Regulation (EU) 2016/341*."
      },
      "means_of_transport_identity": {
         "type": "string",
         "maxLength": 27,
         "title": "The identity of transport means.",
         "description": "Refer to *Box 18/21* of *Commission Delegated Regulation (EU) 2016/341*.",
         "examples": [
            "EE111FF",
            "MSC ALLEGRA"
         ]
      },
      "total_packages_number": {
         "type": "integer",
         "minimum": 0,
         "title": "The total number of packages.",
         "description": "Refer to *Box 6* of *Commission Delegated Regulation (EU) 2016/341*.",
         "examples": [
            20
         ]
      },
      "total_gross_mass_in_kg": {
         "type": "number",
         "minimum": 0,
         "title": "The total gross mass in kilograms.",
         "description": "Refer to *Box 35* of *Commission Delegated Regulation (EU) 2016/341*.",
         "examples": [
            12.300
         ]
      },
      "total_net_mass_in_kg": {
         "type": "number",
         "minimum": 0,
         "title": "The total net mass in kilograms.",
         "description": "Refer to *Box 38* of *Commission Delegated Regulation (EU) 2016/341*.",
         "examples": [
            10.000
         ]
      },
      "items": {
         "type": "array",
         "title": "List of shipment item.",
         "items": {
            "type": "object",
            "title": "Shipment item",
            "minItems": 1,
            "additionalProperties": false,
               "required": [
                  "goods_description",
                  "packages_type",
                  "packages_number",
                  "gross_mass_in_kg",
                  "net_mass_in_kg"
               ],
            "examples": [
               {
                  "goods_description": "Plug Valves for pipes",
                  "goods_customs_heading": "84818081",
                  "packages_type": "CT",
                  "packages_number": 10.0,
                  "gross_mass_in_kg": 2.300,
                  "net_mass_in_kg": 2.000,
                  "goods_amount": {
                     "currency": "EUR",
                     "amount": 12.10
                  },
                  "freight_extra_ue_amount": {
                     "currency": "EUR",
                     "amount": 1.00
                  },
                  "freight_ue_amount": {
                     "currency": "EUR",
                     "amount": 1.00
                  },
                  "freight_local_amount": {
                     "currency": "EUR",
                     "amount": 1.00
                  },
                  "origin_country": "IT",
                  "marks_and_numbers": "SN123456"
               }
            ],
            "properties": {
               "packages_type": {
                  "type": "string",
                  "maxLength": 3,
                  "title": "The type of packages.",
                  "description": "Refer to *Box 31* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     "CT"
                  ]
               },
               "packages_number": {
                  "type": "integer",
                  "minimum": 0,
                  "title": "The number of packages.",
                  "description": "Refer to *Box 31* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     10
                  ]
               },
               "gross_mass_in_kg": {
                  "type": "number",
                  "minimum": 0,
                  "title": "The gross mass in kilograms.",
                  "description": "Refer to *Box 35* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     2.000
                  ]
               },
               "net_mass_in_kg": {
                  "type": "number",
                  "minimum": 0,
                  "title": "The net mass in kilograms.",
                  "description": "Refer to *Box 38* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     2.300
                  ]
               },
               "goods_description": {
                  "type": "string",
                  "maxLength": 30,
                  "title": "The description of the goods.",
                  "description": "Refer to *Box 31* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     "Plug Valves for pipes"
                  ]
               },
               "goods_customs_heading": {
                  "type": "string",
                  "maxLength": 11,
                  "title": "The customs heading of the goods.",
                  "description": "Refer to *Box 33* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     "84818081"
                  ]
               },
               "goods_amount": {
                  "$ref": "#/$defs/amount",
                  "title": "The amount of the goods."
               },
               "freight_extra_ue_amount": {
                  "$ref": "#/$defs/amount",
                  "title": "The amount of Extra UE freight."
               },
               "freight_ue_amount": {
                  "$ref": "#/$defs/amount",
                  "title": "The amount of UE freight."
               },
               "freight_local_amount": {
                  "$ref": "#/$defs/amount",
                  "title": "The amount of Local UE freight."
               },
               "origin_country": {
                  "title": "The country code of origin.",
                  "$ref": "#/$defs/iso31661_alpha_2",
                  "description": "Only Import, Refer to *Box 34A* of *Commission Delegated Regulation (EU) 2016/341*."
               },
               "marks_and_numbers": {
                  "type": "string",
                  "title": "Marks and numbers.",
                  "description": "Refer to *Box 31* of *Commission Delegated Regulation (EU) 2016/341*.",
                  "examples": [
                     "SN123456"
                  ]
               }
            }
         }
      },
      "containers": {
         "title": "List of Containers",
         "description": "Refer to *Box 31* of *Commission Delegated Regulation (EU) 2016/341*.",
         "type": "array",
         "minItems": 0,
         "maxItems": 10,
         "uniqueItems": true,
         "items": {
            "type": "string",
            "title": "Container.",
            "maxLength": 11,
            "examples": [
               "MSCU1234567"
            ]
         },
         "examples": [
            [
               "MSCU1234567",
               "MSCU9876543"
            ]
         ]
      }
   }
}