Transfer Schema

{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://local-loop-io.github.io/projects/loop-protocol/schemas/v0.2.0/transfer.schema.json",
  "title": "Transfer",
  "description": "Transfer schema — LOOP v0.2.0",
  "type": "object",
  "required": [
    "@context",
    "@type",
    "schema_version",
    "id",
    "match_id",
    "status",
    "handoff_at"
  ],
  "anyOf": [
    {
      "required": [
        "material_id"
      ]
    },
    {
      "required": [
        "product_id"
      ]
    }
  ],
  "properties": {
    "@context": {
      "description": "JSON-LD context",
      "type": "string",
      "enum": [
        "https://local-loop-io.github.io/projects/loop-protocol/contexts/loop-v0.1.1.jsonld",
        "https://local-loop-io.github.io/projects/loop-protocol/contexts/loop-v0.2.0.jsonld"
      ]
    },
    "@type": {
      "description": "Object type identifier",
      "type": "string",
      "const": "Transfer"
    },
    "schema_version": {
      "description": "Schema version for the interop flow. Emitters SHOULD use 0.2.0; receivers SHOULD accept additive minor/patch releases.",
      "type": "string",
      "pattern": "^0\\.[1-9]\\d*\\.\\d+$",
      "examples": [
        "0.1.1",
        "0.2.0"
      ]
    },
    "id": {
      "description": "Transfer identifier",
      "type": "string",
      "pattern": "^[A-Z0-9-]{8,}$",
      "examples": [
        "TRF-5D8A23F1"
      ]
    },
    "material_id": {
      "description": "MaterialDNA identifier (required if no product_id)",
      "type": "string",
      "pattern": "^MAT-[A-Z]{2}-[A-Z]{3}-\\d{4}-[A-Z]+-[A-Z0-9]{6,}$",
      "examples": [
        "MAT-DE-MUC-2025-PLASTIC-B847F3"
      ]
    },
    "product_id": {
      "description": "ProductDNA identifier (required if no material_id)",
      "type": "string",
      "pattern": "^PRD-[A-Z0-9-]{8,}$",
      "examples": [
        "PRD-DE-MUC-2025-DESK-F4A7B2"
      ]
    },
    "match_id": {
      "description": "Match identifier",
      "type": "string",
      "pattern": "^[A-Z0-9-]{8,}$",
      "examples": [
        "MCH-9B3C8A12"
      ]
    },
    "status": {
      "description": "Transfer status",
      "type": "string",
      "enum": [
        "scheduled",
        "in_transit",
        "completed",
        "cancelled"
      ]
    },
    "handoff_at": {
      "description": "Handoff timestamp (ISO 8601)",
      "type": "string",
      "format": "date-time",
      "examples": [
        "2025-06-02T09:00:00Z"
      ]
    },
    "received_at": {
      "description": "Receipt timestamp (ISO 8601)",
      "type": "string",
      "format": "date-time",
      "examples": [
        "2025-06-02T18:00:00Z"
      ]
    },
    "route": {
      "description": "Optional route metadata",
      "type": "object",
      "properties": {
        "from_city": {
          "type": "string",
          "examples": [
            "Munich"
          ]
        },
        "to_city": {
          "type": "string",
          "examples": [
            "Berlin"
          ]
        },
        "mode": {
          "type": "string",
          "examples": [
            "road"
          ]
        }
      }
    },
    "metadata": {
      "description": "Additional metadata",
      "type": "object",
      "additionalProperties": true
    },
    "traceability": {
      "description": "Optional chain-of-custody and evidence references for transfer events.",
      "type": "object",
      "properties": {
        "batch_id": {
          "type": "string",
          "maxLength": 120
        },
        "serial_number": {
          "type": "string",
          "maxLength": 160
        },
        "lot_number": {
          "type": "string",
          "maxLength": 120
        },
        "source_operator_id": {
          "type": "string",
          "maxLength": 120
        },
        "facility_id": {
          "type": "string",
          "maxLength": 120
        },
        "retention_until": {
          "type": "string",
          "format": "date-time"
        },
        "document_refs": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uri"
          },
          "maxItems": 20
        },
        "due_diligence_ref": {
          "type": "string",
          "maxLength": 160
        },
        "epcis_event_refs": {
          "type": "array",
          "items": {
            "type": "object",
            "required": [
              "event_type",
              "event_id"
            ],
            "properties": {
              "event_type": {
                "type": "string",
                "enum": [
                  "observation",
                  "aggregation",
                  "transaction",
                  "transformation"
                ]
              },
              "event_id": {
                "type": "string"
              },
              "event_url": {
                "type": "string",
                "format": "uri"
              },
              "hash_digest": {
                "type": "string"
              },
              "hash_method": {
                "type": "string",
                "enum": [
                  "SHA-256",
                  "SHA-384",
                  "SHA-512"
                ]
              }
            }
          }
        },
        "chain_of_custody_url": {
          "type": "string",
          "format": "uri"
        },
        "w3c_vc_credential_id": {
          "type": "string",
          "format": "uri"
        },
        "w3c_vc_issuer": {
          "type": "string",
          "format": "uri"
        }
      },
      "additionalProperties": true
    },
    "passport": {
      "description": "Subset of passport fields relevant to transfer events.",
      "type": "object",
      "properties": {
        "passport_id": {
          "type": "string",
          "maxLength": 160
        },
        "passport_url": {
          "type": "string",
          "format": "uri"
        },
        "access_scope": {
          "type": "string",
          "enum": [
            "public",
            "role-based",
            "restricted"
          ]
        }
      },
      "additionalProperties": true
    },
    "waste_shipment_doc_ref": {
      "description": "Waste Shipment Regulation evidence URL",
      "type": "string",
      "format": "uri"
    },
    "environmental_conditions": {
      "description": "Environmental conditions during transfer",
      "type": "object",
      "properties": {
        "temperature_c": {
          "type": "number"
        },
        "humidity_percent": {
          "type": "number"
        }
      }
    }
  }
}