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

# Change custom terms

> Give a subscription new custom terms, from its renewal or now.

Patches `customize` over the subscription's current terms and moves it onto them. [Custom plans](https://docs.integrateledger.com/billing/custom-plans.md) explains the fields.

* `at_renewal` changes nothing now; the next period bills and grants the new terms.
* `now` starts them at once, with no proration and no charge: the period's allowance is the new one less what it used, and the renewal bills the new price.
* A trialing subscription, one waiting on a payment or billed another way answers `409 subscription_not_movable`; one with a plan change open, `409 pending_change`.
* Terms the plan rules refuse answer `400 invalid_customize`.

Needs the **Billing** permission at Write.


## OpenAPI

````yaml openapi.json POST /v1/customers/subscriptions/{subscriptionId}/plan
openapi: 3.1.0
info:
  title: Ledger API
  version: 0.1.0
servers:
  - url: https://api.integrateledger.com
    description: Hosted Ledger API
security: []
paths:
  /v1/customers/subscriptions/{subscriptionId}/plan:
    post:
      tags:
        - Customers
      summary: Change a subscription's custom terms
      description: >-
        timing "now" starts the new terms at once, with no proration and no
        charge.
      operationId: changeSubscriptionPlanTerms
      parameters:
        - schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 2147483647
            description: The subscription's `id` from List customer subscriptions.
          required: true
          description: The subscription's `id` from List customer subscriptions.
          name: subscriptionId
          in: path
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: Your ID for the customer, such as your user ID.
          required: true
          description: Your ID for the customer, such as your user ID.
          name: customerId
          in: query
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanTermsChange'
      responses:
        '200':
          description: The new terms, scheduled or applied
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanTermsChangeResponse'
        '400':
          description: Invalid request, or terms the plan rules refuse (invalid_customize)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '401':
          description: Missing or invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '404':
          description: No such subscription for this customer
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '409':
          description: >-
            The subscription is trialing, waiting on a payment or billed another
            way (subscription_not_movable), or has a plan change open
            (pending_change)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/RateLimited'
        '502':
          description: >-
            No Stripe connection (stripe_not_configured) or Stripe unavailable
            (stripe_request_failed)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerError'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: >-
            import os

            from integrateledger import ledger


            client = ledger(api_key=os.environ["LEDGER_API_KEY"])

            client.change_subscription_plan_terms(customer_id="user_123",
            subscription_id=42, customize={"monthlyPriceCents": 200000},
            timing="at_renewal")
        - lang: bash
          label: cURL
          source: >-
            curl --request POST
            'https://api.integrateledger.com/v1/customers/subscriptions/42/plan?customerId=user_123'
            \
              -H "Authorization: Bearer $LEDGER_API_KEY" \
              -H 'Content-Type: application/json' \
              --data '{"customize":{"monthlyPriceCents":200000},"timing":"at_renewal"}'
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


            const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? ""
            });

            await client.changeSubscriptionPlanTerms({ subscriptionId: 42,
            customerId: "user_123", body: { customize: { monthlyPriceCents:
            200000 }, timing: "at_renewal" } });
components:
  schemas:
    PlanTermsChange:
      type: object
      properties:
        customize:
          $ref: '#/components/schemas/PlanCustomize'
        timing:
          type: string
          enum:
            - at_renewal
            - now
          description: >-
            `at_renewal`: the new terms start with the next billing period, and
            nothing changes now. `now`: they start at once, with no proration
            and no charge; the period's allowance is the new one less what it
            already used, and the renewal bills the new price.
      required:
        - customize
        - timing
      additionalProperties: false
    PlanTermsChangeResponse:
      type: object
      properties:
        subscriptionId:
          type: integer
        timing:
          type: string
          enum:
            - at_renewal
            - now
        status:
          type: string
          enum:
            - scheduled
            - applied
          description: >-
            `scheduled`: the new terms start at the renewal. `applied`: they are
            the subscription's terms now.
        planId:
          type: string
      required:
        - subscriptionId
        - timing
        - status
        - planId
    CustomerError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        issues:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
            required:
              - path
              - message
          description: >-
            With `invalid_request`: each field that failed validation and why.
            `path` is empty for the body itself, such as an unknown field.
      required:
        - error
    PlanCustomize:
      type: object
      properties:
        monthlyCredits:
          type: integer
          minimum: 0
          description: >-
            Credits granted at the start of each allowance period (each month,
            unless resetInterval is year). 0 for a plan with only items, or with
            pay-as-you-go credits. At most 2,147,483,647: $21,474.83 at 100,000
            credits per dollar.
        priceCents:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: >-
            Price in US cents per billing interval: a year's price on an annual
            plan. 0 makes a free plan. Required unless monthlyPriceCents is
            sent.
        monthlyPriceCents:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: >-
            The older name for priceCents, accepted on monthly plans only.
            Listed for monthly plans.
        overageUnitAmountCents:
          type:
            - integer
            - 'null'
          maximum: 2147483647
          exclusiveMinimum: 0
          description: >-
            Price in cents per overageBillingUnits credits used after the plan's
            credits and packs run out. Null or omitted: no overage.
        overageBillingUnits:
          type: integer
          exclusiveMinimum: 0
          maximum: 2147483647
          description: Credits billed per overageUnitAmountCents. Defaults to 1.
        overageCapCents:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 2147483647
          description: >-
            Default monthly overage spend cap in cents. A customer's own cap
            replaces it. Null or omitted: no cap.
        overageTiers:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              upTo:
                type:
                  - integer
                  - 'null'
                maximum: 2147483647
                exclusiveMinimum: 0
                description: >-
                  The band's last billed unit; null for the last band, which has
                  no limit.
              unitAmountCents:
                type: integer
                maximum: 2147483647
                exclusiveMinimum: 0
                description: Price in cents per billed unit in this band.
              flatAmountCents:
                type: integer
                minimum: 0
                maximum: 2147483647
                description: A flat amount billed once the band is reached. Defaults to 0.
            required:
              - upTo
              - unitAmountCents
            additionalProperties: false
          description: >-
            Bands for the period's overage instead of one rate, over billed
            units (overage rounded up to the billing units), ascending, the last
            with upTo null. overageUnitAmountCents must be sent as the first
            band's rate. The invoice bills one line per band reached.
        overageTiersMode:
          type:
            - string
            - 'null'
          enum:
            - graduated
            - volume
            - null
          description: >-
            With overageTiers: `graduated` (the default) prices each band's
            units at its rate; `volume` prices every unit at the rate of the
            band the period's total reaches. Null or omitted without tiers.
        rollover:
          type:
            - object
            - 'null'
          properties:
            maxCredits:
              type:
                - integer
                - 'null'
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                The most rolled-over credits (or units, on an item) live at
                once. Send this or maxPercent.
            maxPercent:
              type:
                - integer
                - 'null'
              minimum: 1
              maximum: 100
              description: >-
                The most rolled over as a percent of one period's allowance, 1
                to 100. Send this or maxCredits.
            periods:
              type:
                - integer
                - 'null'
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                How many allowance periods a rolled grant lasts. Defaults to 1
                (it ends with the next period); null keeps it until used.
          additionalProperties: false
          description: >-
            Unused monthlyCredits carried into the next allowance period, up to
            a maximum, and spent first. Null or omitted: they end with the
            period. A change publishes a new plan version.
        autoTopUp:
          type:
            - object
            - 'null'
          properties:
            thresholdCredits:
              type: integer
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                Buy when the shared balance's available credits fall below this.
                Above 0.
            addOnId:
              type:
                - string
                - 'null'
              minLength: 1
              maxLength: 100
              description: The credit pack to buy. Send this or amountCents.
            amountCents:
              type:
                - integer
                - 'null'
              exclusiveMinimum: 0
              maximum: 99999999
              description: >-
                Or an amount to buy, in cents, at the catalog's top-up rate.
                Within topUps.minCents and maxCents.
            maxPerPeriod:
              type: integer
              minimum: 1
              maximum: 31
              description: The most automatic top-ups per billing period, 1 to 31.
            maxAmountCentsPerPeriod:
              type:
                - integer
                - 'null'
              exclusiveMinimum: 0
              maximum: 99999999
              description: >-
                The most automatic top-ups may charge per billing period, in
                cents. Null or omitted: no money limit.
          required:
            - thresholdCredits
            - maxPerPeriod
          additionalProperties: false
          description: >-
            The plan's auto top-up default: below thresholdCredits, buy a credit
            pack or an amount with the saved card. A customer's own setting
            replaces it. A change publishes a new plan version.
        trial:
          type:
            - object
            - 'null'
          properties:
            days:
              type: integer
              minimum: 1
              maximum: 365
              description: 'How long the trial lasts: 1 to 365 days.'
            cardRequired:
              type: boolean
              description: >-
                true (the default): the customer gives a card, Stripe holds the
                trial and bills at its end. false: no card and no Stripe
                subscription during the trial.
            onEnd:
              type: string
              enum:
                - bill
                - revert
              description: >-
                What happens when the trial ends: `bill` starts charging (the
                default with a card); `revert` goes back to the plan the
                customer had before, or to none (the default without a card).
            credits:
              type: integer
              minimum: 0
              maximum: 2147483647
              description: >-
                Credits granted to the pool for the trial. Defaults to
                monthlyCredits.
          required:
            - days
          additionalProperties: false
          description: >-
            A free trial when a customer first starts the plan, once per
            customer and plan. Not on a one-off plan (`trial_not_supported`).
            Null or omitted: no trial. A change publishes a new plan version.
        items:
          type: array
          items:
            $ref: '#/components/schemas/PlanItemInput'
          maxItems: 100
          description: >-
            Items that replace the base's item for the same feature, or add a
            feature it doesn't have.
        removeItems:
          type: array
          items:
            type: string
            minLength: 1
            maxLength: 100
            pattern: ^[a-zA-Z0-9_-]+$
            description: >-
              Your ID for the item: letters, numbers, `_` or `-`. It can't be
              changed.
          maxItems: 100
          description: >-
            Features the base includes that this customer's plan leaves out.
            Never `included: 0`.
      additionalProperties: false
      description: >-
        This customer's own terms over the plan, for a sales-led deal: a price,
        credits, items or overage of their own. Ledger makes a private version
        of the plan for the customer, billed under its name; the same customize
        again reuses it. A plan with customOnly needs it.
    InsufficientPermissionsError:
      type: object
      properties:
        error:
          type: string
          example: insufficient_permissions
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        requiredScope:
          type: string
          example: customers:read
      required:
        - error
        - requiredScope
    PayloadTooLargeError:
      type: object
      properties:
        error:
          type: string
          example: payload_too_large
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: rate_limited
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
    PlanItemInput:
      type: object
      properties:
        featureId:
          type: string
          minLength: 1
          maxLength: 100
          pattern: ^[a-zA-Z0-9_-]+$
          description: The feature this item includes.
        included:
          type:
            - integer
            - 'null'
          minimum: 0
          description: >-
            For a metered feature, units granted each period; for a held
            feature, the most the customer may hold; for an AI feature with its
            own balance, credits of that balance each period. At most
            2,147,483,647. Leave out with unlimited, and for boolean, credits
            and pool AI features.
        unlimited:
          type: boolean
          description: >-
            No limit: uses are always allowed and never debited. The only field
            a credits or pool AI item takes, and it must be true there.
        overageUnitAmountCents:
          type:
            - integer
            - 'null'
          maximum: 2147483647
          exclusiveMinimum: 0
          description: >-
            Metered and own-balance AI items only: price in cents per
            overageBillingUnits units (credits, for AI) used past `included`,
            billed on the renewal invoice. Counts toward the customer's one
            overage cap. `included: 0` with a price is pay as you go. Null or
            omitted: no overage.
        overageBillingUnits:
          type: integer
          exclusiveMinimum: 0
          maximum: 2147483647
          description: Units billed per overageUnitAmountCents. Defaults to 1.
        overageTiers:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              upTo:
                type:
                  - integer
                  - 'null'
                maximum: 2147483647
                exclusiveMinimum: 0
                description: >-
                  The band's last billed unit; null for the last band, which has
                  no limit.
              unitAmountCents:
                type: integer
                maximum: 2147483647
                exclusiveMinimum: 0
                description: Price in cents per billed unit in this band.
              flatAmountCents:
                type: integer
                minimum: 0
                maximum: 2147483647
                description: A flat amount billed once the band is reached. Defaults to 0.
            required:
              - upTo
              - unitAmountCents
            additionalProperties: false
          description: >-
            Bands for the period's overage instead of one rate, over billed
            units (overage rounded up to the billing units), ascending, the last
            with upTo null. overageUnitAmountCents must be sent as the first
            band's rate. The invoice bills one line per band reached.
        overageTiersMode:
          type:
            - string
            - 'null'
          enum:
            - graduated
            - volume
            - null
          description: >-
            With overageTiers: `graduated` (the default) prices each band's
            units at its rate; `volume` prices every unit at the rate of the
            band the period's total reaches. Null or omitted without tiers.
        price:
          $ref: '#/components/schemas/ItemPrice'
        trialIncluded:
          type:
            - integer
            - 'null'
          minimum: 0
          maximum: 2147483647
          description: >-
            Metered items only: units granted for the plan's trial instead of
            `included`. Null or omitted: `included`.
        rollover:
          type:
            - object
            - 'null'
          properties:
            maxCredits:
              type:
                - integer
                - 'null'
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                The most rolled-over credits (or units, on an item) live at
                once. Send this or maxPercent.
            maxPercent:
              type:
                - integer
                - 'null'
              minimum: 1
              maximum: 100
              description: >-
                The most rolled over as a percent of one period's allowance, 1
                to 100. Send this or maxCredits.
            periods:
              type:
                - integer
                - 'null'
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                How many allowance periods a rolled grant lasts. Defaults to 1
                (it ends with the next period); null keeps it until used.
          additionalProperties: false
          description: >-
            Metered items with included above 0 only: unused units carried into
            the next period, up to a maximum. Null or omitted: they end with the
            period.
        prepaid:
          type:
            - object
            - 'null'
          properties:
            billingUnits:
              type: integer
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                Units in one pack: what the customer buys at a time, such as
                1000. 1 or more.
            unitAmountCents:
              type: integer
              maximum: 2147483647
              exclusiveMinimum: 0
              description: >-
                Price in US cents of one pack per billing interval of the plan,
                above 0.
            maxQuantity:
              type: integer
              exclusiveMinimum: 0
              maximum: 2147483647
              description: >-
                The most one customer may hold a period, the included units
                counted. Above them, by whole packs
                (`prepaid_max_below_included`, `prepaid_max_not_multiple`).
                Omitted: no maximum.
          required:
            - billingUnits
            - unitAmountCents
          additionalProperties: false
          description: >-
            Metered items only, not unlimited: units past `included` sold in
            prepaid packs. Null or omitted: none.
      required:
        - featureId
      additionalProperties: false
    ItemPrice:
      type:
        - object
        - 'null'
      properties:
        model:
          type: string
          enum:
            - per_unit
            - measured
          description: >-
            `per_unit`: billed per unit held (seats), in advance at the plan's
            interval, prorated when the count changes. `measured`: the amount
            held over each period, billed in arrears as unit-months (storage:
            100 GB for half a month is 50 GB-months), on the renewal invoice.
        billingUnits:
          type: integer
          maximum: 2147483647
          exclusiveMinimum: 0
          description: >-
            Measured prices: held units per billed unit, such as 1024 to bill a
            count in MB per GB-month. Defaults to 1.
        unitAmountCents:
          type:
            - integer
            - 'null'
          maximum: 2147483647
          exclusiveMinimum: 0
          description: >-
            Price in US cents per unit held, per billing interval. Leave out
            with tiers.
        tiers:
          type:
            - array
            - 'null'
          items:
            type: object
            properties:
              upTo:
                type:
                  - integer
                  - 'null'
                maximum: 2147483647
                exclusiveMinimum: 0
                description: >-
                  The band's last unit; null for the last band, which has no
                  limit.
              unitAmountCents:
                type: integer
                minimum: 0
                maximum: 2147483647
                description: Price in US cents per unit in this band.
            required:
              - upTo
              - unitAmountCents
            additionalProperties: false
          description: >-
            Bands instead of one unitAmountCents, ascending, the last with upTo
            null. A first band at 0 makes seats free.
        tiersMode:
          type:
            - string
            - 'null'
          enum:
            - graduated
            - volume
            - null
          description: >-
            With tiers: `graduated` (the default) prices each band's units at
            its rate; `volume` prices every unit at the rate of the band the
            count reaches.
        includedQuantity:
          type: integer
          minimum: 0
          maximum: 2147483647
          description: >-
            Units held free before unitAmountCents applies. Defaults to 0. With
            tiers, use a first band at 0.
        proration:
          type: object
          properties:
            onIncrease:
              type: string
              enum:
                - next_invoice
                - charge_now
                - none
              description: >-
                A rise in the count: prorated on the next invoice (the default),
                invoiced and charged now, or billed from the next period.
            onDecrease:
              type: string
              enum:
                - next_invoice
                - none
              description: >-
                A fall in the count: credited on the next invoice (the default),
                or not (the lower count bills from the next period).
          additionalProperties: false
      required:
        - model
      additionalProperties: false
  responses:
    InsufficientPermissions:
      description: >-
        The API key works but lacks the permission this endpoint needs, named in
        requiredScope. See the API keys guide.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InsufficientPermissionsError'
    PayloadTooLarge:
      description: 'The request body is over the limit: 1 MiB, or 5 MiB for a webhook.'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/PayloadTooLargeError'
    RateLimited:
      description: >-
        Too many requests. Wait Retry-After seconds, then retry. See the rate
        limits guide.
      headers:
        Retry-After:
          description: Seconds until a request is allowed again
          schema:
            type: integer
        RateLimit-Limit:
          description: 'The burst: requests allowed at once'
          schema:
            type: integer
        RateLimit-Remaining:
          description: Requests left right now
          schema:
            type: integer
        RateLimit-Reset:
          description: Seconds until the full burst is back
          schema:
            type: integer
        RateLimit-Policy:
          description: >-
            The sustained rate per second and the burst, such as
            200;w=1;burst=1000
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.