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

# Update a billable metric

> Partially update metric fields. Code and aggregation_type are immutable.



## OpenAPI

````yaml https://api.meteroid.com/api-docs/openapi.json patch /api/v1/metrics/{metric_id}
openapi: 3.1.0
info:
  title: meteroid
  description: ''
  license:
    name: LicenseRef-Proprietary
    identifier: LicenseRef-Proprietary
  version: 0.1.0
servers: []
security: []
tags:
  - name: Meteroid
    description: Meteroid API
  - name: Add-ons
  - name: Batch Jobs
  - name: Checkout Sessions
  - name: Connect
    description: Manage connected accounts (Express & Standard)
  - name: Coupons
  - name: Credit Notes
  - name: Customers
  - name: Entitlements
  - name: Events
  - name: Features
  - name: Invoices
  - name: Metrics
  - name: OAuth
    description: OAuth 2.0 token endpoints (public, client-credentials auth)
  - name: OAuth Apps
    description: Manage OAuth applications for Connect integrations
  - name: Plans
  - name: Product Families
  - name: Products
  - name: Subscriptions
  - name: Usage
paths:
  /api/v1/metrics/{metric_id}:
    patch:
      tags:
        - Metrics
      summary: Update a billable metric
      description: Partially update metric fields. Code and aggregation_type are immutable.
      operationId: update_metric
      parameters:
        - name: metric_id
          in: path
          description: Metric ID
          required: true
          schema:
            $ref: '#/components/schemas/BillableMetricId'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMetricRequest'
        required: true
      responses:
        '200':
          description: Metric updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Metric'
        '400':
          description: Bad request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '404':
          description: Metric not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RestErrorResponse'
      security:
        - bearer_auth: []
components:
  schemas:
    BillableMetricId:
      type: string
      format: MeteroidId
      examples:
        - bm_7n42DGM5Tflk9n8mt7Fhc7
    UpdateMetricRequest:
      type: object
      properties:
        description:
          type:
            - string
            - 'null'
        name:
          type:
            - string
            - 'null'
        segmentation_matrix:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/MetricSegmentationMatrix'
        unit_conversion:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/UnitConversion'
    Metric:
      type: object
      required:
        - id
        - name
        - code
        - aggregation_type
        - product_family_id
        - created_at
      properties:
        aggregation_key:
          type:
            - string
            - 'null'
        aggregation_type:
          $ref: '#/components/schemas/BillingMetricAggregateEnum'
        archived_at:
          type:
            - string
            - 'null'
          format: date-time
        code:
          type: string
        created_at:
          type: string
          format: date-time
        description:
          type:
            - string
            - 'null'
        id:
          $ref: '#/components/schemas/BillableMetricId'
        name:
          type: string
        product_family_id:
          $ref: '#/components/schemas/ProductFamilyId'
        product_id:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ProductId'
        segmentation_matrix:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/MetricSegmentationMatrix'
        unit_conversion:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/UnitConversion'
        usage_group_key:
          type:
            - string
            - 'null'
    RestErrorResponse:
      type: object
      required:
        - code
        - message
      properties:
        code:
          $ref: '#/components/schemas/ErrorCode'
        message:
          type: string
    MetricSegmentationMatrix:
      oneOf:
        - $ref: '#/components/schemas/MetricDimension'
        - $ref: '#/components/schemas/DoubleSegmentationMatrix'
        - $ref: '#/components/schemas/LinkedSegmentationMatrix'
      discriminator:
        propertyName: type
        mapping:
          DOUBLE:
            $ref: '#/components/schemas/DoubleSegmentationMatrix'
          LINKED:
            $ref: '#/components/schemas/LinkedSegmentationMatrix'
          SINGLE:
            $ref: '#/components/schemas/MetricDimension'
    UnitConversion:
      type: object
      required:
        - factor
        - rounding
      properties:
        factor:
          type: integer
          format: int32
        rounding:
          $ref: '#/components/schemas/UnitConversionRoundingEnum'
    BillingMetricAggregateEnum:
      type: string
      enum:
        - COUNT
        - LATEST
        - MAX
        - MIN
        - MEAN
        - SUM
        - COUNT_DISTINCT
    ProductFamilyId:
      type: string
      format: MeteroidId
      examples:
        - pf_7n42DGM5Tflk9n8mt7Fhc7
    ProductId:
      type: string
      format: MeteroidId
      examples:
        - prd_7n42DGM5Tflk9n8mt7Fhc7
    ErrorCode:
      type: string
      enum:
        - BAD_REQUEST
        - NOT_FOUND
        - CONFLICT
        - FORBIDDEN
        - UNAUTHORIZED
        - TOO_MANY_REQUESTS
        - INTERNAL_SERVER_ERROR
    MetricDimension:
      type: object
      required:
        - key
        - values
      properties:
        key:
          type: string
        values:
          type: array
          items:
            type: string
    DoubleSegmentationMatrix:
      type: object
      required:
        - dimension1
        - dimension2
      properties:
        dimension1:
          $ref: '#/components/schemas/MetricDimension'
        dimension2:
          $ref: '#/components/schemas/MetricDimension'
    LinkedSegmentationMatrix:
      type: object
      required:
        - dimension1_key
        - dimension2_key
        - values
      properties:
        dimension1_key:
          type: string
        dimension2_key:
          type: string
        values:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          propertyNames:
            type: string
    UnitConversionRoundingEnum:
      type: string
      enum:
        - UP
        - DOWN
        - NEAREST
        - NEAREST_HALF
        - NEAREST_DECILE
        - NONE
  securitySchemes:
    bearer_auth:
      type: http
      scheme: bearer

````