{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/opentrack/json-schema/opentrack-container-route-schema.json",
  "title": "ContainerRoute",
  "x-generated": "2026-11-15",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/opentrack-api-openapi.yml#/components/schemas/ContainerRoute",
  "required": [
    "containerId",
    "masterBillId",
    "status",
    "route"
  ],
  "properties": {
    "containerId": {
      "type": "string",
      "description": "The container identifier"
    },
    "masterBillId": {
      "type": "string",
      "description": "The master bill of lading identifier"
    },
    "lastKnownPosition": {
      "$ref": "#/$defs/Position",
      "description": "The last known coordinates of the container"
    },
    "status": {
      "$ref": "#/$defs/Status"
    },
    "route": {
      "type": "array",
      "description": "Array of route segments representing the container journey",
      "items": {
        "$ref": "#/$defs/RouteLeg"
      }
    }
  },
  "$defs": {
    "EventClassifier": {
      "type": "string",
      "description": "Classification of whether the route segment is based on actual or estimated data",
      "enum": [
        "ACT",
        "EST"
      ]
    },
    "Point": {
      "type": "object",
      "properties": {
        "latitude": {
          "type": "number",
          "minimum": -90,
          "maximum": 90
        },
        "longitude": {
          "type": "number",
          "minimum": -180,
          "maximum": 180
        }
      }
    },
    "Position": {
      "required": [
        "coordinates"
      ],
      "properties": {
        "coordinates": {
          "$ref": "#/$defs/Point"
        }
      }
    },
    "RouteGeometry": {
      "type": "object",
      "description": "GeoJSON Feature representing the path geometry between two points",
      "required": [
        "type",
        "geometry"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Feature"
          ]
        },
        "geometry": {
          "oneOf": [
            {
              "type": "object",
              "required": [
                "type",
                "coordinates"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "LineString"
                  ]
                },
                "coordinates": {
                  "type": "array",
                  "description": "Array of longitude, latitude coordinate pairs",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "number"
                    },
                    "minItems": 2,
                    "maxItems": 2
                  }
                }
              }
            },
            {
              "type": "object",
              "required": [
                "type",
                "coordinates"
              ],
              "properties": {
                "type": {
                  "type": "string",
                  "enum": [
                    "MultiLineString"
                  ]
                },
                "coordinates": {
                  "type": "array",
                  "description": "Array of LineString coordinate arrays",
                  "items": {
                    "type": "array",
                    "items": {
                      "type": "array",
                      "items": {
                        "type": "number"
                      },
                      "minItems": 2,
                      "maxItems": 2
                    },
                    "minItems": 2
                  }
                }
              }
            }
          ]
        },
        "properties": {
          "type": "object",
          "description": "Additional properties for the geometry (may be empty)"
        }
      }
    },
    "RouteLeg": {
      "required": [
        "from",
        "to",
        "points",
        "segment",
        "modeOfTransport",
        "eventClassifierCode"
      ],
      "properties": {
        "from": {
          "$ref": "#/$defs/RouteLocation"
        },
        "to": {
          "$ref": "#/$defs/RouteLocation"
        },
        "points": {
          "$ref": "#/$defs/RouteGeometry"
        },
        "segment": {
          "type": "string",
          "description": "The segment of the journey this leg represents",
          "enum": [
            "origin",
            "ocean",
            "destination"
          ]
        },
        "modeOfTransport": {
          "$ref": "#/$defs/TransportMode"
        },
        "eventClassifierCode": {
          "$ref": "#/$defs/EventClassifier"
        }
      }
    },
    "RouteLocation": {
      "type": "object",
      "description": "GeoJSON Feature representing a location point on the route",
      "required": [
        "type",
        "geometry",
        "properties"
      ],
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "Feature"
          ]
        },
        "geometry": {
          "type": "object",
          "required": [
            "type",
            "coordinates"
          ],
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "Point"
              ]
            },
            "coordinates": {
              "type": "array",
              "description": "Longitude, latitude coordinates",
              "items": {
                "type": "number"
              },
              "minItems": 2,
              "maxItems": 2
            }
          }
        },
        "properties": {
          "$ref": "#/$defs/RouteProperties"
        }
      }
    },
    "RouteProperties": {
      "type": "object",
      "description": "Properties describing a route location - can contain location information, container information, or be empty",
      "properties": {
        "name": {
          "type": "string",
          "description": "Name of the location or container identifier"
        },
        "state": {
          "type": "string",
          "description": "State or province of the location"
        },
        "country": {
          "type": "string",
          "description": "Country of the location"
        },
        "city": {
          "type": "string",
          "description": "City of the location"
        },
        "timezone": {
          "type": "string",
          "description": "Timezone of the location"
        },
        "status": {
          "$ref": "#/$defs/Status"
        },
        "index": {
          "type": "integer",
          "description": "Index for ordered locations like rail sightings"
        },
        "createdAt": {
          "type": "string",
          "format": "date-time",
          "description": "Timestamp"
        }
      }
    },
    "Status": {
      "type": "string",
      "description": "The current status of the container.  Can either be a lifecycle milestone, or a status indicating that OpenTrack is still searching for information about the container. Click <a href=\"/docs/container-voyage-milestones\" target=\"_blank\">here</a> for more information",
      "enum": [
        "DISCOVERING",
        "DISCOVERED",
        "BOOKED",
        "NOT_FOUND",
        "EMPTY_OUTGATED",
        "FULL_INGATED_AT_ORIGIN_RAIL_FACILITY",
        "LOADED_ON_RAIL_AT_ORIGIN",
        "DEPARTED_ON_RAIL_FROM_ORIGIN",
        "ARRIVED_AT_ORIGIN_PORT_RAIL_FACILITY",
        "UNLOADED_FROM_RAIL_AT_ORIGIN_PORT",
        "FULL_INGATED",
        "LOADED_ON_BARGE_AT_ORIGIN",
        "BARGE_DEPARTED_FROM_ORIGIN",
        "BARGE_BERTHED_AT_ORIGIN_PORT",
        "DISCHARGED_FROM_BARGE_AT_ORIGIN_PORT",
        "LOADED",
        "VESSEL_DEPARTED",
        "VESSEL_ARRIVED_AT_TRANSSHIPMENT_PORT",
        "VESSEL_BERTHED_AT_TRANSSHIPMENT_PORT",
        "DISCHARGED_AT_TRANSSHIPMENT_PORT",
        "LOADED_AT_TRANSSHIPMENT_PORT",
        "VESSEL_DEPARTED_FROM_TRANSSHIPMENT_PORT",
        "VESSEL_ARRIVED",
        "VESSEL_BERTHED",
        "DISCHARGED",
        "LOADED_ON_BARGE_AT_DESTINATION_PORT",
        "BARGE_DEPARTED_FROM_DESTINATION_PORT",
        "BARGE_BERTHED_AT_DESTINATION",
        "DISCHARGED_FROM_BARGE_AT_DESTINATION",
        "AVAILABLE",
        "FULL_OUTGATED",
        "FULL_INGATED_TO_RAIL_FACILITY",
        "LOADED_ON_RAIL",
        "DEPARTED_ON_RAIL",
        "ARRIVED_AT_RAIL_FACILITY",
        "UNLOADED_FROM_RAIL",
        "ACTUAL_PLACEMENT",
        "AVAILABLE_AT_RAIL_FACILITY",
        "FULL_OUTGATED_FROM_RAIL_FACILITY",
        "FULL_INGATED_TO_OFFDOCK_FACILITY",
        "AVAILABLE_AT_OFFDOCK_FACILITY",
        "FULL_OUTGATED_FROM_OFFDOCK_FACILITY",
        "FULL_DROPPED_OFF_AT_TRUCKER_YARD",
        "FULL_PICKED_UP_FROM_TRUCKER_YARD",
        "DELIVERED",
        "EMPTY_READY_FOR_PICKUP",
        "EMPTY_PICKED_UP_FOR_RETURN",
        "EMPTY_DROPPED_OFF_AT_TRUCKER_YARD",
        "EMPTY_PICKED_UP_FROM_TRUCKER_YARD",
        "EMPTY_RETURNED"
      ]
    },
    "TransportMode": {
      "type": "string",
      "description": "The mode of transportation for this route segment",
      "enum": [
        "VESSEL",
        "BARGE",
        "TRUCK",
        "RAIL"
      ]
    }
  }
}