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

# Undo a scheduled downgrade

> Keep the customer on its current plan.

Undoes a scheduled downgrade: Ledger releases its Stripe schedule, so the subscription renews on its current plan, and the downgrade is `closed`. Undoing one that's already closed returns it again. A downgrade that has already applied returns `409 downgrade_applied`; upgrade instead.

A schedule released or canceled in Stripe's Dashboard closes the downgrade the same way.


## OpenAPI

````yaml openapi.json POST /v1/billing/downgrade/{downgradeId}/cancel
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/billing/downgrade/{downgradeId}/cancel:
    post:
      tags:
        - Billing
      summary: Undo a scheduled downgrade
      operationId: cancelScheduledDowngrade
      parameters:
        - schema:
            type: integer
            exclusiveMinimum: 0
            maximum: 2147483647
          required: true
          name: downgradeId
          in: path
        - schema:
            type: string
            minLength: 1
            maxLength: 255
          required: true
          name: customerId
          in: query
      responses:
        '200':
          description: >-
            The downgrade, now `closed`; the subscription stays on its current
            plan
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Downgrade'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  downgradeId:
                    type: integer
                required:
                  - error
        '401':
          description: Invalid Ledger API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  downgradeId:
                    type: integer
                required:
                  - error
        '404':
          description: No such downgrade for this customer
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  downgradeId:
                    type: integer
                required:
                  - error
        '409':
          description: Already applied (downgrade_applied); upgrade instead
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  downgradeId:
                    type: integer
                required:
                  - error
        '429':
          $ref: '#/components/responses/RateLimited'
        '500':
          description: >-
            Unexpected error in Ledger. It has been logged with the request ID;
            retry, or quote request_id when reporting it.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalError'
        '502':
          description: Stripe unavailable or not set up
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
                  downgradeId:
                    type: integer
                required:
                  - error
      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.cancel_scheduled_downgrade(customer_id="user_123",
            downgrade_id=7)
        - lang: bash
          label: cURL
          source: >-
            curl --request POST
            'https://api.integrateledger.com/v1/billing/downgrade/7/cancel?customerId=user_123'
            \
              -H "Authorization: Bearer $LEDGER_API_KEY"
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


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

            await client.cancelScheduledDowngrade({ downgradeId: 7, customerId:
            "user_123" });
components:
  schemas:
    Downgrade:
      type: object
      properties:
        downgradeId:
          type: integer
        status:
          type: string
          enum:
            - pending
            - scheduled
            - applied
            - closed
        fromPlanId:
          type: string
        planId:
          type: string
        timing:
          type: string
          enum:
            - period_end
            - immediately
        refund:
          type: string
          enum:
            - none
            - prorated
        oldPlanCredits:
          type: string
          enum:
            - keep
            - expire
        overageOnPlanChange:
          type: string
          enum:
            - carry_to_renewal
            - bill_now
        effectiveAt:
          type: string
          nullable: true
          format: date-time
        refundAmountCents:
          type: integer
          nullable: true
        creditNoteId:
          type: string
          nullable: true
      required:
        - downgradeId
        - status
        - fromPlanId
        - planId
        - timing
        - refund
        - oldPlanCredits
        - overageOnPlanChange
        - effectiveAt
        - refundAmountCents
        - creditNoteId
    InternalError:
      type: object
      properties:
        error:
          type: string
          example: internal_error
        request_id:
          type: string
          nullable: true
      required:
        - error
        - request_id
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: rate_limited
      required:
        - error
  responses:
    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.