❄️

Snow Status API

Real-time snow conditions and 7-day forecasts for Flagstaff & Sedona, AZ

GET /api/status

Returns cached snow status for both cities. Fast response, no external API calls.

Parameters: None
Response:
{
  "lastCheckedAt": "2026-01-14T22:23:33.470Z",
  "flagstaff": {
    "isSnowing": false,
    "lastChangedAt": "2026-01-14T06:00:00.000Z",
    "lastCheckedAt": "2026-01-14T22:23:33.470Z",
    "snowForecast": {
      "expectedDate": "2026-01-18",
      "daysAway": 4,
      "snowfallCm": 2.5
    }
  },
  "sedona": {
    "isSnowing": true,
    "lastChangedAt": "2026-01-14T20:00:00.000Z",
    "lastCheckedAt": "2026-01-14T22:23:33.470Z",
    "snowForecast": null
  }
}

POST /api/subscribe

Subscribe an email to receive snow alerts. Rate limited to 5 requests/minute per IP.

Body (JSON):
{
  "email": "user@example.com",
  "cities": ["flagstaff", "sedona"]  // optional, defaults to both
}
Response:
{ "ok": true }

Note: Response is always the same to prevent email enumeration.

GET /api/unsubscribe

One-click unsubscribe from email alerts. Returns an HTML confirmation page.

Query Parameters:
ParamTypeDescription
tokenstring (UUID)Unsubscribe token from email
Example:
GET /api/unsubscribe?token=550e8400-e29b-41d4-a716-446655440000

GET /api/force-check

Force a fresh weather check. Fetches live data from Open-Meteo, updates database, and sends alerts if conditions changed.

Authentication: Requires secret (query param or header)
ParamTypeDescription
secretstringCRON_SECRET env var value
Response:
{
  "runId": "x5dnm3zu",
  "timestamp": "2026-01-14T22:23:33.470Z",
  "provider": "open-meteo",
  "latencyMs": 608,
  "results": [
    {
      "city": "Flagstaff, AZ",
      "isSnowing": false,
      "weatherCode": 3,
      "temperature": 11.3,
      "previousState": false,
      "stateChanged": false,
      "emailsSent": 0,
      "forecast": {
        "snowExpected": true,
        "nextSnowDate": "2026-01-18",
        "daysAway": 4,
        "forecastAlertSent": true
      }
    },
    {
      "city": "Sedona, AZ",
      "isSnowing": false,
      "weatherCode": 0,
      "temperature": 19,
      "previousState": false,
      "stateChanged": false,
      "emailsSent": 0,
      "forecast": {
        "snowExpected": false,
        "nextSnowDate": null,
        "daysAway": null,
        "forecastAlertSent": false
      }
    }
  ]
}

POST /api/cron/check-snow

Scheduled weather check (called by Vercel Cron daily at 8 AM UTC). Same as force-check but respects month gate (Dec-Mar only).

Authentication: Requires x-cron-secret header or secret query param
Response (outside winter months):
{
  "skipped": true,
  "reason": "Outside allowed months (current: 7, allowed: [12, 1, 2, 3])"
}

Weather Codes Reference

WMO Weather Codes from Open-Meteo. Snow conditions:

CodeCondition
0Clear sky
1-3Partly cloudy / Overcast
71Slight snow fall
73Moderate snow fall
75Heavy snow fall
77Snow grains
85Slight snow showers
86Heavy snow showers

Email Notifications

Subscribers receive two types of alerts:

1. Snow Alert (when it starts snowing)

Subject: ❄️ IT IS SNOWING IN FLAGSTAFF

2. Forecast Alert (when snow appears in 7-day forecast)

Subject: 🌨️ SNOW COMING TO FLAGSTAFF IN 3 DAYS