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

# Change subscription plan

> Changes the subscription to a different plan with configurable proration behavior. Supports upgrades (immediate or deferred billing) and downgrades (always deferred to next billing cycle).



## OpenAPI

````yaml /api-reference/orchestrator-openapi.json patch /v1/subscriptions/{id}/plan
openapi: 3.0.0
info:
  title: Payment Orchestrator API
  description: API documentation for the Payment Orchestrator service
  version: 1.0.0
servers:
  - url: https://api.sandbox.cheqpay.mx/pos
    description: Sandbox environment
  - url: https://prod.cheqpay.mx/pos
    description: Production environment
security:
  - ApiKeyAuth: []
    MerchantIdAuth: []
tags:
  - name: Customer
    description: Customer management endpoints (v1)
  - name: Customer V2
    description: >-
      Customer management endpoints (v2) - merchant-scoped, no external ID
      required
  - name: Payment Order
    description: Payment order management endpoints
  - name: Checkout
    description: Payment checkout endpoints
  - name: Payment Method
    description: Payment method management endpoints
  - name: Subscription Plan
    description: Subscription plan management endpoints for recurring payments
  - name: Subscription
    description: Subscription management endpoints for recurring billing
  - name: Subscription Invoice
    description: Subscription invoice management endpoints
paths:
  /v1/subscriptions/{id}/plan:
    patch:
      tags:
        - Subscription
      summary: Change subscription plan
      description: >-
        Changes the subscription to a different plan with configurable proration
        behavior. Supports upgrades (immediate or deferred billing) and
        downgrades (always deferred to next billing cycle).
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Subscription unique identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ChangePlanRequest'
            examples:
              upgrade_deferred:
                summary: Upgrade with deferred proration (default)
                value:
                  newPlanId: 123e4567-e89b-12d3-a456-426614174010
                  prorationBehavior: create_prorations
              upgrade_immediate:
                summary: Upgrade with immediate charge
                value:
                  newPlanId: 123e4567-e89b-12d3-a456-426614174010
                  prorationBehavior: always_invoice
              downgrade:
                summary: Downgrade (always deferred, no proration)
                value:
                  newPlanId: 123e4567-e89b-12d3-a456-426614174005
                  prorationBehavior: none
              reset_billing_cycle:
                summary: Change plan and reset billing cycle
                value:
                  newPlanId: 123e4567-e89b-12d3-a456-426614174010
                  prorationBehavior: create_prorations
                  resetBillingCycle: true
      responses:
        '200':
          description: Plan changed successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChangePlanResponse'
              examples:
                upgrade_deferred:
                  summary: Upgrade with deferred proration
                  value:
                    subscription:
                      id: 123e4567-e89b-12d3-a456-426614174000
                      merchantId: merchant_123
                      customerId: 123e4567-e89b-12d3-a456-426614174001
                      planId: 123e4567-e89b-12d3-a456-426614174010
                      paymentMethodId: 123e4567-e89b-12d3-a456-426614174003
                      status: ACTIVE
                      currentPeriodStart: '2026-01-01T00:00:00.000Z'
                      currentPeriodEnd: '2026-02-01T00:00:00.000Z'
                      trialStart: null
                      trialEnd: null
                      cancelAtPeriodEnd: false
                      canceledAt: null
                      endedAt: null
                      metadata: null
                      createdAt: '2026-01-01T00:00:00.000Z'
                      updatedAt: '2026-01-16T00:00:00.000Z'
                    proration:
                      behavior: create_prorations
                      netAmount: '5162'
                      appliedOn: next_invoice
                      invoiceId: null
                      chargedAmount: null
                      chargedAt: null
                      nextInvoiceDate: '2026-02-01T00:00:00.000Z'
                      nextInvoiceAmount: '25162'
                      billingCycleReset: false
                      error: null
                upgrade_immediate:
                  summary: Upgrade with immediate charge
                  value:
                    subscription:
                      id: 123e4567-e89b-12d3-a456-426614174000
                      merchantId: merchant_123
                      customerId: 123e4567-e89b-12d3-a456-426614174001
                      planId: 123e4567-e89b-12d3-a456-426614174010
                      paymentMethodId: 123e4567-e89b-12d3-a456-426614174003
                      status: ACTIVE
                      currentPeriodStart: '2026-01-01T00:00:00.000Z'
                      currentPeriodEnd: '2026-02-01T00:00:00.000Z'
                      trialStart: null
                      trialEnd: null
                      cancelAtPeriodEnd: false
                      canceledAt: null
                      endedAt: null
                      metadata: null
                      createdAt: '2026-01-01T00:00:00.000Z'
                      updatedAt: '2026-01-16T00:00:00.000Z'
                    proration:
                      behavior: always_invoice
                      netAmount: '5162'
                      appliedOn: immediate
                      invoiceId: 123e4567-e89b-12d3-a456-426614174020
                      chargedAmount: '5162'
                      chargedAt: '2026-01-16T00:00:00.000Z'
                      nextInvoiceDate: '2026-02-01T00:00:00.000Z'
                      nextInvoiceAmount: '20000'
                      billingCycleReset: false
                      error: null
                downgrade:
                  summary: Downgrade (deferred to next cycle)
                  value:
                    subscription:
                      id: 123e4567-e89b-12d3-a456-426614174000
                      merchantId: merchant_123
                      customerId: 123e4567-e89b-12d3-a456-426614174001
                      planId: 123e4567-e89b-12d3-a456-426614174002
                      paymentMethodId: 123e4567-e89b-12d3-a456-426614174003
                      status: ACTIVE
                      currentPeriodStart: '2026-01-01T00:00:00.000Z'
                      currentPeriodEnd: '2026-02-01T00:00:00.000Z'
                      trialStart: null
                      trialEnd: null
                      cancelAtPeriodEnd: false
                      canceledAt: null
                      endedAt: null
                      metadata: null
                      createdAt: '2026-01-01T00:00:00.000Z'
                      updatedAt: '2026-01-16T00:00:00.000Z'
                    proration:
                      behavior: none
                      netAmount: null
                      appliedOn: deferred
                      invoiceId: null
                      chargedAmount: null
                      chargedAt: null
                      nextInvoiceDate: '2026-02-01T00:00:00.000Z'
                      nextInvoiceAmount: '10000'
                      billingCycleReset: false
                      error: null
        '400':
          description: Validation failed or invalid plan change
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UnauthorizedError'
        '404':
          description: Subscription or plan not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalError'
components:
  schemas:
    ChangePlanRequest:
      type: object
      required:
        - newPlanId
      properties:
        newPlanId:
          type: string
          format: uuid
          description: New plan ID to change to
          example: 123e4567-e89b-12d3-a456-426614174010
        prorationBehavior:
          type: string
          enum:
            - create_prorations
            - always_invoice
            - none
          default: create_prorations
          description: >-
            How to handle proration: create_prorations (deferred to next
            invoice), always_invoice (immediate charge), none (no proration for
            downgrades)
          example: create_prorations
        prorationDate:
          type: string
          format: date-time
          description: Effective date for the plan change (defaults to now)
          example: '2026-01-16T00:00:00.000Z'
        resetBillingCycle:
          type: boolean
          default: false
          description: >-
            Whether to reset the billing cycle anchor (start new period from
            change date)
          example: false
    ChangePlanResponse:
      type: object
      required:
        - subscription
      properties:
        subscription:
          $ref: '#/components/schemas/SubscriptionResponse'
        proration:
          $ref: '#/components/schemas/ProrationDetails'
    ValidationError:
      type: object
      description: Validation error response
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: Error message
          example: Validation failed
        errors:
          type: array
          description: List of validation errors
          items:
            type: object
            properties:
              field:
                type: string
                description: Field that failed validation
                example: name
              message:
                type: string
                description: Validation error message
                example: Required
      example:
        message: Validation failed
        errors:
          - field: name
            message: Required
    UnauthorizedError:
      type: object
      description: Unauthorized error response
      properties:
        message:
          type: string
          description: Error message
          example: Invalid api key
      example:
        message: Invalid api key
    NotFoundError:
      type: object
      description: Not found error response
      properties:
        message:
          type: string
          description: Error message
          example: Merchant not found
      example:
        message: Merchant not found
    InternalError:
      type: object
      description: Error response
      properties:
        message:
          type: string
          description: Error message
          example: Error message
      example:
        message: Error message
    SubscriptionResponse:
      type: object
      required:
        - id
        - merchantId
        - customerId
        - planId
        - paymentMethodId
        - status
        - currentPeriodStart
        - currentPeriodEnd
        - cancelAtPeriodEnd
        - nextBillingDate
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique subscription identifier
          example: 123e4567-e89b-12d3-a456-426614174000
        merchantId:
          type: string
          description: Merchant identifier
          example: merchant_123
        customerId:
          type: string
          format: uuid
          description: Customer identifier
          example: 123e4567-e89b-12d3-a456-426614174001
        planId:
          type: string
          format: uuid
          description: Plan identifier
          example: 123e4567-e89b-12d3-a456-426614174002
        paymentMethodId:
          type: string
          format: uuid
          description: Payment method identifier
          example: 123e4567-e89b-12d3-a456-426614174003
        status:
          type: string
          enum:
            - TRIALING
            - ACTIVE
            - PAST_DUE
            - CANCELED
            - UNPAID
          description: Subscription status
          example: ACTIVE
        currentPeriodStart:
          type: string
          format: date-time
          description: Start of the current billing period
          example: '2025-01-01T00:00:00.000Z'
        currentPeriodEnd:
          type: string
          format: date-time
          description: End of the current billing period
          example: '2025-02-01T00:00:00.000Z'
        trialStart:
          type: string
          format: date-time
          nullable: true
          description: Trial period start date
          example: '2025-01-01T00:00:00.000Z'
        trialEnd:
          type: string
          format: date-time
          nullable: true
          description: Trial period end date
          example: '2025-01-15T00:00:00.000Z'
        cancelAtPeriodEnd:
          type: boolean
          description: Whether the subscription will cancel at period end
          example: false
        canceledAt:
          type: string
          format: date-time
          nullable: true
          description: When the subscription was canceled
          example: null
        endedAt:
          type: string
          format: date-time
          nullable: true
          description: When the subscription ended
          example: null
        nextBillingDate:
          type: string
          format: date-time
          description: >-
            Date of the next billing charge (trial end date while trialing,
            otherwise the current period end date)
          example: '2025-02-01T00:00:00.000Z'
        metadata:
          type: object
          additionalProperties: true
          nullable: true
          description: Additional metadata
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
          example: '2025-01-01T00:00:00.000Z'
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
          example: '2025-01-15T10:00:00.000Z'
        plan:
          type: object
          description: Associated plan details
          properties:
            id:
              type: string
              format: uuid
              description: Plan identifier
            name:
              type: string
              description: Plan name
            amount:
              type: string
              description: Plan amount
            currency:
              type: string
              description: Plan currency
            interval:
              type: string
              enum:
                - DAY
                - WEEK
                - MONTH
                - YEAR
              description: Billing interval
            intervalCount:
              type: integer
              description: Number of intervals
    ProrationDetails:
      type: object
      nullable: true
      properties:
        behavior:
          type: string
          enum:
            - create_prorations
            - always_invoice
            - none
          description: Proration behavior applied
          example: create_prorations
        netAmount:
          type: string
          nullable: true
          description: >-
            Net proration amount (new plan charge - old plan credit) as string
            to preserve precision
          example: '5162'
        appliedOn:
          type: string
          enum:
            - immediate
            - next_invoice
            - deferred
          description: When the proration was/will be applied
          example: next_invoice
        invoiceId:
          type: string
          format: uuid
          nullable: true
          description: Invoice ID if proration was immediately charged
          example: null
        chargedAmount:
          type: string
          nullable: true
          description: Amount charged immediately (only for always_invoice)
          example: null
        chargedAt:
          type: string
          format: date-time
          nullable: true
          description: When the immediate charge occurred
          example: null
        nextInvoiceDate:
          type: string
          format: date-time
          nullable: true
          description: Next scheduled invoice date (for deferred proration)
          example: '2026-02-01T00:00:00.000Z'
        nextInvoiceAmount:
          type: string
          nullable: true
          description: Expected amount on next invoice including proration
          example: '25162'
        billingCycleReset:
          type: boolean
          description: Whether the billing cycle was reset
          example: false
        error:
          type: string
          nullable: true
          description: Error message if immediate charging failed
          example: null
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key for authentication (required)
    MerchantIdAuth:
      type: apiKey
      in: header
      name: x-merchant-id
      description: Merchant ID for identifying the merchant (required)

````