{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/roark/json-schema/roark-update-metric-definition-input-schema.json",
  "title": "UpdateMetricDefinitionInput",
  "description": "Editable subset of a metric definition. Every update creates a new immutable version. Immutable fields (slug, scope, outputType, calcType, …) are rejected with a 400.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/roark-metric-api-openapi.yml#/components/schemas/UpdateMetricDefinitionInput",
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100,
      "description": "New name (only for metrics whose name is editable)"
    },
    "llmPrompt": {
      "type": "string",
      "maxLength": 20000,
      "description": "New LLM prompt (only for LLM_JUDGE metrics whose prompt is editable)"
    },
    "scaleMin": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "New scale minimum (SCALE output only)"
    },
    "scaleMax": {
      "type": "integer",
      "minimum": 0,
      "maximum": 100,
      "description": "New scale maximum (SCALE output only)"
    },
    "scaleLabels": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "rangeMin": {
            "type": "number",
            "description": "Minimum value for this label range"
          },
          "rangeMax": {
            "type": "number",
            "description": "Maximum value for this label range"
          },
          "label": {
            "type": "string",
            "description": "Label for this range"
          },
          "description": {
            "type": "string",
            "description": "Description of what this range means"
          },
          "displayOrder": {
            "type": "integer",
            "description": "Display order of this label"
          },
          "colorHex": {
            "type": "string",
            "description": "Hex color code for this label (e.g. \"#FF0000\")"
          }
        },
        "required": [
          "rangeMin",
          "rangeMax",
          "label",
          "displayOrder"
        ]
      },
      "description": "Replacement set of scale-range labels (SCALE output only)"
    },
    "booleanTrueLabel": {
      "type": "string",
      "description": "New label for the true case (BOOLEAN output only)"
    },
    "booleanFalseLabel": {
      "type": "string",
      "description": "New label for the false case (BOOLEAN output only)"
    },
    "classificationOptions": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "label": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "displayOrder": {
            "type": "integer"
          }
        },
        "required": [
          "label",
          "description",
          "displayOrder"
        ],
        "description": "Option for classification metrics."
      },
      "minItems": 1,
      "description": "Replacement set of classification options (CLASSIFICATION output only)"
    },
    "maxClassifications": {
      "type": "integer",
      "minimum": 1,
      "description": "New maximum number of classifications (CLASSIFICATION output only)"
    },
    "toolDefinitionIds": {
      "type": "array",
      "items": {
        "type": "string",
        "format": "uuid"
      },
      "description": "Replacement set of scoped tool-definition ids (only for metrics whose tool scoping is editable)"
    },
    "supportedContexts": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "CALL",
          "SEGMENT",
          "TURN"
        ]
      },
      "minItems": 1,
      "description": "Replacement set of supported contexts. Omit to leave unchanged. Scope and participantRole cannot change after create, so moving to SEGMENT or TURN grading only works on a PER_PARTICIPANT metric (see create)."
    },
    "formula": {
      "type": "string",
      "minLength": 1,
      "maxLength": 500,
      "description": "New formula expression (FORMULA only). Pass `sources` alongside if the referenced metrics change."
    },
    "sources": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "sourceMetricDefinitionId": {
            "type": "string",
            "format": "uuid",
            "description": "ID of a metric referenced in the formula"
          },
          "sourceVariantId": {
            "type": "string",
            "format": "uuid",
            "description": "Variant of the source metric to use"
          }
        },
        "required": [
          "sourceMetricDefinitionId"
        ]
      },
      "description": "Replacement formula sources, required when `formula` changes the referenced metrics (FORMULA only)."
    },
    "httpRequest": {
      "$ref": "#/$defs/HttpRequestMetricConfig",
      "description": "Replacement request (HTTP_REQUEST only). Send the whole request; omitted headers are removed."
    },
    "changeReason": {
      "type": "string",
      "description": "Optional free-text audit note recorded on the new version."
    },
    "slug": {},
    "metricId": {},
    "source": {},
    "organizationId": {},
    "projectId": {},
    "outputType": {},
    "scope": {},
    "participantRole": {},
    "calcType": {},
    "supportsMultipleVariants": {},
    "analysisPackageId": {}
  },
  "$defs": {
    "HttpRequestMetricConfig": {
      "type": "object",
      "properties": {
        "url": {
          "type": "string",
          "minLength": 1,
          "maxLength": 2048,
          "description": "Public http(s) URL. May contain {{path}} placeholders into the request payload, which are URL-encoded."
        },
        "method": {
          "type": "string",
          "enum": [
            "GET",
            "POST"
          ],
          "default": "POST",
          "description": "GET or POST (default POST). A GET request has no body."
        },
        "headers": {
          "type": "object",
          "propertyNames": {
            "type": "string",
            "minLength": 1,
            "maxLength": 200
          },
          "additionalProperties": {
            "type": "string",
            "maxLength": 4000
          },
          "description": "Request headers, for example your own Authorization header. Values may contain placeholders."
        },
        "body": {
          "type": [
            "string",
            "null"
          ],
          "minLength": 1,
          "maxLength": 20000,
          "description": "A JSON template with {{path}} placeholders into the request payload, such as {\"cardId\": \"{{call.properties.cardId}}\"}. Omit or pass null to send the default payload."
        }
      },
      "required": [
        "url"
      ],
      "title": "HTTP request metric request"
    }
  }
}