{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/qr-manager-ai/json-schema/qr-manager-ai-qr-analytics-response-schema.json",
  "title": "QrAnalyticsResponse",
  "x-generated": "2026-11-22",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/qr-manager-ai-openapi.yml#/components/schemas/QrAnalyticsResponse",
  "type": "object",
  "required": [
    "slug",
    "totalScans"
  ],
  "properties": {
    "slug": {
      "type": "string"
    },
    "range": {
      "type": "integer",
      "description": "Present when the `range` param was used. The rolling window in days."
    },
    "period": {
      "type": "string",
      "enum": [
        "week",
        "month",
        "quarter",
        "year"
      ],
      "description": "Present when the `period` param was used."
    },
    "from": {
      "type": "string",
      "format": "date",
      "description": "Present when a custom `from`/`to` window was requested."
    },
    "to": {
      "type": "string",
      "format": "date",
      "description": "Present when a custom `from`/`to` window was requested."
    },
    "tz": {
      "type": "string",
      "description": "Present when a non-UTC timezone was requested."
    },
    "totalScans": {
      "type": "integer",
      "description": "All-time scan count (bot scans excluded)."
    },
    "periodScans": {
      "type": "integer",
      "description": "Total scan count within the requested window (includes repeat scans)."
    },
    "uniqueScans": {
      "type": "integer",
      "description": "Deduplicated scan count within the window. Counts distinct scanner fingerprints\n(coarse IP prefix + user-agent) per calendar day. Accurate from 2026-05-30 onwards.\n"
    },
    "last7Days": {
      "type": "integer",
      "description": "Present when `range=30` or `range=90`."
    },
    "last30Days": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Present when `range=30` or `range=90`."
    },
    "last90Days": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Present when `range=90`."
    },
    "dailyScans": {
      "type": "array",
      "description": "One entry per calendar day in the window, oldest first. Present when `granularity=day` (default).",
      "items": {
        "$ref": "#/$defs/DailyCount"
      }
    },
    "hourlySeries": {
      "type": "array",
      "description": "One entry per hour in the window, oldest first. Present when `granularity=hour` (replaces `dailyScans`).",
      "items": {
        "$ref": "#/$defs/HourlyCount"
      }
    },
    "topCountries": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 countries by scan count.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topCities": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 cities.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topRegions": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 states or provinces.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topDevices": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 device types (Mobile, Desktop, Tablet).",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topBrowsers": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 browsers.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topOs": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 operating systems.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topReferrers": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 referring domains.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "topLanguages": {
      "type": "array",
      "description": "**Pro / Enterprise only.** Top 5 Accept-Language values.",
      "items": {
        "$ref": "#/$defs/BreakdownEntry"
      }
    },
    "note": {
      "type": "string",
      "description": "Present for static QR types (non-URL, non-SHORTLINK) explaining why detailed analytics are unavailable."
    }
  },
  "$defs": {
    "BreakdownEntry": {
      "type": "object",
      "required": [
        "name",
        "scans"
      ],
      "properties": {
        "name": {
          "type": "string"
        },
        "scans": {
          "type": "integer"
        }
      }
    },
    "DailyCount": {
      "type": "object",
      "required": [
        "date",
        "scans"
      ],
      "properties": {
        "date": {
          "type": "string",
          "format": "date"
        },
        "scans": {
          "type": "integer"
        }
      }
    },
    "HourlyCount": {
      "type": "object",
      "required": [
        "hour",
        "scans"
      ],
      "properties": {
        "hour": {
          "type": "string",
          "description": "Hour bucket in `YYYY-MM-DDTHH:00` format, in the requested timezone."
        },
        "scans": {
          "type": "integer"
        }
      }
    }
  }
}