{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://unvtd.unece.org/rail-consignment-note-schema.json",
  "title": "Rail Consignment Note (CIM)",
  "description": "A transport document issued under the Uniform Rules Concerning the Contract of International Carriage of Goods by Rail (CIM) evidencing the contract of rail carriage between the consignor and the carrier for cross-border rail freight.",
  "type": "object",
  "required": [
    "@context",
    "type",
    "issuer",
    "credentialSubject",
    "credentialSchema"
  ],
  "properties": {
    "@context": {
      "type": "array",
      "description": "JSON-LD contexts: the W3C Verifiable Credentials v2 context, followed by this document's context.",
      "const": [
        "https://www.w3.org/ns/credentials/v2",
        "https://unvtd.unece.org/rail-consignment-note-context.jsonld"
      ]
    },
    "type": {
      "type": "array",
      "description": "Credential types.",
      "const": [
        "VerifiableCredential",
        "RailConsignmentNoteCredential"
      ]
    },
    "name": {
      "type": "string",
      "description": "Human-readable name of the credential, for display.",
      "example": "Rail Consignment Note (CIM)"
    },
    "credentialSchema": {
      "type": "object",
      "description": "Reference to the credential schema for validation",
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "const": "https://unvtd.unece.org/rail-consignment-note-schema.json",
          "description": "Public location of the schema"
        },
        "type": {
          "type": "string",
          "const": "JsonSchema",
          "description": "Schema type identifier"
        }
      },
      "required": [
        "id",
        "type"
      ]
    },
    "id": {
      "type": "string",
      "format": "uri",
      "description": "Unique identifier for the credential",
      "example": "urn:uuid:cim-2025-de-001234"
    },
    "validFrom": {
      "example": "2025-03-12T00:00:00.000Z",
      "type": "string",
      "format": "date-time",
      "description": "Credential validity start date"
    },
    "validUntil": {
      "example": "2026-03-12T00:00:00.000Z",
      "type": "string",
      "format": "date-time",
      "description": "Date until which this credential is valid."
    },
    "issuer": {
      "description": "Identifier of the rail carrier issuing the consignment note (e.g., DID)",
      "type": "string",
      "format": "uri",
      "example": "did:web:dbcargo.example.com"
    },
    "credentialSubject": {
      "name": "RailConsignmentNote",
      "description": "Rail consignment note (CIM) details",
      "type": "object",
      "required": [
        "type",
        "consignor",
        "consignee",
        "destinationStation",
        "descriptionOfGoods",
        "numberOfPackages",
        "dangerousGoodsClassNumber",
        "transportMeansIdentifier",
        "vehicleRegistrationNumber",
        "transportEquipmentIdentifier"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "Type of the business document.",
          "const": "RailConsignmentNote"
        },
        "consignor": {
          "description": "Party consigning goods for rail carriage.",
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "default": "Party",
              "enum": [
                "Party"
              ]
            },
            "id": {
              "example": "did:web:waveridersports-de.example.com",
              "type": "string",
              "format": "uri",
              "description": "A unique party identifier."
            },
            "name": {
              "example": "Wave Rider Sports GmbH",
              "type": "string",
              "description": "Trade party name."
            },
            "postalAddress": {
              "description": "The postal address of the party.",
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "default": "Address",
                  "enum": [
                    "Address"
                  ]
                },
                "streetAddress": {
                  "example": "88 Hafenstrasse",
                  "type": "string",
                  "description": "The street component of the address."
                },
                "addressLocality": {
                  "example": "Hamburg",
                  "type": "string",
                  "description": "The city component of the address."
                },
                "postalCode": {
                  "example": "20457",
                  "type": "string",
                  "description": "Postal code."
                },
                "addressCountry": {
                  "example": "DE",
                  "type": "string",
                  "description": "Country."
                }
              }
            }
          }
        },
        "consignee": {
          "description": "Party to which the goods are consigned for rail delivery.",
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "default": "Party",
              "enum": [
                "Party"
              ]
            },
            "id": {
              "example": "did:web:balticsurfclub.example.com",
              "type": "string",
              "format": "uri",
              "description": "A unique party identifier."
            },
            "name": {
              "example": "Baltic Surf Club Sp. z o.o.",
              "type": "string",
              "description": "Trade party name."
            },
            "postalAddress": {
              "description": "The postal address of the party.",
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "default": "Address",
                  "enum": [
                    "Address"
                  ]
                },
                "streetAddress": {
                  "example": "ul. Sportowa 12",
                  "type": "string",
                  "description": "The street component of the address."
                },
                "addressLocality": {
                  "example": "Warsaw",
                  "type": "string",
                  "description": "The city component of the address."
                },
                "postalCode": {
                  "example": "00-001",
                  "type": "string",
                  "description": "Postal code."
                },
                "addressCountry": {
                  "example": "PL",
                  "type": "string",
                  "description": "Country."
                }
              }
            }
          }
        },
        "destinationStation": {
          "description": "Name of the destination railway station where the goods are to be delivered.",
          "type": "object",
          "properties": {
            "name": {
              "example": "Warszawa Towarowa",
              "type": "string",
              "description": "Name of the destination railway station."
            },
            "addressLocality": {
              "example": "Warsaw",
              "type": "string",
              "description": "City."
            },
            "addressCountry": {
              "example": "PL",
              "type": "string",
              "description": "Country."
            }
          }
        },
        "descriptionOfGoods": {
          "example": "Surfboards, fins and wetsuits for water sports retail",
          "type": "string",
          "description": "Plain language description of the nature of the goods carried by rail."
        },
        "numberOfPackages": {
          "example": 18,
          "type": "number",
          "description": "Number of packages in the consignment."
        },
        "dangerousGoodsClassNumber": {
          "example": "N/A",
          "type": "string",
          "description": "RID dangerous goods class number applicable to the consignment (or N/A if not applicable)."
        },
        "transportMeansIdentifier": {
          "example": "DB 193 362",
          "type": "string",
          "description": "Identifier of the rail locomotive or traction unit."
        },
        "vehicleRegistrationNumber": {
          "example": "91 80 6193 362-8 D-DB",
          "type": "string",
          "description": "European Vehicle Number (EVN) or other registration number of the rail vehicle."
        },
        "transportEquipmentIdentifier": {
          "example": "33 80 4780 001-4",
          "type": "string",
          "description": "Identifier of the rail wagon or other transport equipment."
        }
      },
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
