{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/cekura-ai/json-schema/cekura-ai-metric-detail-serializer-v2-schema.json",
  "title": "MetricDetailSerializerV2",
  "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/MetricDetailSerializerV2",
  "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"
        ]
      }
    },
    "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        "
    },
    "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        "
    },
    "prompt": {
      "type": "string",
      "description": "\nEvaluation prompt for the metric.\nExample: `\"Evaluate customer satisfaction based on conversation\"`\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",
      "x-spec-enum-id": "2adad4b8df61914f",
      "description": "\nType of trigger evaluation: LLM judge or custom code.\nOnly used when evaluation_trigger is CUSTOM.\nExample: `\"llm_judge\"` or `\"custom_code\"`\n\n\n* `llm_judge` - LLM Judge\n* `custom_code` - Custom Code"
    },
    "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"
    },
    "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,
      "description": "The overall score for this metric across all test sets"
    },
    "total_score": {
      "type": "string",
      "readOnly": true,
      "description": "The total score for this metric"
    },
    "knowledge_base_files": {
      "type": "string",
      "readOnly": true,
      "description": "Knowledge base files associated with this metric"
    },
    "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."
    },
    "alert_enabled": {
      "type": "boolean",
      "description": "\nEnable alerts for this metric when it fails (value=false).\nOnly applicable to binary metrics (eval_type=binary).\nFor other metric types, use significant_change_alert_status instead.\nExample: `true` or `false`\n        "
    },
    "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"
    },
    "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
    },
    "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"
    },
    "function_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "\nPredefined function name\nExample: `\"get_latency\"` or `\"check_critical_deviations\"`\n",
      "maxLength": 255
    },
    "custom_code": {
      "type": "string",
      "description": "\nPython custom code for the metric.\nExample:\n```python\n_resul = True\n_explanation = None\nif  \"call_end_reason\" in data and data[\"call_end_reason\"] == \"customer_satisfaction\":\n    _result = True\n    _explanation = \"Customer expressed satisfaction with service\"\n```\n"
    },
    "vocera_defined_metric_code": {
      "type": "string",
      "description": "\nVocera defined metric code for the metric.\nExample: `\"7fd534f5\"`\n",
      "maxLength": 255
    },
    "scenarios": {
      "writeOnly": true
    },
    "reviews": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/MetricReviewDetail"
      },
      "readOnly": true,
      "description": "Reviews associated with the metric"
    },
    "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."
    },
    "pending_optimisation_proposal": {
      "oneOf": [
        {},
        {
          "type": "null"
        }
      ],
      "readOnly": true,
      "description": "Unsaved proposal from a metric-optimiser cron run. Shape: {description, evaluation_trigger, type, custom_code, score, baseline_score, cron_job_id, cron_job_name, proposed_at}."
    },
    "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": {
    "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"
      ]
    },
    "MetricReviewDetail": {
      "type": "object",
      "description": "",
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true
        },
        "test_set": {
          "allOf": [
            {
              "$ref": "#/$defs/TestSetInline"
            }
          ],
          "readOnly": true
        },
        "metric": {
          "type": "integer"
        },
        "expected_value": {
          "oneOf": [
            {},
            {
              "type": "null"
            }
          ],
          "description": "\nMetric expected value\nExample:\n- `5` or `0`\n- `one`, `two` or `three` [ enum type ]\n"
        },
        "actual_value": {
          "oneOf": [
            {},
            {
              "type": "null"
            }
          ],
          "description": "\nMetric actual value\nExample:\n- `5` or `0`\n- `one`, `two` or `three` [ enum type ]\n"
        },
        "explanation": {
          "description": "\nMetric explanation\nExample:\n```json\n[\"Agent failed to follow the opening script\", \"Missed key product information\"]\n```\n"
        },
        "feedback": {
          "type": "string",
          "description": "\nMetric feedback\nExample:\n- `\"Great Call\"`\n"
        },
        "created_at": {
          "type": "string",
          "format": "date-time",
          "readOnly": true,
          "description": "\nTimestamp when the metric review was created\nExample: `\"2021-01-01T00:00:00Z\"`\n"
        },
        "updated_at": {
          "type": "string",
          "format": "date-time",
          "readOnly": true,
          "description": "\nTimestamp when the metric review was last updated\nExample: `\"2021-01-01T00:00:00Z\"`\n"
        }
      },
      "required": [
        "metric"
      ]
    },
    "TestSetInline": {
      "type": "object",
      "description": "",
      "properties": {
        "id": {
          "type": "integer",
          "readOnly": true
        },
        "agent": {
          "type": "integer"
        },
        "name": {
          "type": "string",
          "description": "\nName of the test set\nExample: `\"Test Set 1\"`\n",
          "maxLength": 255
        },
        "transcript": {
          "type": "string",
          "description": "Full text transcript of the call.\nExample: \n```text\n[00:01] Testing Agent: Hello. \n[00:02] Main Agent: Hello, how can I help you today?\n[00:03] Testing Agent: Well, I mean, sure. What time exactly are we talking about here\n[00:04] Main Agent: 6 PM.\n[00:05] Testing Agent: Great. I'll book that for you. Just a sec.\n[00:06] Main Agent: Okay.\n```\n"
        },
        "voice_recording_url": {
          "type": "string",
          "readOnly": true
        },
        "call_end_reason": {
          "type": "string",
          "description": "Reason why the call ended.\nExample: \n- `\"customer-ended-call\"`\n- `\"agent-ended-call\"`\n",
          "maxLength": 255
        },
        "duration": {
          "type": "string",
          "readOnly": true
        },
        "source_model": {
          "enum": [
            "CallLog",
            "Run"
          ],
          "type": "string",
          "description": "* `CallLog` - Call Log\n* `Run` - Run",
          "x-spec-enum-id": "1d8f6db20c0b4cac",
          "readOnly": true
        },
        "source_id": {
          "type": "string",
          "readOnly": true
        },
        "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"
      ]
    }
  }
}