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

# Update a metric definition

> Update the editable subset of a custom metric definition, addressed by its UUID or its stable `slug`. Only the supplied fields are changed; omitted fields are left unchanged. Every update creates a new immutable version; the response carries the advanced `versionId`. System metrics and immutable fields (scope, outputType, calcType, …) are rejected. Which fields are editable depends on the metric (e.g. derived metrics only allow `name`).



## OpenAPI

````yaml /api-reference/openapi.documented.json put /v1/metric/definitions/{idOrSlug}
openapi: 3.1.0
info:
  title: Roark Analytics API
  description: >-
    The Roark Analytics API gives you access to the same API that powers the
    award winning Roark Analytics platform.
  version: 1.0.0
servers:
  - description: Production
    url: https://api.roark.ai
security:
  - Bearer: []
tags:
  - name: Agent
  - name: Agent Endpoint
  - name: Call
  - name: Chat
  - name: Metric
  - name: Metric Policy
  - name: Metric Collection Job
  - name: Simulation Persona
  - name: Simulation Scenario
  - name: Simulation Run Plan
  - name: Simulation Run Plan Job
  - name: Simulation Job
  - name: HTTP Request Definition
  - name: Webhook
  - name: Issue
  - name: Knowledge Base
  - name: Call Analysis
  - name: Health
paths:
  /v1/metric/definitions/{idOrSlug}:
    put:
      tags:
        - Metric
      summary: Update a metric definition
      description: >-
        Update the editable subset of a custom metric definition, addressed by
        its UUID or its stable `slug`. Only the supplied fields are changed;
        omitted fields are left unchanged. Every update creates a new immutable
        version; the response carries the advanced `versionId`. System metrics
        and immutable fields (scope, outputType, calcType, …) are rejected.
        Which fields are editable depends on the metric (e.g. derived metrics
        only allow `name`).
      operationId: putV1MetricDefinitionsByIdOrSlug
      parameters:
        - name: idOrSlug
          in: path
          required: true
          description: >-
            The metric definition's Roark ID (UUID) or its stable `slug` (e.g.
            `customer_satisfaction`).
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMetricDefinitionInput'
      responses:
        '200':
          description: >-
            The updated metric definition (with `versionId` advanced to the new
            version)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: '#/components/schemas/UpdateMetricDefinitionResponse'
                required:
                  - data
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Validation error
              example:
                type: validation
                code: invalid_parameter
                message: The request was invalid
                param: email
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Authentication error
              example:
                type: authentication
                code: unauthorized
                message: Authentication required
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Permission error
              example:
                type: forbidden
                code: permission_denied
                message: You do not have permission to access this resource
          description: Forbidden
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Not found error
              example:
                type: not_found
                code: resource_not_found
                message: The requested resource could not be found
          description: Not Found
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Rate limit error
              example:
                type: rate_limit
                code: too_many_requests
                message: Rate limit exceeded
          description: Too Many Requests
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
                description: Server error
              example:
                type: internal
                code: internal_error
                message: Internal server error
          description: Internal Server Error
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: 2000
          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.
        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).
        changeReason:
          type: string
          description: Optional free-text audit note recorded on the new version.
        slug:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        metricId:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        source:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        organizationId:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        projectId:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        outputType:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        scope:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        participantRole:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        calcType:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        supportsMultipleVariants:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
        analysisPackageId:
          path: /v1/integrations/livekit-sdk/chunk-upload-url
      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.
    UpdateMetricDefinitionResponse:
      oneOf:
        - $ref: '#/components/schemas/LlmJudgeMetricResponse'
        - $ref: '#/components/schemas/FormulaMetricResponse'
        - $ref: '#/components/schemas/PatternMetricResponse'
        - $ref: '#/components/schemas/ThresholdMetricResponse'
      discriminator:
        propertyName: calculationType
        mapping:
          LLM_JUDGE:
            $ref: '#/components/schemas/LlmJudgeMetricResponse'
          FORMULA:
            $ref: '#/components/schemas/FormulaMetricResponse'
          PATTERN:
            $ref: '#/components/schemas/PatternMetricResponse'
          THRESHOLD:
            $ref: '#/components/schemas/ThresholdMetricResponse'
      description: >-
        The updated metric definition. The variant is selected by
        `calculationType`.
    ErrorResponse:
      type: object
      properties:
        type:
          type: string
          enum:
            - validation
            - authentication
            - forbidden
            - not_found
            - conflict
            - rate_limit
            - internal
          description: The error type category
          examples:
            - validation
            - authentication
        code:
          type: string
          description: Machine-readable error code identifier
          examples:
            - invalid_parameter
            - missing_required_field
            - unauthorized
        message:
          type: string
          description: Human-readable error message
          examples:
            - The request was invalid
            - Authentication required
        param:
          type: string
          description: The parameter that caused the error (if applicable)
          examples:
            - email
            - user_id
        details:
          description: Additional error context information
      required:
        - type
        - code
        - message
    LlmJudgeMetricResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the metric definition
        slug:
          type: string
          description: Stable metric slug (e.g. "call_reason", "customer_satisfaction")
        metricId:
          type: string
          description: >-
            Alias of `slug` retained for backwards compatibility. Same value as
            `slug`.
        variantId:
          type: string
          format: uuid
          description: >-
            The resolved variant this response reflects (org-scoped Default if
            the org has customized it, otherwise the system Default). Pass this
            as sourceVariantId when building a derived metric off this one to
            pin the exact config.
        versionId:
          type: string
          format: uuid
          description: >-
            The variant's current version. Immutable snapshot of the config —
            editing the metric produces a new versionId. Use it to detect config
            changes.
        name:
          type: string
          description: Name of the metric
        description:
          type: string
          description: Description of what the metric measures
        type:
          type: string
          enum:
            - COUNT
            - NUMERIC
            - BOOLEAN
            - SCALE
            - TEXT
            - CLASSIFICATION
            - OFFSET
          description: Type of value this metric produces
        scope:
          type: string
          enum:
            - GLOBAL
            - PER_PARTICIPANT
          description: Whether metric is global or per-participant
        supportedContexts:
          type: array
          items:
            type: string
            enum:
              - CALL
              - SEGMENT
              - TURN
          description: Which levels this metric can produce values at
        unit:
          type: object
          properties:
            name:
              type: string
              description: Name of the unit
            symbol:
              type:
                - string
                - 'null'
              description: Symbol for the unit
          required:
            - name
            - symbol
          description: Unit information if applicable
        calculationType:
          type: string
          const: LLM_JUDGE
          description: Metric evaluated by an LLM against a prompt.
      required:
        - id
        - slug
        - metricId
        - variantId
        - versionId
        - name
        - description
        - type
        - scope
        - supportedContexts
        - calculationType
      title: LLM judge metric
    FormulaMetricResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the metric definition
        slug:
          type: string
          description: Stable metric slug (e.g. "call_reason", "customer_satisfaction")
        metricId:
          type: string
          description: >-
            Alias of `slug` retained for backwards compatibility. Same value as
            `slug`.
        variantId:
          type: string
          format: uuid
          description: >-
            The resolved variant this response reflects (org-scoped Default if
            the org has customized it, otherwise the system Default). Pass this
            as sourceVariantId when building a derived metric off this one to
            pin the exact config.
        versionId:
          type: string
          format: uuid
          description: >-
            The variant's current version. Immutable snapshot of the config —
            editing the metric produces a new versionId. Use it to detect config
            changes.
        name:
          type: string
          description: Name of the metric
        description:
          type: string
          description: Description of what the metric measures
        type:
          type: string
          enum:
            - COUNT
            - NUMERIC
            - BOOLEAN
            - SCALE
            - TEXT
            - CLASSIFICATION
            - OFFSET
          description: Type of value this metric produces
        scope:
          type: string
          enum:
            - GLOBAL
            - PER_PARTICIPANT
          description: Whether metric is global or per-participant
        supportedContexts:
          type: array
          items:
            type: string
            enum:
              - CALL
              - SEGMENT
              - TURN
          description: Which levels this metric can produce values at
        unit:
          type: object
          properties:
            name:
              type: string
              description: Name of the unit
            symbol:
              type:
                - string
                - 'null'
              description: Symbol for the unit
          required:
            - name
            - symbol
          description: Unit information if applicable
        calculationType:
          type: string
          const: FORMULA
          description: Metric computed by evaluating an expression over other metrics.
        formula:
          $ref: '#/components/schemas/FormulaMetricDetails'
          description: Formula configuration.
      required:
        - id
        - slug
        - metricId
        - variantId
        - versionId
        - name
        - description
        - type
        - scope
        - supportedContexts
        - calculationType
        - formula
      title: Formula metric
    PatternMetricResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the metric definition
        slug:
          type: string
          description: Stable metric slug (e.g. "call_reason", "customer_satisfaction")
        metricId:
          type: string
          description: >-
            Alias of `slug` retained for backwards compatibility. Same value as
            `slug`.
        variantId:
          type: string
          format: uuid
          description: >-
            The resolved variant this response reflects (org-scoped Default if
            the org has customized it, otherwise the system Default). Pass this
            as sourceVariantId when building a derived metric off this one to
            pin the exact config.
        versionId:
          type: string
          format: uuid
          description: >-
            The variant's current version. Immutable snapshot of the config —
            editing the metric produces a new versionId. Use it to detect config
            changes.
        name:
          type: string
          description: Name of the metric
        description:
          type: string
          description: Description of what the metric measures
        type:
          type: string
          enum:
            - COUNT
            - NUMERIC
            - BOOLEAN
            - SCALE
            - TEXT
            - CLASSIFICATION
            - OFFSET
          description: Type of value this metric produces
        scope:
          type: string
          enum:
            - GLOBAL
            - PER_PARTICIPANT
          description: Whether metric is global or per-participant
        supportedContexts:
          type: array
          items:
            type: string
            enum:
              - CALL
              - SEGMENT
              - TURN
          description: Which levels this metric can produce values at
        unit:
          type: object
          properties:
            name:
              type: string
              description: Name of the unit
            symbol:
              type:
                - string
                - 'null'
              description: Symbol for the unit
          required:
            - name
            - symbol
          description: Unit information if applicable
        calculationType:
          type: string
          const: PATTERN
          description: >-
            Metric detecting a trigger condition followed by an outcome within a
            window.
        pattern:
          $ref: '#/components/schemas/PatternMetricDetails'
          description: Pattern configuration.
      required:
        - id
        - slug
        - metricId
        - variantId
        - versionId
        - name
        - description
        - type
        - scope
        - supportedContexts
        - calculationType
        - pattern
      title: Pattern metric
    ThresholdMetricResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the metric definition
        slug:
          type: string
          description: Stable metric slug (e.g. "call_reason", "customer_satisfaction")
        metricId:
          type: string
          description: >-
            Alias of `slug` retained for backwards compatibility. Same value as
            `slug`.
        variantId:
          type: string
          format: uuid
          description: >-
            The resolved variant this response reflects (org-scoped Default if
            the org has customized it, otherwise the system Default). Pass this
            as sourceVariantId when building a derived metric off this one to
            pin the exact config.
        versionId:
          type: string
          format: uuid
          description: >-
            The variant's current version. Immutable snapshot of the config —
            editing the metric produces a new versionId. Use it to detect config
            changes.
        name:
          type: string
          description: Name of the metric
        description:
          type: string
          description: Description of what the metric measures
        type:
          type: string
          enum:
            - COUNT
            - NUMERIC
            - BOOLEAN
            - SCALE
            - TEXT
            - CLASSIFICATION
            - OFFSET
          description: Type of value this metric produces
        scope:
          type: string
          enum:
            - GLOBAL
            - PER_PARTICIPANT
          description: Whether metric is global or per-participant
        supportedContexts:
          type: array
          items:
            type: string
            enum:
              - CALL
              - SEGMENT
              - TURN
          description: Which levels this metric can produce values at
        unit:
          type: object
          properties:
            name:
              type: string
              description: Name of the unit
            symbol:
              type:
                - string
                - 'null'
              description: Symbol for the unit
          required:
            - name
            - symbol
          description: Unit information if applicable
        calculationType:
          type: string
          const: THRESHOLD
          description: >-
            Boolean metric derived by comparing a source metric against a
            threshold.
        threshold:
          $ref: '#/components/schemas/ThresholdMetricDetails'
          description: Threshold configuration.
      required:
        - id
        - slug
        - metricId
        - variantId
        - versionId
        - name
        - description
        - type
        - scope
        - supportedContexts
        - calculationType
      title: Threshold metric
    FormulaMetricDetails:
      type: object
      properties:
        expression:
          type: string
        sources:
          type: array
          items:
            type: object
            properties:
              sourceMetricDefinitionId:
                type: string
                format: uuid
              sourceVariantId:
                type:
                  - string
                  - 'null'
                format: uuid
            required:
              - sourceMetricDefinitionId
              - sourceVariantId
      required:
        - expression
        - sources
    PatternMetricDetails:
      type: object
      properties:
        operation:
          type: string
          enum:
            - PATTERN_EXISTS
            - PATTERN_COUNT
            - OUTCOME_AGGREGATE
        windowMode:
          type:
            - string
            - 'null'
        triggerCombinator:
          type:
            - string
            - 'null'
          enum:
            - AND
            - OR
        triggers:
          type: array
          items:
            type: object
            properties:
              sourceMetricDefinitionId:
                type: string
                format: uuid
              operator:
                type: string
                enum:
                  - GREATER_THAN
                  - GREATER_THAN_OR_EQUALS
                  - LESS_THAN
                  - LESS_THAN_OR_EQUALS
                  - EQUALS
                  - NOT_EQUALS
              thresholdValue:
                type: string
              sourceParticipantRole:
                type:
                  - string
                  - 'null'
                enum:
                  - AGENT
                  - CUSTOMER
                  - SIMULATED_CUSTOMER
                  - BACKGROUND_SPEAKER
              sourceVariantId:
                type:
                  - string
                  - 'null'
                format: uuid
            required:
              - sourceMetricDefinitionId
              - operator
              - thresholdValue
              - sourceParticipantRole
              - sourceVariantId
        outcome:
          type:
            - object
            - 'null'
          properties:
            sourceMetricDefinitionId:
              type: string
              format: uuid
            operator:
              type: string
              enum:
                - GREATER_THAN
                - GREATER_THAN_OR_EQUALS
                - LESS_THAN
                - LESS_THAN_OR_EQUALS
                - EQUALS
                - NOT_EQUALS
            thresholdValue:
              type: string
            sourceParticipantRole:
              type:
                - string
                - 'null'
              enum:
                - AGENT
                - CUSTOMER
                - SIMULATED_CUSTOMER
                - BACKGROUND_SPEAKER
            sourceVariantId:
              type:
                - string
                - 'null'
              format: uuid
            windowBefore:
              type:
                - integer
                - 'null'
            windowAfter:
              type:
                - integer
                - 'null'
          required:
            - sourceMetricDefinitionId
            - operator
            - thresholdValue
            - sourceParticipantRole
            - sourceVariantId
            - windowBefore
            - windowAfter
      required:
        - operation
        - windowMode
        - triggerCombinator
        - triggers
        - outcome
    ThresholdMetricDetails:
      type: object
      properties:
        sourceMetricDefinitionId:
          type: string
          format: uuid
        operator:
          type: string
          enum:
            - GREATER_THAN
            - GREATER_THAN_OR_EQUALS
            - LESS_THAN
            - LESS_THAN_OR_EQUALS
            - EQUALS
            - NOT_EQUALS
        thresholdValue:
          type: string
        aggregationMode:
          type: string
          enum:
            - EACH
            - COUNT
            - AVERAGE
            - MIN
            - MAX
            - MEDIAN
            - P95
            - P99
            - SUM
        countThreshold:
          type:
            - integer
            - 'null'
        sourceParticipantRole:
          type:
            - string
            - 'null'
          enum:
            - AGENT
            - CUSTOMER
            - SIMULATED_CUSTOMER
            - BACKGROUND_SPEAKER
        sourceVariantId:
          type:
            - string
            - 'null'
          format: uuid
      required:
        - sourceMetricDefinitionId
        - operator
        - thresholdValue
        - aggregationMode
        - countThreshold
        - sourceParticipantRole
        - sourceVariantId
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer
      bearerFormat: JWT

````