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

# Update plan

> Update a plan. Fields period_amount and billing_interval are immutable. Credit bundles use reconciliation: include credit_bundle_id to update, add is_deleted: true to remove, omit credit_bundle_id to create new.



## OpenAPI

````yaml /openapi.json patch /plans/{id}
openapi: 3.0.0
info:
  title: Lava API
  description: >-
    Lava API enables businesses to implement usage-based billing for AI
    services. This API allows tracking, managing, and billing for third-party AI
    API usage through a forwarding system.
  version: 1.0.0
  contact:
    name: Lava support
    url: https://www.lava.so/contact
servers:
  - url: https://api.lava.so/v1/
    description: Lava API v1
security: []
tags:
  - name: Authentication
  - name: Core Endpoints
  - name: Models
  - name: Services
  - name: Requests
  - name: Wallet
  - name: Payment Methods
  - name: Spend Keys
  - name: Usage
  - name: Checkout Sessions
  - name: Customers
  - name: Plans
  - name: Subscriptions
  - name: Meters
  - name: Webhooks
  - name: Secret Keys
  - name: Credit Bundles
  - name: Gateway Settings
  - name: Skills
  - name: News Data
  - name: Search
  - name: Enrich
paths:
  /plans/{id}:
    patch:
      tags:
        - Plans
      summary: Update plan
      description: >-
        Update a plan. Fields period_amount and billing_interval are immutable.
        Credit bundles use reconciliation: include credit_bundle_id to update,
        add is_deleted: true to remove, omit credit_bundle_id to create new.
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
          description: Plan ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateSubscriptionConfig'
      responses:
        '200':
          description: Plan updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionConfig'
        '400':
          description: Invalid request body or attempted to modify immutable field
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '404':
          description: Plan not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      security:
        - Auth: []
components:
  schemas:
    UpdateSubscriptionConfig:
      type: object
      description: >-
        Update a plan. Note: period_amount and billing_interval cannot be
        changed after creation.
      properties:
        name:
          type: string
          description: Name of the plan
        rollover_type:
          type: string
          enum:
            - full
            - none
          description: Whether unused included credit rolls over
        bundle_rollover_type:
          type: string
          enum:
            - full
            - none
          description: Whether unused bundle credit rolls over
        included_credit:
          type: string
          description: Credit included per billing cycle in USD
        default_auto_top_up_bundle_id:
          type: string
          nullable: true
          description: >-
            ID of a credit bundle to set as the default auto top-up bundle for
            new subscriptions. Set to null to disable.
        meter_ids:
          type: array
          items:
            type: string
          description: Meter IDs to link (full replacement — existing links are removed)
        credit_bundles:
          type: array
          items:
            type: object
            properties:
              credit_bundle_id:
                type: string
                description: >-
                  ID of existing bundle to update or delete. Omit to create a
                  new bundle.
              name:
                type: string
                description: Credit bundle name
              cost:
                type: string
                description: Price of the bundle in USD
              credit_amount:
                type: string
                description: Amount of credits in the bundle
              is_deleted:
                type: boolean
                description: >-
                  Set to true to soft-delete the bundle (requires
                  credit_bundle_id)
            required:
              - name
              - cost
              - credit_amount
          description: Credit bundles to create, update, or delete
    SubscriptionConfig:
      type: object
      properties:
        plan_id:
          type: string
          description: Unique identifier for the plan
        merchant_id:
          type: string
          description: Merchant ID that owns this plan
        name:
          type: string
          description: Name of the plan
        period_amount:
          type: string
          description: Period amount in USD (high precision decimal as string)
        included_credit:
          type: string
          description: >-
            Included credit per billing cycle in USD (high precision decimal as
            string)
        billing_interval:
          type: string
          enum:
            - day
            - week
            - month
            - year
          description: How often the subscription is billed
        rollover_type:
          type: string
          enum:
            - full
            - none
          description: 'Cycle rollover: whether unused included credit rolls to next cycle'
        bundle_rollover_type:
          type: string
          enum:
            - full
            - none
          description: 'Bundle rollover: whether unused bundle credit rolls to next cycle'
        default_auto_top_up_bundle_id:
          type: string
          nullable: true
          description: >-
            ID of the credit bundle that will be auto-purchased when a
            subscription cycle runs out of credit. Null if auto top-up is
            disabled.
        linked_meters:
          type: array
          items:
            type: object
            properties:
              meter_id:
                type: string
                description: Meter ID
              name:
                type: string
                description: Meter name
            required:
              - meter_id
              - name
          description: Meters linked to this plan
        credit_bundles:
          type: array
          items:
            type: object
            properties:
              credit_bundle_id:
                type: string
                description: Credit bundle ID
              name:
                type: string
                description: Credit bundle name
              cost:
                type: string
                description: Cost of the bundle in USD
              credit_amount:
                type: string
                description: Amount of credits in the bundle
            required:
              - credit_bundle_id
              - name
              - cost
              - credit_amount
          description: Credit bundles available for this plan
        created_at:
          type: string
          format: date-time
          description: When the plan was created
      required:
        - plan_id
        - merchant_id
        - name
        - period_amount
        - included_credit
        - billing_interval
        - rollover_type
        - bundle_rollover_type
        - default_auto_top_up_bundle_id
        - linked_meters
        - credit_bundles
        - created_at
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message describing what went wrong
              example: Invalid authentication credentials
            code:
              type: string
              description: Machine-readable error code describing what went wrong
              example: forward_token_json_invalid
            status:
              type: integer
              description: HTTP status code of the error
              example: 400
            issues:
              type: array
              items:
                type: object
                properties:
                  path:
                    type: array
                    items:
                      type: string
                    description: Path to the field that caused the validation error
                  message:
                    type: string
                    description: Error message describing the validation issue
                required:
                  - path
                  - message
              description: >-
                Optional array of specific validation issues with their paths
                and messages
              example:
                - path:
                    - model
                  message: 'Missing required field: model'
                - path:
                    - messages
                    - '0'
                    - content
                  message: Invalid message content format
          required:
            - message
            - code
            - status
      required:
        - error
  securitySchemes:
    Auth:
      type: http
      scheme: bearer
      description: >-
        Bearer token authentication used for standard API calls. Format: 'Bearer
        YOUR_API_KEY'

````