> ## 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.

# Preview moving subscribers to another version

> See who would move from one plan version to another, how their price changes, and who is skipped.

Previews moving the subscribers of one version (`fromVersion`, by number or label) to another (`toVersion`). The answer is a draft migration: how many subscribers move, whether their price goes up, down or stays the same, and who is skipped and why. Nothing moves until you [run it](https://docs.integrateledger.com/api-reference/plans/migrations-run.md).

* `timing: "at_renewal"` (the default): each subscriber keeps the version they paid for until their next renewal, which bills and grants the new one.
* `timing: "now"`: the new version starts at once, with no proration and no charge. The customer gets its allowance less what they already used this period, and its price bills from the next renewal.

A subscriber is skipped when another plan change is under way (`pending_change`), when Stripe's subscription can't take the change or the versions are billed differently, free and paid or on another billing interval (`stripe_state`), when a payment is owed (`past_due`), or while on a trial (`trialing`).

Needs the **Billing** permission at Write.


## OpenAPI

````yaml openapi.json POST /v1/plans/{id}/migrations
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/plans/{id}/migrations:
    post:
      tags:
        - Plans
      summary: Preview moving subscribers to another version
      description: >-
        Previews moving a plan's subscribers from one version to another: who
        moves, how their price changes, and who is skipped and why. Nothing
        moves until the migration runs.
      operationId: createPlanMigration
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 100
            pattern: ^[a-zA-Z0-9_-]+$
            description: The plan's ID.
          required: true
          description: The plan's ID.
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PlanMigrationInput'
      responses:
        '200':
          description: The preview, a draft migration
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PlanMigration'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                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
        '401':
          description: Invalid Ledger API key
          content:
            application/json:
              schema:
                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
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '404':
          description: >-
            No plan with this ID (plan_not_found), or no such version of it
            (plan_version_not_found)
          content:
            application/json:
              schema:
                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
        '413':
          $ref: '#/components/responses/PayloadTooLarge'
        '429':
          $ref: '#/components/responses/RateLimited'
      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.create_plan_migration("starter", from_version=1,
            to_version=2, timing="at_renewal")
        - lang: bash
          label: cURL
          source: >-
            curl --request POST
            'https://api.integrateledger.com/v1/plans/starter/migrations' \
              -H "Authorization: Bearer $LEDGER_API_KEY" \
              -H 'Content-Type: application/json' \
              --data '{"fromVersion":1,"toVersion":2,"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.createPlanMigration({ id: "starter", body: {
            fromVersion: 1, toVersion: 2, timing: "at_renewal" } });
components:
  schemas:
    PlanMigrationInput:
      type: object
      properties:
        fromVersion:
          anyOf:
            - type: integer
              exclusiveMinimum: 0
            - type: string
              minLength: 1
              maxLength: 60
          description: The version's number (such as 2) or its label (such as 2026-q4).
        toVersion:
          anyOf:
            - type: integer
              exclusiveMinimum: 0
            - type: string
              minLength: 1
              maxLength: 60
          description: The version's number (such as 2) or its label (such as 2026-q4).
        timing:
          type: string
          enum:
            - now
            - at_renewal
          description: >-
            at_renewal (the default): each subscriber keeps the version they
            paid for until their next renewal, which bills the new one. now: the
            new version starts at once, with no proration; its allowance less
            what this period used is granted, and its price bills from the next
            renewal.
        customerIds:
          type:
            - array
            - 'null'
          items:
            type: string
            minLength: 1
            maxLength: 255
          minItems: 1
          maxItems: 1000
          description: >-
            Only these customers (your IDs for them) move. Leave it out to move
            every subscriber of the version.
      required:
        - fromVersion
        - toVersion
      additionalProperties: false
    PlanMigration:
      type: object
      properties:
        migrationId:
          type: integer
        planId:
          type: string
        fromVersion:
          type:
            - integer
            - 'null'
        toVersion:
          type:
            - integer
            - 'null'
        timing:
          type: string
          enum:
            - now
            - at_renewal
        status:
          type: string
          enum:
            - draft
            - running
            - done
          description: >-
            draft: a preview; nothing has moved. running: its moves are queued
            and being applied. done: every move has been made or scheduled for
            its renewal.
        customers:
          type: integer
          minimum: 0
          description: >-
            Subscribers who move: the preview's count while a draft, the queued
            moves once it runs.
        byChange:
          type: object
          properties:
            priceUp:
              type: integer
              minimum: 0
            priceDown:
              type: integer
              minimum: 0
            same:
              type: integer
              minimum: 0
          required:
            - priceUp
            - priceDown
            - same
          description: How the moving subscribers' price changes.
        progress:
          type: object
          properties:
            queued:
              type: integer
              minimum: 0
            scheduled:
              type: integer
              minimum: 0
              description: Moves waiting for the subscriber's renewal.
            applied:
              type: integer
              minimum: 0
          required:
            - queued
            - scheduled
            - applied
          description: The moves' state once it runs.
        skipped:
          type: array
          items:
            type: object
            properties:
              customerId:
                type: string
              reason:
                type: string
                enum:
                  - pending_change
                  - stripe_state
                  - past_due
                  - trialing
                description: >-
                  pending_change: another plan change is under way.
                  stripe_state: Stripe's subscription can't take the change (a
                  schedule, pending update, pause or cancellation), or the
                  versions are billed differently (free and paid, or on another
                  billing interval). past_due: a payment is owed. trialing: the
                  subscriber is on a trial.
            required:
              - customerId
              - reason
          description: Subscribers left on their version, and why.
      required:
        - migrationId
        - planId
        - fromVersion
        - toVersion
        - timing
        - status
        - customers
        - byChange
        - progress
        - skipped
    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
  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.