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

# Cancel a subscription contract

> Cancels an existing subscription contract. This operation terminates all future billing and delivery cycles for the subscription. The cancellation takes effect immediately.

**Important Notes:**
- Any pending/scheduled orders will be cancelled
- The customer will receive a cancellation confirmation email if SUBSCRIPTION_CANCELLED email template is enabled
- Cancellation feedback and notes are stored for analytics and reporting
- Minimum cycle requirements ARE enforced via API (unlike internal cancellations)
- If the subscription is under a free trial period, minimum cycles are not enforced

**Validation Rules:**
- Contract must exist and belong to the authenticated shop
- Contract must not already be cancelled
- Must have completed minimum required billing cycles (unless in trial)

**Post-Cancellation:**
- Status changes to 'cancelled' (lowercase)
- Any pause settings are cleared
- Cancellation feedback and notes are saved
- Activity log entry is created
- Cancellation email is sent (if enabled)
- Any invalid discount codes are automatically removed

**Authentication:** Requires valid X-API-Key header



## OpenAPI

````yaml /subscription/admin-api-swagger.json delete /api/external/v2/subscription-contracts/{id}
openapi: 3.0.1
info:
  description: >-
    Comprehensive API documentation for managing subscriptions, payments, and
    related operations. These APIs allow you to programmatically manage
    subscription lifecycles, handle payments, configure products, and integrate
    subscription functionality into your applications.
  title: Admin APIs
  version: 0.0.1
servers:
  - url: https://subscription-admin.appstle.com
security: []
tags:
  - description: >-
      Core APIs for managing the complete subscription lifecycle including
      creation, updates, pausing, resuming, and cancellation of subscriptions.
    name: Subscription Management
  - description: >-
      APIs for managing subscription payment methods, processing payments,
      handling payment retries, and updating billing information.
    name: Subscription Payments
  - description: >-
      APIs for managing subscription contracts including delivery schedules,
      pricing, order notes, billing cycles, and shipping addresses.
    name: Subscription Contracts
  - description: >-
      APIs for managing products within subscriptions including adding,
      removing, updating quantities, and swapping products.
    name: Subscription Products
  - description: >-
      APIs for handling billing operations, payment processing, and financial
      transactions related to subscriptions.
    name: Billing & Payments
  - description: >-
      APIs for managing discounts and promotional codes applied to
      subscriptions.
    name: Subscription Discounts
  - description: >-
      APIs for managing one-time add-on products that can be purchased alongside
      recurring subscription items.
    name: Subscription One-Time Products
  - description: >-
      APIs for managing subscription plans, pricing tiers, and plan
      configurations.
    name: Subscription Plans
  - description: >-
      APIs for managing customizable product boxes and bundles where customers
      can select multiple items.
    name: Build-a-Box & Bundles
  - description: >-
      APIs for managing the product catalog including product information,
      variants, and inventory.
    name: Product Catalog
  - description: >-
      APIs for managing operational settings, configurations, and administrative
      functions.
    name: Operations & Settings
  - description: >-
      APIs powering the customer-facing portal where subscribers can manage
      their own subscriptions.
    name: Customer Portal
  - description: APIs for managing customer information, profiles, and account details.
    name: Customers
  - description: >-
      APIs for retrieving aggregated subscription data, customer subscription
      history, and account-level subscription information.
    name: Subscription Data
  - description: >-
      APIs for managing delivery profiles, shipping rates, free shipping
      configuration, and delivery method options on subscriptions.
    name: Delivery & Shipping
  - description: >-
      APIs for managing storefront customization including custom CSS, theme
      settings, label translations, and merchant-defined widget configuration.
    name: Customization
  - description: >-
      APIs for configuring cancellation flows, retention offers, cancellation
      reason management, and win-back automation.
    name: Customer Retention
paths:
  /api/external/v2/subscription-contracts/{id}:
    delete:
      tags:
        - Subscription Contracts
      summary: Cancel a subscription contract
      description: >-
        Cancels an existing subscription contract. This operation terminates all
        future billing and delivery cycles for the subscription. The
        cancellation takes effect immediately.


        **Important Notes:**

        - Any pending/scheduled orders will be cancelled

        - The customer will receive a cancellation confirmation email if
        SUBSCRIPTION_CANCELLED email template is enabled

        - Cancellation feedback and notes are stored for analytics and reporting

        - Minimum cycle requirements ARE enforced via API (unlike internal
        cancellations)

        - If the subscription is under a free trial period, minimum cycles are
        not enforced


        **Validation Rules:**

        - Contract must exist and belong to the authenticated shop

        - Contract must not already be cancelled

        - Must have completed minimum required billing cycles (unless in trial)


        **Post-Cancellation:**

        - Status changes to 'cancelled' (lowercase)

        - Any pause settings are cleared

        - Cancellation feedback and notes are saved

        - Activity log entry is created

        - Cancellation email is sent (if enabled)

        - Any invalid discount codes are automatically removed


        **Authentication:** Requires valid X-API-Key header
      operationId: deleteSubscriptionContractV2
      parameters:
        - description: >-
            The unique identifier of the subscription contract to cancel. Must
            be a valid contract ID that belongs to the authenticated shop.
          example: 123456789
          in: path
          name: id
          required: true
          schema:
            format: int64
            minimum: 1
            type: integer
        - description: >-
            Optional feedback from the customer about why they are cancelling.
            This information is valuable for understanding cancellation reasons
            and improving retention. Common values include: 'Too expensive', 'No
            longer needed', 'Found alternative', 'Quality issues', 'Delivery
            issues', 'Customer service', 'Product not as expected', etc. This
            field is stored permanently with the contract for analytics.
          example: Too expensive
          in: query
          name: cancellationFeedback
          required: false
          schema:
            maxLength: 500
            type: string
        - description: >-
            Optional internal note for recording additional cancellation
            context. This field is for internal use and not visible to
            customers. Can be used to track special circumstances, support
            ticket references, competitor information, or other relevant details
            about why the customer cancelled. This note is stored permanently
            with the contract.
          example: >-
            Customer switching to competitor X due to pricing. Support ticket
            #12345
          in: query
          name: cancellationNote
          required: false
          schema:
            maxLength: 1000
            type: string
      responses:
        '204':
          description: Subscription successfully cancelled. No content returned.
          headers:
            X-Application-Context:
              description: Application context
              schema:
                type: string
              style: simple
        '400':
          content:
            application/json:
              examples:
                Contract Not Found:
                  description: Contract Not Found
                  value:
                    detail: No subscription contract found with the specified ID
                    instance: /api/external/v2/subscription-contracts/999999999
                    status: 400
                    title: Contract does not exist
                    type: https://example.com/errors/bad-request
                Invalid Contract ID:
                  description: Invalid Contract ID
                  value:
                    detail: Contract does not belong to this shop
                    instance: /api/external/v2/subscription-contracts/123456789
                    status: 400
                    title: Invalid id
                    type: https://example.com/errors/bad-request
                Minimum Cycles Not Met:
                  description: Minimum Cycles Not Met
                  value:
                    detail: >-
                      Subscription has a minimum commitment that has not been
                      fulfilled
                    instance: /api/external/v2/subscription-contracts/123456789
                    status: 400
                    title: >-
                      UserGeneratedError:You need to complete at least 3 orders
                      before you can cancel this subscription.
                    type: https://example.com/errors/bad-request
                Shopify API Error:
                  description: Shopify API Error
                  value:
                    detail: Shopify API returned an error when attempting to cancel
                    instance: /api/external/v2/subscription-contracts/123456789
                    status: 400
                    title: >-
                      UserGeneratedError:Unable to cancel subscription at this
                      time
                    type: https://example.com/errors/bad-request
          description: Invalid request or business rule violation
        '401':
          content:
            application/json:
              example:
                detail: Valid X-API-Key header is required
                instance: /api/external/v2/subscription-contracts/123456789
                status: 401
                title: Shop does not exist
                type: https://example.com/errors/unauthorized
          description: Authentication required
        '403':
          content:
            application/json:
              example:
                detail: API key does not have permission to cancel subscriptions
                instance: /api/external/v2/subscription-contracts/123456789
                status: 403
                title: Insufficient permissions
                type: https://example.com/errors/forbidden
          description: Insufficient permissions to cancel the subscription

````