{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/dockflow-com/json-schema/dockflow-com-upstream-record-schema.json",
  "title": "UpstreamRecord",
  "description": "One record per shipment of a tradeflow. The locations, containers, vessels, shipment and events blocks are present when requested with fields.",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/dockflow-com-openapi.json#/components/schemas/UpstreamRecord",
  "type": "object",
  "properties": {
    "version": {
      "type": "string"
    },
    "tradeflow_reference": {
      "type": "string"
    },
    "bill_of_lading": {
      "type": [
        "string",
        "null"
      ]
    },
    "booking": {
      "type": [
        "string",
        "null"
      ]
    },
    "additional_references": {
      "type": "object",
      "properties": {
        "bill_of_lading": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "booking": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      }
    },
    "data_quality": {
      "type": "object",
      "properties": {
        "freshness_min": {
          "type": "integer"
        },
        "anomalies": {
          "type": "number"
        },
        "missed_milestones": {
          "type": "integer"
        },
        "has_live_data": {
          "type": "boolean"
        },
        "is_singular_shipment": {
          "type": "boolean"
        }
      }
    },
    "metadata": {
      "type": "object",
      "properties": {
        "last_updated": {
          "type": "string",
          "format": "date-time",
          "description": "Keep since unchanged while following next_cursor; after the last page, use the highest value as the next since."
        },
        "carrier_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "carrier_scac": {
          "type": [
            "string",
            "null"
          ]
        },
        "is_active": {
          "type": "boolean"
        },
        "created_at": {
          "type": "string",
          "format": "date-time"
        }
      }
    },
    "partners": {
      "type": "array",
      "description": "The other organisations on this tradeflow, oldest link first. Your own organisation is not listed.",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "roles": {
            "type": "array",
            "description": "Lowercased, e.g. client, forwarder.",
            "items": {
              "type": "string"
            }
          },
          "reference": {
            "type": [
              "string",
              "null"
            ],
            "description": "That partner's own reference for this tradeflow."
          }
        }
      }
    },
    "locations": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "containers": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "vessels": {
      "type": "array",
      "items": {
        "type": "object"
      }
    },
    "shipment": {
      "type": "object"
    },
    "events": {
      "type": "array",
      "items": {
        "type": "object"
      }
    }
  },
  "required": [
    "version",
    "tradeflow_reference",
    "bill_of_lading",
    "booking",
    "additional_references",
    "data_quality",
    "metadata"
  ]
}