{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/snowsure-ai/json-schema/snowsure-ai-resort-snowfall-history-response-schema.json",
  "title": "ResortSnowfallHistoryResponse",
  "description": "Season snowfall ledger for one resort: daily snowfall in independent lanes, the normal-to-date curve, and past-season summaries. Since 1.6.0 each lane carries `lagDays` and `stale` (SS-W-2782): a measured or analysed lane more than 2 days behind `meta.season.asOf` is stale, and its `toDateCm` runs to its `lastDate`, not to as-of. Since 1.7.0 each lane carries `spatialScale` (SS-W-3268): the modeled and analysed lanes are `grid_cell`, so neighbouring resorts in one ERA5 cell share them.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/snowsure-ai-openapi.json#/components/schemas/ResortSnowfallHistoryResponse",
  "type": "object",
  "properties": {
    "schemaVersion": {
      "type": "string",
      "const": "1.7.0",
      "description": "Versions this payload contract, independently of info.version."
    },
    "meta": {
      "type": "object",
      "properties": {
        "source": {
          "type": "string",
          "const": "SnowSure"
        },
        "slug": {
          "type": "string",
          "description": "Canonical resort slug, after alias resolution"
        },
        "generatedAt": {
          "type": "string",
          "format": "date-time"
        },
        "hemisphere": {
          "type": "string",
          "enum": [
            "NH",
            "SH"
          ]
        },
        "season": {
          "type": "object",
          "description": "The season record window (NH 1 Sep → 30 Jun, SH 1 Jun → 30 Nov) and the ski-month focus window a chart should open on.",
          "properties": {
            "year": {
              "type": "integer",
              "description": "NH: the calendar year the season starts in. SH: the calendar year."
            },
            "label": {
              "type": "string"
            },
            "start": {
              "type": "string",
              "format": "date"
            },
            "end": {
              "type": "string",
              "format": "date"
            },
            "focusStart": {
              "type": "string",
              "format": "date"
            },
            "focusEnd": {
              "type": "string",
              "format": "date"
            },
            "inProgress": {
              "type": "boolean"
            },
            "asOf": {
              "type": "string",
              "format": "date",
              "description": "Last date the lanes can carry data — yesterday during the season (the modeled lane is mirrored the morning after)."
            },
            "operating": {
              "type": [
                "object",
                "null"
              ],
              "description": "The resort's own season: opening and closing dates for this season_year from resort_seasons, a permanent per-season record. A date in the future is 'scheduled' whatever column it came from.",
              "properties": {
                "open": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date"
                },
                "close": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "format": "date"
                },
                "openKind": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "actual",
                    "scheduled",
                    null
                  ]
                },
                "closeKind": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "enum": [
                    "actual",
                    "scheduled",
                    null
                  ]
                },
                "source": {
                  "type": [
                    "string",
                    "null"
                  ],
                  "description": "Provenance of the record: resort_website, manual, sync-resorts-trigger, wikipedia-extraction, …"
                }
              }
            }
          }
        },
        "granularity": {
          "type": "string",
          "enum": [
            "day",
            "week",
            "month"
          ]
        },
        "seasonsAvailable": {
          "type": "array",
          "description": "Every season the ledger can be asked for, newest first — the same list whichever season is selected, so a picker never strands the reader in the past.",
          "items": {
            "type": "object",
            "properties": {
              "year": {
                "type": "integer"
              },
              "label": {
                "type": "string"
              }
            }
          }
        },
        "minYearsForNorm": {
          "type": "integer",
          "description": "Complete winters required before `data.normal` is published."
        },
        "normalWithheldReason": {
          "type": [
            "string",
            "null"
          ],
          "description": "Why `data.normal` is null, when it is."
        },
        "measuredWithheldReason": {
          "type": [
            "string",
            "null"
          ],
          "description": "Why there is no measured lane, when there is none: \"No alpine station\" means no station within 750 m below the summit reports snow for this resort (SS-W-2744). Null when the measured lane exists."
        },
        "lanesNote": {
          "type": "string",
          "description": "The blending rule, restated for agents that read the payload without the docs."
        }
      }
    },
    "data": {
      "type": "object",
      "properties": {
        "lanes": {
          "type": "array",
          "description": "Independent sources, in order modeled → measured → analysed → reported. A lane with nothing observed is absent. `analysed` is NOAA's National Snowfall Analysis sampled at the resort's coordinates (CONUS only, SS-W-370): a grid cell, not a station, and never blended into `measured`.",
          "items": {
            "type": "object",
            "properties": {
              "key": {
                "type": "string",
                "enum": [
                  "modeled",
                  "measured",
                  "analysed",
                  "reported"
                ]
              },
              "label": {
                "type": "string"
              },
              "source": {
                "type": "string",
                "description": "Named network or origin — \"ERA5 / Open-Meteo\", \"SNOTEL\", \"SLF IMIS\", \"Resort\"."
              },
              "sourceKey": {
                "type": "string",
                "description": "The snowfall_actuals source key behind the lane."
              },
              "stationId": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "stationName": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "stationElevationM": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "stationDistanceKm": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "tier": {
                "type": "integer",
                "description": "ML truth tier (1 best). snotel 1, meteofrance 2, resort_reported 3, ghcn/amedas/geosphere 4, depth-derived 5, open_meteo 6."
              },
              "firstDate": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              "lastDate": {
                "type": [
                  "string",
                  "null"
                ],
                "format": "date"
              },
              "toDateCm": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Cumulative through `meta.season.asOf`. Null before the season starts."
              },
              "toDateSource": {
                "type": [
                  "string",
                  "null"
                ],
                "enum": [
                  "counter",
                  "days",
                  null
                ],
                "description": "Where `toDateCm` came from. 'counter' is the resort's own published season-to-date figure; 'days' is the sum of this lane's own days. Null when the lane has no total. Never absent — a total without a source is not publishable."
              },
              "lagDays": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Days between this lane's `lastDate` and `meta.season.asOf`. Null when the lane has no reading this season."
              },
              "stale": {
                "type": "boolean",
                "description": "True when a measured or analysed lane's last reading is more than 2 days before `meta.season.asOf` (SS-W-2782). A stale lane's `toDateCm` is the total to its `lastDate`, and a stale zero means no data, not no snow: do not display it as a season total. Always false on the modeled lane (it runs to as-of) and the reported lane (a resort that filed nothing had a dry day, not a gap)."
              },
              "spatialScale": {
                "type": "string",
                "enum": [
                  "grid_cell",
                  "station",
                  "resort"
                ],
                "description": "What one number in this lane stands for (since 1.7.0, SS-W-3268). `grid_cell`: a reanalysis or analysis cell tens of km across, so resorts in the same cell carry the same series (modeled, analysed). `station`: one named gauge at `stationElevationM` (measured). `resort`: what the resort itself published (reported)."
              },
              "vsNormalPct": {
                "type": [
                  "integer",
                  "null"
                ],
                "description": "Modeled lane only: signed percent vs `data.normal` at the as-of day. Null on other lanes, when the normal is withheld, or while the normal-to-date is under 10 cm."
              },
              "days": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "date": {
                      "type": "string",
                      "format": "date"
                    },
                    "cm": {
                      "type": [
                        "number",
                        "null"
                      ],
                      "description": "Snowfall that day. Null = no observation (station and reported lanes only)."
                    },
                    "cumCm": {
                      "type": "number",
                      "description": "Cumulative through this day; gaps carry the previous total."
                    }
                  }
                }
              },
              "bins": {
                "type": "array",
                "description": "`days` rolled up to the requested granularity.",
                "items": {
                  "type": "object",
                  "properties": {
                    "start": {
                      "type": "string",
                      "format": "date"
                    },
                    "end": {
                      "type": "string",
                      "format": "date"
                    },
                    "cm": {
                      "type": "number"
                    },
                    "cumCm": {
                      "type": "number"
                    },
                    "observedDays": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        },
        "snowDaysByLane": {
          "type": "object",
          "description": "Snow days (≥ 1 cm) per lane, computed once server-side (SS-W-324). Headline and comparison both read `modeled`. A missing lane is 0.",
          "required": [
            "modeled",
            "measured",
            "analysed",
            "reported"
          ],
          "properties": {
            "modeled": {
              "type": "integer"
            },
            "measured": {
              "type": "integer"
            },
            "analysed": {
              "type": "integer"
            },
            "reported": {
              "type": "integer"
            }
          }
        },
        "normal": {
          "type": [
            "object",
            "null"
          ],
          "description": "Normal-to-date from the modeled lane across complete winters. Null when withheld — see `meta.normalWithheldReason`.",
          "properties": {
            "winters": {
              "type": "integer"
            },
            "days": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "dayOfSeason": {
                    "type": "integer"
                  },
                  "date": {
                    "type": "string",
                    "format": "date"
                  },
                  "meanCumCm": {
                    "type": "number"
                  },
                  "p25CumCm": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "p75CumCm": {
                    "type": [
                      "number",
                      "null"
                    ]
                  }
                }
              }
            }
          }
        },
        "snowsureSeasonCounter": {
          "type": [
            "object",
            "null"
          ],
          "description": "SnowSure's own count of the resort's daily statements this season, stored on the season record every six hours (SS-W-122). Same sum as the reported lane's toDateCm, but persisted. Null until the resort has stated a 24h figure this season.",
          "properties": {
            "cm": {
              "type": "number"
            },
            "days": {
              "type": "integer",
              "description": "Daily statements behind the count, published zeros included."
            },
            "asOf": {
              "type": [
                "string",
                "null"
              ],
              "format": "date"
            }
          }
        },
        "reportedSeasonCounter": {
          "type": [
            "object",
            "null"
          ],
          "description": "The resort's own published season-to-date total, as last archived. Independent of the reported lane's daily sum.",
          "properties": {
            "cm": {
              "type": "number"
            },
            "asOf": {
              "type": "string",
              "format": "date"
            }
          }
        },
        "depth": {
          "type": "object",
          "description": "Snow depth by source and elevation tier, one series each, never blended. A day without a reading is null and drawn as a gap. Lanes absent when nothing was archived.",
          "properties": {
            "lanes": {
              "type": "array",
              "items": {
                "type": "object",
                "properties": {
                  "key": {
                    "type": "string",
                    "enum": [
                      "modeled",
                      "reported",
                      "measured"
                    ]
                  },
                  "tier": {
                    "type": "string",
                    "enum": [
                      "base",
                      "mid",
                      "summit",
                      "station"
                    ]
                  },
                  "label": {
                    "type": "string"
                  },
                  "source": {
                    "type": "string",
                    "description": "\"ERA5 / Open-Meteo\", \"Resort (website)\", \"Resort (portal)\", or the station network."
                  },
                  "stationId": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "stationName": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "stationElevationM": {
                    "type": [
                      "number",
                      "null"
                    ]
                  },
                  "observedDays": {
                    "type": "integer"
                  },
                  "latest": {
                    "type": [
                      "object",
                      "null"
                    ],
                    "properties": {
                      "date": {
                        "type": "string",
                        "format": "date"
                      },
                      "cm": {
                        "type": "number"
                      }
                    }
                  },
                  "days": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "date": {
                          "type": "string",
                          "format": "date"
                        },
                        "cm": {
                          "type": [
                            "number",
                            "null"
                          ]
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "pastSeasons": {
          "type": "array",
          "description": "Prior seasons, newest first, for the sparkline strip.",
          "items": {
            "type": "object",
            "properties": {
              "seasonYear": {
                "type": "integer"
              },
              "label": {
                "type": "string"
              },
              "totalCm": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "snowDays": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "maxStormCm": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "weeklyCumCm": {
                "type": "array",
                "description": "Modeled cumulative at the end of each 7-day bin from the record start.",
                "items": {
                  "type": "number"
                }
              },
              "reportedTotalCm": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "What the resort stated that season, summed by SnowSure. Null for seasons before the reported lane existed."
              },
              "reportedDays": {
                "type": [
                  "integer",
                  "null"
                ]
              }
            }
          }
        }
      }
    }
  }
}