{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cekura-ai/json-schema/cekura-ai-widget-data-response-schema.json",
  "title": "WidgetDataResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cekura-ai-dashboards-api-openapi.yml#/components/schemas/WidgetDataResponse",
  "type": "object",
  "properties": {
    "widget_id": {
      "type": "integer"
    },
    "field_name": {
      "type": "string"
    },
    "chart_type": {
      "type": "string"
    },
    "data": {
      "type": "array",
      "description": "Chart data. Format depends on `chart_type`:\n\n**Line chart:** `[{id, timestamp, value}, ...]`\n\n**Bar chart:** `[{time_interval, value, sample_count}, ...]`\n\n**Enum daily share:** `[{time_interval, group, value, selected_calls, total_calls, evaluated_calls}, ...]`, where `value` is the selected enum value's percentage of total filtered calls.\n\n**Pie chart:** `[{label, value, percentage}, ...]`\n\nSee the [Dashboards guide](https://docs.cekura.ai/documentation/guides/dashboards#chart-output-formats) for full examples.",
      "items": {
        "type": "object"
      }
    },
    "aggregation_function": {
      "type": [
        "string",
        "null"
      ]
    },
    "time_period": {
      "type": [
        "string",
        "null"
      ]
    },
    "group_by": {
      "oneOf": [
        {},
        {
          "type": "null"
        }
      ]
    },
    "can_group_by": {
      "type": "boolean",
      "default": false
    },
    "metadata": {
      "type": "object",
      "description": "Additional metadata about the plotted data. See the [Dashboards guide](https://docs.cekura.ai/documentation/guides/dashboards#widget-data) for details.",
      "properties": {
        "display_name": {
          "type": "string",
          "description": "Human-readable name of the field"
        },
        "data_type": {
          "type": "string",
          "enum": [
            "numeric",
            "boolean",
            "string",
            "datetime",
            "dynamic",
            "percentage"
          ],
          "description": "Resolved data type of the field"
        },
        "filter_value": {
          "description": "The filter value used (e.g. metric ID), or null",
          "nullable": true
        },
        "series_dimension": {
          "type": "string",
          "enum": [
            "enum_value"
          ],
          "description": "Server-supplied series dimension for enum daily shares."
        },
        "normalization": {
          "type": "string",
          "enum": [
            "total_calls"
          ],
          "description": "Denominator used for enum daily shares."
        }
      }
    },
    "warning": {
      "allOf": [
        {
          "$ref": "#/$defs/WidgetDataWarning"
        }
      ],
      "description": "Present instead of plot data when the widget cannot be computed for the requested range, e.g. `metadata_retention` when a metadata.* widget asks for days older than the metadata retention window. `data` is then empty."
    }
  },
  "required": [
    "aggregation_function",
    "chart_type",
    "data",
    "field_name",
    "group_by",
    "metadata",
    "time_period",
    "widget_id"
  ],
  "$defs": {
    "WidgetDataWarning": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      },
      "required": [
        "code",
        "message"
      ]
    }
  }
}