{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://unvtd.unece.org/delivery-confirmation-schema.json",
  "title": "Delivery Confirmation",
  "description": "A verifiable confirmation of delivery issued and cryptographically signed by the consignee (or its receiving agent), referencing a despatch advice / delivery note. Replaces the wet-ink proof-of-delivery signature in fully electronic processes.",
  "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/delivery-confirmation-context.jsonld"
      ]
    },
    "type": {
      "type": "array",
      "description": "Credential types.",
      "const": [
        "VerifiableCredential",
        "DeliveryConfirmationCredential"
      ]
    },
    "name": {
      "type": "string",
      "description": "Human-readable name of the credential, for display.",
      "example": "Delivery Confirmation"
    },
    "credentialSchema": {
      "type": "object",
      "description": "Reference to the credential schema for validation",
      "properties": {
        "id": {
          "type": "string",
          "format": "uri",
          "const": "https://unvtd.unece.org/delivery-confirmation-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:dc-2025-wrs-001"
    },
    "validFrom": {
      "example": "2025-03-28T09:00:00Z",
      "type": "string",
      "format": "date-time",
      "description": "Credential validity start date"
    },
    "validUntil": {
      "example": "2026-03-28T09:00:00Z",
      "type": "string",
      "format": "date-time",
      "description": "Date until which this credential is valid."
    },
    "issuer": {
      "name": "Issuer",
      "description": "Identifier of the party issuing the delivery confirmation (e.g., DID). Must match the receiving party (consignee or its agent). The cryptographic proof of this credential constitutes the signature of receipt.",
      "type": "string",
      "format": "uri",
      "example": "did:web:waveridersupplies.example.com"
    },
    "credentialSubject": {
      "name": "DeliveryConfirmation",
      "description": "Delivery confirmation details",
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "description": "Type of the business document.",
          "const": "DeliveryConfirmation"
        },
        "deliveryConfirmationNumber": {
          "example": "DC-2025-WRS-001",
          "type": "string",
          "description": "Identifier assigned by the receiving party to the delivery confirmation."
        },
        "despatchAdviceReference": {
          "description": "Cryptographic link to the despatch advice / delivery note being confirmed. The digest binds the confirmation to the exact signed content received.",
          "type": "object",
          "properties": {
            "id": {
              "example": "urn:uuid:da-2025-surfpro-001",
              "type": "string",
              "format": "uri",
              "description": "Credential identifier of the referenced despatch advice."
            },
            "despatchAdviceNumber": {
              "example": "DA-2025-031-001",
              "type": "string",
              "description": "Business identifier of the referenced despatch advice."
            },
            "deliveryNoteNumber": {
              "example": "DN-2025-031-001",
              "type": "string",
              "description": "Business identifier of the referenced delivery note."
            },
            "digestSRI": {
              "example": "sha384-ksqdt3lNQpaOCL63Aq0XhnXhxptvCXwbfPrcOPC/VJO7ZMrFviW7gwsj0US2ogiV",
              "type": "string",
              "description": "Subresource Integrity digest of the referenced despatch advice credential, binding this confirmation to its exact content."
            }
          },
          "required": [
            "id",
            "digestSRI"
          ]
        },
        "receivedDate": {
          "example": "2025-03-27T14:30:00Z",
          "type": "string",
          "format": "date-time",
          "description": "Date and time at which the consignment was received."
        },
        "deliveryLocation": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "default": "Location",
              "enum": [
                "Location"
              ]
            },
            "name": {
              "example": "Sydney Secure Warehousing - Facility A",
              "type": "string",
              "description": "Location name."
            },
            "unLocode": {
              "type": "string",
              "description": "UN/LOCODE location identifier (5 characters)."
            },
            "postalAddress": {
              "description": "The postal address of the location.",
              "type": "object",
              "properties": {
                "type": {
                  "type": "string",
                  "default": "Address",
                  "enum": [
                    "Address"
                  ]
                },
                "streetAddress": {
                  "example": "45 Logistics Way",
                  "type": "string",
                  "description": "The street component of the address"
                },
                "addressLocality": {
                  "example": "Banksmeadow",
                  "type": "string",
                  "description": "The city component of the address"
                },
                "addressRegion": {
                  "example": "NSW",
                  "type": "string",
                  "description": "The state component of the address"
                },
                "postalCode": {
                  "example": "2019",
                  "type": "string",
                  "description": "Postal code."
                },
                "addressCountry": {
                  "example": "AU",
                  "type": "string",
                  "description": "Country code."
                }
              }
            }
          },
          "description": "Location at which the consignment was actually received."
        },
        "receivingParty": {
          "description": "Party confirming receipt of the goods. Must match the credential issuer.",
          "type": "object",
          "required": [
            "type",
            "id",
            "name"
          ],
          "properties": {
            "type": {
              "type": "string",
              "default": "Party",
              "enum": [
                "Party"
              ]
            },
            "id": {
              "example": "did:web:waveridersupplies.example.com",
              "type": "string",
              "format": "uri",
              "description": "A unique party identifier."
            },
            "name": {
              "example": "Wave Rider Supplies Pty Ltd",
              "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": "18 Harbord Road",
                  "type": "string",
                  "description": "The street component of the address"
                },
                "addressLocality": {
                  "example": "Brookvale",
                  "type": "string",
                  "description": "The city component of the address"
                },
                "addressRegion": {
                  "example": "NSW",
                  "type": "string",
                  "description": "The state component of the address"
                },
                "postalCode": {
                  "example": "2100",
                  "type": "string",
                  "description": "Postal code."
                },
                "addressCountry": {
                  "example": "AU",
                  "type": "string",
                  "description": "Country code."
                }
              }
            }
          }
        },
        "receivedBy": {
          "description": "Natural person who took receipt of the goods on behalf of the receiving party.",
          "type": "object",
          "properties": {
            "name": {
              "example": "J. Smith",
              "type": "string",
              "description": "Name of the person acknowledging receipt."
            },
            "role": {
              "example": "Goods-In Supervisor",
              "type": "string",
              "description": "Role or function of the person within the receiving party."
            },
            "id": {
              "example": "did:web:waveridersupplies.example.com:staff:jsmith",
              "type": "string",
              "format": "uri",
              "description": "Electronic identifier of the person (e.g., DID or corporate e-ID), where individual attribution is required."
            }
          }
        },
        "acceptanceStatus": {
          "example": "AcceptedWithReservations",
          "type": "string",
          "enum": [
            "Accepted",
            "AcceptedWithReservations",
            "Refused"
          ],
          "description": "Overall acceptance decision for the consignment."
        },
        "packagesReceived": {
          "example": 6,
          "type": "number",
          "description": "Total number of packages received."
        },
        "reservations": {
          "example": "Box 3 received with crushed corner; contents inspected, 2 shortboards damaged.",
          "type": "string",
          "description": "Reservations or remarks recorded by the receiver at the time of delivery."
        },
        "lineConfirmations": {
          "name": "Line Confirmations",
          "description": "Per-line receipt reconciliation against the despatch advice. May be omitted when the consignment is accepted in full without reservations.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "lineNumber": {
                "example": 1,
                "type": "number",
                "description": "Line number on the referenced despatch advice."
              },
              "sku": {
                "example": "SURF-LB-001",
                "type": "string",
                "description": "Stock keeping unit identifier of the item."
              },
              "quantityDelivered": {
                "description": "Quantity actually delivered.",
                "type": "object",
                "properties": {
                  "amount": {
                    "example": 25,
                    "type": "number",
                    "description": "Quantity value"
                  },
                  "unit": {
                    "example": "EA",
                    "type": "string",
                    "description": "Quantity unit"
                  }
                }
              },
              "quantityAccepted": {
                "description": "Quantity accepted by the receiver.",
                "type": "object",
                "properties": {
                  "amount": {
                    "example": 25,
                    "type": "number",
                    "description": "Quantity value"
                  },
                  "unit": {
                    "example": "EA",
                    "type": "string",
                    "description": "Quantity unit"
                  }
                }
              },
              "quantityRejected": {
                "description": "Quantity rejected by the receiver.",
                "type": "object",
                "properties": {
                  "amount": {
                    "example": 2,
                    "type": "number",
                    "description": "Quantity value"
                  },
                  "unit": {
                    "example": "EA",
                    "type": "string",
                    "description": "Quantity unit"
                  }
                }
              },
              "discrepancyCode": {
                "example": "Damaged",
                "type": "string",
                "enum": [
                  "Shortage",
                  "Overage",
                  "Damaged",
                  "WrongItem",
                  "Other"
                ],
                "description": "Code classifying the discrepancy, where one exists."
              },
              "remarks": {
                "example": "2 shortboards with cracked rails.",
                "type": "string",
                "description": "Free-text remarks on the discrepancy."
              }
            },
            "description": "Receipt confirmation for a specific line item."
          }
        },
        "deliveryEvidence": {
          "name": "Evidence",
          "description": "Electronic evidence recorded at delivery (e.g., photographs, sensor logs), each bound by content digest.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "description": {
                "example": "Photo of damaged box 3",
                "type": "string",
                "description": "Description of the evidence item."
              },
              "link": {
                "example": "https://edms.waveridersupplies.example.com/evidence/dc-2025-wrs-001/photo-1.jpg",
                "type": "string",
                "format": "uri",
                "description": "Resolvable location of the evidence item."
              },
              "digestSRI": {
                "example": "sha384-H8BRh8j48O9oYatfu5AZzq6A9RINhZO5H16dQZngK7T62em8MUt1FLm52t+eX6xO",
                "type": "string",
                "description": "Subresource Integrity digest binding the evidence content."
              }
            },
            "description": "An item of electronic evidence."
          }
        }
      },
      "required": [
        "type",
        "deliveryConfirmationNumber",
        "despatchAdviceReference",
        "receivedDate",
        "receivingParty",
        "acceptanceStatus"
      ],
      "additionalProperties": true
    }
  },
  "additionalProperties": true
}
