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

# Move commits and credits to historical

> Move one or more fully depleted, immutable commits or credits on a contract to historical storage. Historical commits and credits are removed from active code paths, which makes future computations for this customer faster. They remain retrievable through the historical view. Set `dry_run` to `true` to preview the result without making changes.




## OpenAPI

````yaml /openapi.json post /v2/contracts/commits/moveToHistory
openapi: 3.0.1
info:
  title: Metronome
  version: 1.0.0
servers:
  - url: https://api.metronome.com
    description: Production server
security:
  - bearerAuth: []
tags:
  - name: Webhooks
    description: >-
      Inspect webhook delivery history, notification payloads, and retry
      attempts for the last 30 days. See the [Webhooks
      guide](/guides/platform-configuration/webhooks/webhook-types) for
      notification types and delivery behavior.
  - name: Customers
    description: >-
      [Customers](https://docs.metronome.com/provisioning/create-customers/) in
      Metronome represent your users for all billing and reporting. Use these
      endpoints to create, retrieve, update, and archive customers and their
      billing configuration.
  - name: Billable metrics
    description: >-
      [Billable
      metrics](https://docs.metronome.com/understanding-metronome/how-metronome-works#billable-metrics)
      in Metronome represent the various consumption components that Metronome
      meters and aggregates.
  - name: Usage
    description: >-
      [Usage
      events](https://docs.metronome.com/connecting-metronome/send-usage-data/)
      are the basis for billable metrics. Use these endpoints to send usage
      events to Metronome and retrieve aggregated event data.
  - name: Products
    description: Products are the items that customers purchase.
  - name: Rate cards
    description: Rate cards are used to define default pricing for products.
  - name: Contracts
    description: >-
      A contract defines a customer’s products, pricing, discounts, commitments,
      and more. Use these endpoints to create and update contracts data.
  - name: Credits and commits
    description: Credits and commits are used to manage customer balances.
  - name: Invoices
    description: >-
      [Invoices](https://docs.metronome.com/invoicing/) reflect how much a
      customer spent during a period, which is the basis for billing. Metronome
      automatically generates invoices based upon your pricing, packaging, and
      usage events. Use these endpoints to retrieve invoices.
  - name: Alerts
    description: >-
      [Alerts](https://docs.metronome.com/connecting-metronome/alerts/) monitor
      customer spending, balances, and other billing factors. Use these
      endpoints to create, retrieve, and archive customer alerts. To view sample
      alert payloads by alert type, navigate
      [here.](https://docs.metronome.com/manage-product-access/create-manage-alerts/#webhook-notifications)
  - name: Custom fields
    description: >-
      [Custom fields](https://docs.metronome.com/integrations/custom-fields/)
      enable adding additional data to Metronome entities. Use these endpoints
      to create, retrieve, update, and delete custom fields.
  - name: Security
    description: >-
      [Security](https://docs.metronome.com/developer-resources/security/)
      endpoints allow you to retrieve security-related data.
  - name: Settings
    description: >-
      Use these endpoints to configure a billing API key, a webhook secret, or
      invoice finalization behavior.
  - name: Named schedules
    description: >-
      Named schedules are used for storing custom data that can change over
      time. Named schedules are often used in custom pricing logic.
paths:
  /v2/contracts/commits/moveToHistory:
    post:
      tags:
        - Credits and commits
      summary: Move commits and credits to historical
      description: >
        Move one or more fully depleted, immutable commits or credits on a
        contract to historical storage. Historical commits and credits are
        removed from active code paths, which makes future computations for this
        customer faster. They remain retrievable through the historical view.
        Set `dry_run` to `true` to preview the result without making changes.
      operationId: moveToHistory-v2
      requestBody:
        description: Customer, contract, and commit or credit IDs to move to historical
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MoveToHistoryPayload'
            example:
              customer_id: 4c91c473-fc12-445a-9c38-40421d47023f
              contract_id: a1b2c3d4-5678-9abc-def0-1234567890ab
              commit_ids:
                - 5e7e82cf-ccb7-428c-a96f-a8e4f67af822
                - d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: '#/components/schemas/MoveToHistoryResponse'
              example:
                data:
                  historical_count: 1
                  historical_commit_ids:
                    - 5e7e82cf-ccb7-428c-a96f-a8e4f67af822
                  historical_credit_ids: []
                  skipped_commit_reasons:
                    - commit_id: d7abd0cd-4ae9-4db7-8676-e986a4ebd8dc
                      reason: COMMIT_NOT_FOUND
                  skipped_credit_reasons: []
                  skipped_count: 1
        '400':
          description: Error
          content:
            application/json:
              schema:
                type: object
                required:
                  - code
                  - message
                properties:
                  code:
                    type: string
                  message:
                    type: string
components:
  schemas:
    MoveToHistoryPayload:
      type: object
      required:
        - customer_id
        - contract_id
      description: Provide up to 1000 IDs across commit_ids and credit_ids combined.
      properties:
        customer_id:
          type: string
          format: uuid
          description: >-
            ID of the customer whose commits or credits are being moved to
            historical
        contract_id:
          type: string
          format: uuid
          description: ID of the contract containing the commits or credits
        commit_ids:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of the commits to move to historical
        credit_ids:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of the credits to move to historical
        dry_run:
          type: boolean
          description: >-
            If true, previews which commits or credits would be moved to
            historical and which would be skipped, without making changes
    MoveToHistoryResponse:
      type: object
      required:
        - historical_count
        - historical_commit_ids
        - historical_credit_ids
        - skipped_commit_reasons
        - skipped_credit_reasons
        - skipped_count
      properties:
        historical_count:
          type: number
          description: >-
            Number of commits and credits successfully moved to historical in
            this request
        historical_commit_ids:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of the commits that were moved to historical
        historical_credit_ids:
          type: array
          items:
            type: string
            format: uuid
          description: IDs of the credits that were moved to historical
        skipped_commit_reasons:
          type: array
          items:
            type: object
            required:
              - commit_id
              - reason
            properties:
              commit_id:
                type: string
                format: uuid
              reason:
                type: string
                description: Why the commit was skipped
          description: >-
            Per-commit details on why specific commits were not moved to
            historical
        skipped_credit_reasons:
          type: array
          items:
            type: object
            required:
              - credit_id
              - reason
            properties:
              credit_id:
                type: string
                format: uuid
              reason:
                type: string
                description: Why the credit was skipped
          description: >-
            Per-credit details on why specific credits were not moved to
            historical
        skipped_count:
          type: number
          description: Number of commits and credits that were skipped due to ineligibility
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````