{
  "$defs": {
    "MetricPointIn": {
      "additionalProperties": false,
      "description": "One metric point written through the API (``step`` null = a scalar, newest wins).",
      "examples": [
        {
          "key": "revenue_lift",
          "labels": {
            "region": "north"
          },
          "value": 0.042
        },
        {
          "key": "loss",
          "step": 400,
          "value": 1.23
        }
      ],
      "properties": {
        "key": {
          "pattern": "^[a-z][a-z0-9_]{0,63}$",
          "title": "Key",
          "type": "string"
        },
        "labels": {
          "maxProperties": 8,
          "patternProperties": {
            "^[a-z][a-z0-9_]{0,31}$": {
              "pattern": "^[A-Za-z0-9_.\\-]{1,63}$",
              "type": "string"
            }
          },
          "title": "Labels",
          "type": "object"
        },
        "step": {
          "anyOf": [
            {
              "minimum": 0,
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Step"
        },
        "ts": {
          "anyOf": [
            {
              "format": "date-time",
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Defaults to the time of the request",
          "title": "Ts"
        },
        "value": {
          "title": "Value",
          "type": "number"
        }
      },
      "required": [
        "key",
        "value"
      ],
      "title": "MetricPointIn",
      "type": "object"
    }
  },
  "$id": "https://schemas.mapi.dev/v1/api-MetricsWrite.json",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "additionalProperties": false,
  "description": "``POST /v1/runs/{run_id}/metrics``: log metric points to a run (any state).",
  "examples": [
    {
      "metrics": [
        {
          "key": "revenue_lift",
          "value": 0.042
        },
        {
          "key": "loss",
          "step": 400,
          "value": 1.23
        }
      ]
    }
  ],
  "properties": {
    "metrics": {
      "items": {
        "$ref": "#/$defs/MetricPointIn"
      },
      "maxItems": 1000,
      "minItems": 1,
      "title": "Metrics",
      "type": "array"
    }
  },
  "required": [
    "metrics"
  ],
  "title": "MetricsWrite",
  "type": "object",
  "x-mapi-contract-version": "0.2"
}
