{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cekura-ai/json-schema/cekura-ai-metric-list-serializer-v2-schema.json",
  "title": "MetricListSerializerV2",
  "description": "Read-only inputs and dependents of a metric, resolved once per project.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cekura-ai-metrics-api-openapi.yml#/components/schemas/MetricListSerializerV2",
  "type": "object",
  "properties": {
    "id": {
      "type": "integer",
      "readOnly": true
    },
    "slug": {
      "type": [
        "string",
        "null"
      ],
      "description": "URL-friendly unique identifier in snake_case format. Example: \"customer_satisfaction_1562\"",
      "maxLength": 255
    },
    "project": {
      "type": [
        "integer",
        "null"
      ]
    },
    "agents": {
      "type": "array",
      "items": {
        "type": [
          "integer",
          "null"
        ]
      }
    },
    "agent_names": {
      "type": "string",
      "readOnly": true
    },
    "name": {
      "type": "string",
      "description": "\nName of the metric.\nExample: `\"Customer Satisfaction\"` or `\"Appointment Booking\"`\n        ",
      "maxLength": 255
    },
    "description": {
      "type": "string",
      "description": "\nDescription of what the metric measures.\nExample: `\"Measures how satisfied customers are with the service provided\"`\n        "
    },
    "function_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "\nPredefined function name\nExample: `\"get_latency\"` or `\"check_critical_deviations\"`\n",
      "maxLength": 255
    },
    "type": {
      "enum": [
        "basic",
        "custom_prompt",
        "custom_code",
        "llm_judge"
      ],
      "type": "string",
      "x-spec-enum-id": "b44700c0a6443b40",
      "description": "\nType of metric\n\n\n* `basic` - Basic (Deprecated in favor of LLM Judge)\n* `custom_prompt` - Custom Prompt ( Deprecated in favor of LLM Judge)\n* `custom_code` - Custom Code\n* `llm_judge` - LLM Judge"
    },
    "eval_type": {
      "enum": [
        "binary",
        "continuous_qualitative",
        "numeric",
        "enum"
      ],
      "type": "string",
      "description": "* `binary` - Binary\n* `continuous_qualitative` - Continuous Qualitative\n* `numeric` - Numeric\n* `enum` - Enum",
      "x-spec-enum-id": "b40eac6824409cc2"
    },
    "enum_values": {
      "description": "\nList of possible enum values for enum type metrics.\nExample: `[\"satisfied\", \"unsatisfied\"]`\n"
    },
    "audio_enabled": {
      "type": "boolean",
      "description": "\nWhether this metric requires audio analysis.\nExample: `true` or `false`\n        "
    },
    "observability_enabled": {
      "type": "boolean",
      "description": "\nEnable this metric for observability.\nExample: `true` or `false`\n        "
    },
    "simulation_enabled": {
      "type": "boolean",
      "description": "\nEnable this metric for simulations.\nExample: `true` or `false`\n        "
    },
    "sampling_enabled": {
      "type": "boolean",
      "description": "Enable sampling for this metric using its sample_rate, or the project sample rate when unset"
    },
    "sample_rate": {
      "type": [
        "number",
        "null"
      ],
      "format": "double",
      "maximum": 1.0,
      "minimum": 0.0,
      "description": "Sampling rate for this metric (0.0 to 1.0). Overrides the project sample rate when set."
    },
    "prompt": {
      "type": "string",
      "description": "\nEvaluation prompt for the metric.\nExample: `\"Evaluate customer satisfaction based on conversation\"`\n"
    },
    "display_order": {
      "type": "integer",
      "maximum": 2147483647,
      "minimum": -2147483648,
      "description": "\nDisplay order for the metric.\nExample: `1`\n"
    },
    "evaluation_trigger": {
      "enum": [
        "always",
        "automatic",
        "custom"
      ],
      "type": "string",
      "description": "* `always` - Always\n* `automatic` - Automatic\n* `custom` - Custom",
      "x-spec-enum-id": "ecd3c02e0e393ef5"
    },
    "trigger_type": {
      "enum": [
        "llm_judge",
        "custom_code"
      ],
      "type": "string",
      "description": "* `llm_judge` - LLM Judge\n* `custom_code` - Custom Code",
      "x-spec-enum-id": "2adad4b8df61914f"
    },
    "evaluation_trigger_prompt": {
      "type": "string",
      "description": "\nEvaluation trigger prompt for the metric.\nExample: `\"Evaluate metric only if call ended reason is main-agent-ended-call\"`\n"
    },
    "evaluation_trigger_custom_code": {
      "type": "string",
      "description": "\nPython custom code to determine metric relevance. Code should set _result (bool) and _explanation (str).\nExample:\n```python\n_result = True\n_explanation = \"Metric is relevant\"\nif \"call_end_reason\" in data and data[\"call_end_reason\"] == \"customer-hung-up\":\n    _result = False\n    _explanation = \"Customer hung up, metric not applicable\"\n```\n"
    },
    "priority_assignment_prompt": {
      "type": "string",
      "description": "\nPriority assignment prompt for the metric.\n"
    },
    "vocera_defined_metric_code": {
      "type": "string",
      "description": "\nVocera defined metric code for the metric.\nExample: `\"7fd534f5\"`\n",
      "maxLength": 255
    },
    "configuration": {
      "description": "\nCustom configuration parameters for specific metrics if metric supports it.\nExample:\n- For Infrastructure issues\n```json\n{\n    \"infra_issues_timeout\": 10\n}\n```\n"
    },
    "overall_score": {
      "type": "string",
      "readOnly": true
    },
    "total_score": {
      "type": "string",
      "readOnly": true
    },
    "kb_file_ids": {
      "type": "array",
      "items": {
        "type": "integer"
      },
      "description": "\nList of knowledge base file IDs for the metric.\nExample: `[123, 456]`\n"
    },
    "knowledge_base_files": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/KnowledgeBaseFile"
      },
      "readOnly": true
    },
    "scenarios": {
      "writeOnly": true,
      "description": "Either \"all\" or a list of scenario IDs to attach to this metric"
    },
    "custom_code": {
      "type": "string",
      "writeOnly": true
    },
    "metric_cost": {
      "type": "number",
      "format": "double",
      "description": "\nMetric Cost\nExample: `0.10`\n",
      "readOnly": true
    },
    "alert_type": {
      "enum": [
        "disabled",
        "normal",
        "significant_change"
      ],
      "type": "string",
      "description": "* `disabled` - Alerts Disabled\n* `normal` - Normal Alerts\n* `significant_change` - Significant Change Alerts",
      "x-spec-enum-id": "9e2661f1aeca64cf",
      "default": "disabled"
    },
    "significant_change_alert_status": {
      "enum": [
        "enabled",
        "disabled"
      ],
      "type": "string",
      "x-spec-enum-id": "6d6f4d361b4ea1fb",
      "description": "\nAlert status: enabled or disabled.\n\n\n* `enabled` - Enabled\n* `disabled` - Disabled"
    },
    "significant_change_alert_direction": {
      "enum": [
        "",
        "increase",
        "decrease"
      ],
      "type": "string",
      "x-spec-enum-id": "1e86e60ca5cfba12",
      "description": "Alert direction: increase only, decrease only, or both (empty = both).\nExample: `\"increase\"`, `\"decrease\"`, or `\"both\"`\n\n* `` - Both (Increase and Decrease)\n* `increase` - Increase Only\n* `decrease` - Decrease Only"
    },
    "window_size": {
      "type": "integer",
      "readOnly": true,
      "description": "\nWindow size for rolling statistics calculation.\nExample: `50`\n"
    },
    "std_multiplier": {
      "type": "number",
      "format": "double",
      "readOnly": true,
      "description": "\nStandard deviation multiplier for threshold calculation.\nExample: `2.0`\n"
    },
    "ewma_alpha": {
      "type": "number",
      "format": "double",
      "readOnly": true,
      "description": "\nAlpha value for exponentially weighted moving average (EWMA) calculation.\nExample: `0.1`\n"
    },
    "add_to_new_agents": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "When enabled, this metric is automatically assigned to new agents created in the project."
    },
    "alert_filters": {
      "oneOf": [
        {},
        {
          "type": "null"
        }
      ],
      "description": "Filters to apply before computing alerts (CallLogQueryFilter format)"
    },
    "slack_workspace": {
      "type": [
        "integer",
        "null"
      ],
      "description": "Slack workspace to send alerts to"
    },
    "slack_channel_id": {
      "type": [
        "string",
        "null"
      ],
      "description": "Override channel ID for this metric's alerts",
      "maxLength": 255
    },
    "uses_llm_judge": {
      "type": "string",
      "readOnly": true,
      "description": "\nWhether this metric produces an LLM-judge narrative: a `custom_code` metric whose\ncode delegates to the LLM judge internally. Computed server-side because the\n`custom_code` body is write-only and not exposed on read.\nExample: `true`\n"
    },
    "dependencies": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MetricDependencyRef"
      },
      "readOnly": true,
      "description": "Metrics whose results this metric reads, each with `source` = `declared` or `inferred`."
    },
    "dependents": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MetricDependencyRef"
      },
      "readOnly": true,
      "description": "Metrics that read this metric's result."
    }
  },
  "required": [
    "eval_type",
    "name"
  ],
  "$defs": {
    "KnowledgeBaseFile": {
      "type": "object",
      "description": "",
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true
        },
        "agent": {
          "type": "integer"
        },
        "file": {
          "type": "string",
          "format": "uri",
          "writeOnly": true,
          "description": "Knowledge base file",
          "pattern": "(?:pdf|txt|json|csv|xml|md)$"
        },
        "file_url": {
          "type": "string",
          "readOnly": true,
          "description": "URL of the Knowledge file"
        },
        "file_name": {
          "type": "string",
          "readOnly": true,
          "description": "Name of the Knowledge file"
        },
        "file_type": {
          "type": "string",
          "readOnly": true,
          "description": "MIME type of the Knowledge file"
        },
        "file_size": {
          "type": "integer",
          "readOnly": true,
          "description": "Size in bytes.\nExample: `1048576`"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "readOnly": true,
          "description": "When this record was created.\nExample: `2024-03-15T10:30:45Z`"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "readOnly": true,
          "description": "When this record was last updated.\nExample: `2024-03-15T10:35:11Z`"
        }
      },
      "required": [
        "agent",
        "file"
      ]
    },
    "MetricDependencyRef": {
      "type": "object",
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "slug": {
          "type": [
            "string",
            "null"
          ]
        },
        "source": {
          "enum": [
            "declared",
            "inferred"
          ],
          "type": "string",
          "description": "* `declared` - declared\n* `inferred` - inferred",
          "x-spec-enum-id": "d99fdefc2ee39c16"
        }
      },
      "required": [
        "id",
        "name",
        "slug",
        "source"
      ]
    }
  }
}