> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Create a new metric version

> Snapshot the supplied metric definition as a new version. By default the version is created as a draft (`deployed: false`); set `deploy_immediately: true` to also make it the live version in the same transaction.



## OpenAPI

````yaml https://raw.githubusercontent.com/honeyhiveai/honeyhive-openapi/main/openapi.yaml post /v1/metrics/{metric_id}/versions
openapi: 3.1.0
info:
  title: HoneyHive Data Plane API
  license:
    name: MIT
    url: https://opensource.org/licenses/MIT
  version: 1.2.1
servers:
  - url: https://api.honeyhive.ai
security:
  - BearerAuth: []
tags:
  - name: Charts
    description: >
      Define and manage saved charts. Charts are visualizations that aggregate
      metrics over time with bucketing, filters, and groupings.
  - name: Configurations
    description: >
      Manage prompt configurations, i.e. model parameters, message templates,
      and response settings that can be versioned and deployed without code
      changes.
  - name: Datapoints
    description: >
      Manage individual records inside datasets, including batch creation and
      mapping to source events.
  - name: Datasets
    description: >
      Curate collections of datapoints used as test sets for evaluations and
      experiments.
  - name: Events
    description: >
      Read and write trace events. Events are the spans that capture every step
      of an AI application's execution.
  - name: Experiments
    description: >
      Run, retrieve, and compare evaluation runs to measure how prompt or
      configuration changes affect agent performance.
  - name: Metric Versions
    description: >
      Snapshot, list, and deploy versions of a metric's definition so changes
      can be reviewed and rolled back without losing history.
  - name: Metrics
    description: >
      Define and run evaluators, i.e. automated quality checks that score traces
      against criteria like accuracy, safety, or correctness.
  - name: Queues
    description: >
      Manage annotation queues for human review of traces, turning expert
      feedback into labeled datasets.
  - name: Sessions
    description: >
      Group related trace events into sessions, the top-level container for a
      multi-step or multi-service AI interaction.
paths:
  /v1/metrics/{metric_id}/versions:
    post:
      tags:
        - Metric Versions
      summary: Create a new metric version
      description: >-
        Snapshot the supplied metric definition as a new version. By default the
        version is created as a draft (`deployed: false`); set
        `deploy_immediately: true` to also make it the live version in the same
        transaction.
      operationId: createMetricVersion
      parameters:
        - in: path
          name: metric_id
          required: true
          schema:
            type: string
          description: The unique identifier of the metric to version
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateMetricVersionRequest'
      responses:
        '200':
          description: Metric version created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreateMetricVersionResponse'
        '400':
          description: >-
            Invalid `content` payload. Fails cross-field validation (e.g. an
            `LLM` metric without `model_provider`/`model_name`, or a `COMPOSITE`
            metric without `child_metrics`).
        '404':
          description: No metric with the given `metric_id` exists in the caller's scope.
components:
  schemas:
    CreateMetricVersionRequest:
      type: object
      properties:
        message:
          type: string
        content:
          $ref: '#/components/schemas/MetricVersionContentRequest'
        deploy_immediately:
          type: boolean
      required:
        - message
        - content
      additionalProperties: false
      description: Request body for POST /v1/metrics/{metric_id}/versions
    CreateMetricVersionResponse:
      type: object
      properties:
        success:
          type: boolean
          enum:
            - true
        data:
          $ref: '#/components/schemas/MetricVersion'
      required:
        - success
        - data
      additionalProperties: false
      description: Response for POST /v1/metrics/{metric_id}/versions
    MetricVersionContentRequest:
      type: object
      properties:
        name:
          type: string
          maxLength: 200
        type:
          type: string
          enum:
            - PYTHON
            - LLM
            - HUMAN
            - COMPOSITE
        criteria:
          type: string
          minLength: 1
        description:
          type: string
          default: ''
          description: Free-form description of the metric. Defaults to an empty string.
        return_type:
          type: string
          enum:
            - float
            - boolean
            - string
            - categorical
          default: float
          description: Return type of the metric. Defaults to `float`.
        enabled_in_prod:
          type: boolean
          default: false
          description: >-
            Whether this version should run against production traffic. Defaults
            to `false` for non-HUMAN metrics and `true` for HUMAN metrics.
        needs_ground_truth:
          type: boolean
          default: false
          description: >-
            Whether this metric requires ground-truth labels to evaluate.
            Defaults to `false`.
        sampling_percentage:
          type: number
          minimum: 0
          maximum: 100
          default: 10
          description: >-
            Percentage of events the metric should run against, 0–100. Defaults
            to `10`.
        model_provider:
          type:
            - string
            - 'null'
        model_name:
          type:
            - string
            - 'null'
        scale:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
        threshold:
          type:
            - object
            - 'null'
          properties:
            min:
              type: number
            max:
              type: number
            pass_when:
              anyOf:
                - type: boolean
                - type: number
            passing_categories:
              type: array
              items:
                type: string
                maxLength: 200
              minItems: 1
          additionalProperties: false
        categories:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/MetricVersionContentRequestCategoriesItem'
          minItems: 1
        child_metrics:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/MetricVersionContentRequestChildMetricsItem'
          minItems: 1
        filters:
          $ref: '#/components/schemas/MetricVersionContentRequestFilters'
      required:
        - name
        - type
        - criteria
      additionalProperties: false
      description: >-
        Metric definition snapshot accepted by POST
        /v1/metrics/{metric_id}/versions.

        Six fields are optional and fall back to server-side defaults when
        omitted:

        - `description` → `""`

        - `return_type` → `"float"`

        - `enabled_in_prod` → `true` for HUMAN metrics, `false` otherwise

        - `needs_ground_truth` → `false`

        - `sampling_percentage` → `10`

        - `filters` → `{ "filterArray": [] }`
    MetricVersion:
      type: object
      properties:
        name:
          type: string
        full_sha:
          type: string
        message:
          type: string
        date:
          type: string
          format: date-time
        deployed:
          type: boolean
        content:
          $ref: '#/components/schemas/MetricVersionContent'
      required:
        - name
        - full_sha
        - message
        - date
        - deployed
        - content
      additionalProperties: false
      description: A versioned snapshot of a metric definition.
    MetricVersionContentRequestCategoriesItem:
      type: object
      properties:
        category:
          type: string
          maxLength: 200
        score:
          type:
            - number
            - 'null'
      required:
        - category
        - score
      additionalProperties: false
    MetricVersionContentRequestChildMetricsItem:
      type: object
      properties:
        id:
          type: string
          minLength: 1
        name:
          type: string
          maxLength: 200
        weight:
          type: number
        scale:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
      required:
        - name
        - weight
      additionalProperties: false
    MetricVersionContentRequestFilters:
      type: object
      properties:
        filterArray:
          $ref: '#/components/schemas/FiltersArray'
      default:
        filterArray: []
      required:
        - filterArray
      additionalProperties: false
      description: >-
        ETL filter narrowing which events this metric applies to. Defaults to `{
        filterArray: [] }` (no filtering).
    MetricVersionContent:
      type: object
      properties:
        name:
          type: string
          maxLength: 200
        type:
          type: string
          enum:
            - PYTHON
            - LLM
            - HUMAN
            - COMPOSITE
        criteria:
          type: string
          minLength: 1
        description:
          type:
            - string
            - 'null'
        return_type:
          type: string
          enum:
            - float
            - boolean
            - string
            - categorical
        enabled_in_prod:
          type: boolean
        needs_ground_truth:
          type: boolean
        sampling_percentage:
          type: number
          minimum: 0
          maximum: 100
        model_provider:
          type:
            - string
            - 'null'
        model_name:
          type:
            - string
            - 'null'
        scale:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
        threshold:
          type:
            - object
            - 'null'
          properties:
            min:
              type: number
            max:
              type: number
            pass_when:
              anyOf:
                - type: boolean
                - type: number
            passing_categories:
              type: array
              items:
                type: string
                maxLength: 200
              minItems: 1
          additionalProperties: false
        categories:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/MetricVersionContentCategoriesItem'
          minItems: 1
        child_metrics:
          type:
            - array
            - 'null'
          items:
            $ref: '#/components/schemas/MetricVersionContentChildMetricsItem'
          minItems: 1
        filters:
          $ref: '#/components/schemas/MetricVersionContentFilters'
      required:
        - name
        - type
        - criteria
        - description
        - return_type
        - enabled_in_prod
        - needs_ground_truth
        - sampling_percentage
        - filters
      additionalProperties: false
      description: Versioned snapshot of a metric definition.
    FiltersArray:
      type: array
      items:
        $ref: '#/components/schemas/SingleFilter'
    MetricVersionContentCategoriesItem:
      type: object
      properties:
        category:
          type: string
          maxLength: 200
        score:
          type:
            - number
            - 'null'
      required:
        - category
        - score
      additionalProperties: false
    MetricVersionContentChildMetricsItem:
      type: object
      properties:
        id:
          type: string
          minLength: 1
        name:
          type: string
          maxLength: 200
        weight:
          type: number
        scale:
          type:
            - integer
            - 'null'
          exclusiveMinimum: 0
      required:
        - name
        - weight
      additionalProperties: false
    MetricVersionContentFilters:
      type: object
      properties:
        filterArray:
          $ref: '#/components/schemas/FiltersArray'
      required:
        - filterArray
      additionalProperties: false
    SingleFilter:
      type: object
      properties:
        field:
          type: string
        operator:
          type: string
          enum:
            - exists
            - not exists
            - is
            - is not
            - contains
            - not contains
            - greater than
            - less than
            - after
            - before
        value:
          anyOf:
            - type: string
            - type: number
            - type: boolean
            - type: 'null'
        type:
          type: string
          enum:
            - string
            - number
            - boolean
            - datetime
      required:
        - field
        - operator
        - value
        - type
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````