{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/roark/json-schema/roark-analytics-result-schema.json",
  "title": "AnalyticsResult",
  "description": "One series per measure (or per breakdown value / comparison group). `value` is the aggregate over the whole window; `buckets` hold the per-interval values.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/roark-analytics-api-openapi.yml#/components/schemas/AnalyticsResult",
  "type": "object",
  "properties": {
    "from": {
      "type": "string"
    },
    "to": {
      "type": "string"
    },
    "interval": {
      "type": "string",
      "enum": [
        "HOUR",
        "DAY",
        "WEEK",
        "MONTH"
      ]
    },
    "timezone": {
      "type": "string"
    },
    "series": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "measureIndex": {
            "type": "integer"
          },
          "type": {
            "type": "string",
            "enum": [
              "METRIC",
              "CONVERSATION",
              "UPTIME"
            ]
          },
          "metric": {
            "type": [
              "string",
              "null"
            ]
          },
          "aggregation": {
            "type": "string",
            "enum": [
              "COUNT",
              "AVG",
              "MIN",
              "MAX",
              "SUM",
              "MEDIAN",
              "PERCENTILE",
              "PASS_RATE"
            ]
          },
          "breakdownValue": {
            "type": [
              "string",
              "null"
            ]
          },
          "comparisonGroup": {
            "type": [
              "string",
              "null"
            ]
          },
          "value": {
            "type": "number"
          },
          "sampleSize": {
            "type": [
              "number",
              "null"
            ]
          },
          "comparisonValue": {
            "type": [
              "number",
              "null"
            ]
          },
          "percentageOfBaseline": {
            "type": [
              "number",
              "null"
            ]
          },
          "buckets": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string"
                },
                "value": {
                  "type": "number"
                },
                "passed": {
                  "type": "number"
                },
                "sampleSize": {
                  "type": "number"
                },
                "comparisonDate": {
                  "type": "string"
                },
                "comparisonValue": {
                  "type": "number"
                },
                "percentageOfBaseline": {
                  "type": "number"
                }
              },
              "required": [
                "date",
                "value"
              ]
            }
          }
        },
        "required": [
          "measureIndex",
          "type",
          "metric",
          "aggregation",
          "breakdownValue",
          "comparisonGroup",
          "value",
          "sampleSize",
          "comparisonValue",
          "percentageOfBaseline",
          "buckets"
        ]
      }
    },
    "omittedSeries": {
      "type": "integer"
    }
  },
  "required": [
    "from",
    "to",
    "interval",
    "timezone",
    "series",
    "omittedSeries"
  ]
}