> ## 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 membership contract

> Permanently cancels an active membership contract in Shopify. This operation stops all future billing and marks the membership as CANCELLED.

**Important Notes:**
- **Permanent Action**: Cancellation cannot be undone. A new membership must be created to re-subscribe.
- **Email Notification**: Cancellation email is automatically sent to the customer
- **Activity Logging**: Cancellation is logged with reason/feedback for analytics
- **Immediate Effect**: No future billing attempts will be made

**Customer Portal Restrictions:**
When called from customer portal, additional validations apply:
- **Minimum Cycles**: Cannot cancel if membership hasn't completed minimum required billing cycles
- **Frozen Memberships**: Cannot cancel memberships that are frozen until min cycle completion
- **Attribute-Based Limits**: Respects any custom attribute-based cancellation restrictions

**Cancellation Feedback:**
- Optional `cancellationFeedback` parameter to capture why customer is cancelling
- Common values: 'TOO_EXPENSIVE', 'NO_LONGER_NEEDED', 'SWITCHING_TO_COMPETITOR', 'OTHER'
- Helps merchants understand churn reasons

**Use Cases:**
- Customer requests to cancel their membership
- Merchant manually cancels membership (e.g., payment issues, customer request)
- Automated cancellation after max cycles reached

**Authentication:** Requires authenticated shop user or customer portal token



## OpenAPI

````yaml /memberships/storefront-api-swagger.json delete /memberships/cp/api/subscription-contracts/{id}
openapi: 3.0.1
info:
  description: >-
    Comprehensive API documentation for the customer-facing membership portal.
    These APIs enable customers to manage their memberships, update billing
    information, modify delivery schedules, and access their account details
    through your storefront.


    **Important**: These APIs must be called from your shop's domain (e.g.,
    https://www.myshop.com/apps/memberships/cp/api/**) and require customer
    authentication. Unauthenticated requests will return a 401 Unauthorized
    error.
  title: Storefront APIs
  version: 0.0.1
servers:
  - url: https://www.myshop.com/apps
security: []
tags:
  - description: >-
      APIs for managing Shopify delivery profiles, shipping rates, zones, and
      free shipping configuration for subscription memberships
    name: Shipping & Delivery Profiles
  - description: >-
      APIs for managing shop-level membership settings, configuration, email
      domains, webhooks, and general store information
    name: Shop Settings
  - description: >-
      APIs for integrating loyalty programs with memberships including customer
      points lookup, earn options, redeem options, and point redemption
    name: Loyalty Integration
  - description: >-
      APIs for retrieving historical discount code usage and redemption
      information for membership contracts
    name: Customer Discount History
  - description: >-
      APIs for managing membership cancellation flow settings including
      retention offers, survey questions, and cancel confirmation screens
    name: Cancellation Flow Configuration
  - description: >-
      APIs for managing membership billing attempts, recurring orders, payment
      retries, order history, and order skipping
    name: Billing & Orders
  - description: >-
      APIs for managing one-time product additions to upcoming subscription
      orders, including adding, retrieving, and removing one-off items
    name: One-Time Add-Ons
  - description: >-
      APIs for managing membership/subscription plan groups, including creating
      plans, configuring discounts, billing intervals, and assigning products to
      plans
    name: Membership Plans
  - description: >-
      APIs for managing customer retention activities including cancellation
      feedback, retention action tracking, and activity export
    name: Customer Retention
  - description: >-
      APIs for retrieving custom CSS styles applied to subscription widgets and
      customer portal for theme customization
    name: Custom CSS Styling
  - description: >-
      APIs for managing customer portal settings including UI customization,
      text labels, feature toggles, and branding options for the member
      self-service portal
    name: Customer Portal Configuration
  - description: >-
      APIs for managing membership/subscription contracts including creation,
      updates, status changes, line items, discounts, and billing operations
    name: Membership Contracts
  - description: >-
      APIs for retrieving product catalog, variants, pricing, and inventory
      information for subscription memberships
    name: Product & Inventory Data
  - description: >-
      APIs for retrieving product swap/substitution options allowing members to
      exchange subscription items based on configured swap rules and variant
      groups
    name: Product Swap Rules
  - description: APIs for managing subscription product bundles and bundle configurations.
    name: Product Bundles
  - description: APIs for managing payment methods and billing information.
    name: Customer Payment Methods
paths:
  /memberships/cp/api/subscription-contracts/{id}:
    delete:
      tags:
        - Membership Contracts
      summary: Cancel a membership contract
      description: >-
        Permanently cancels an active membership contract in Shopify. This
        operation stops all future billing and marks the membership as
        CANCELLED.


        **Important Notes:**

        - **Permanent Action**: Cancellation cannot be undone. A new membership
        must be created to re-subscribe.

        - **Email Notification**: Cancellation email is automatically sent to
        the customer

        - **Activity Logging**: Cancellation is logged with reason/feedback for
        analytics

        - **Immediate Effect**: No future billing attempts will be made


        **Customer Portal Restrictions:**

        When called from customer portal, additional validations apply:

        - **Minimum Cycles**: Cannot cancel if membership hasn't completed
        minimum required billing cycles

        - **Frozen Memberships**: Cannot cancel memberships that are frozen
        until min cycle completion

        - **Attribute-Based Limits**: Respects any custom attribute-based
        cancellation restrictions


        **Cancellation Feedback:**

        - Optional `cancellationFeedback` parameter to capture why customer is
        cancelling

        - Common values: 'TOO_EXPENSIVE', 'NO_LONGER_NEEDED',
        'SWITCHING_TO_COMPETITOR', 'OTHER'

        - Helps merchants understand churn reasons


        **Use Cases:**

        - Customer requests to cancel their membership

        - Merchant manually cancels membership (e.g., payment issues, customer
        request)

        - Automated cancellation after max cycles reached


        **Authentication:** Requires authenticated shop user or customer portal
        token
      operationId: deleteSubscriptionContract
      parameters:
        - description: Membership contract ID to cancel
          example: 123456789
          in: path
          name: id
          required: true
          schema:
            format: int64
            type: integer
        - description: Optional cancellation reason/feedback from customer
          example: TOO_EXPENSIVE
          in: query
          name: cancellationFeedback
          required: false
          schema:
            type: string
        - description: Optional cancellation note with additional details
          example: Customer found a cheaper alternative
          in: query
          name: cancellationNote
          required: false
          schema:
            type: string
      responses:
        '204':
          description: >-
            Membership successfully cancelled (no content returned).
            Cancellation email sent to customer.
        '400':
          content:
            application/json:
              examples:
                Contract Not Found:
                  description: Contract Not Found
                  value:
                    detail: Contract not found or doesn't belong to this shop
                    errorKey: notfound
                    status: 400
                    title: Bad Request
                Frozen Membership:
                  description: Membership is frozen and cannot be cancelled yet
                  value:
                    detail: >-
                      This membership is frozen until minimum billing cycles are
                      completed
                    errorKey: membership_frozen
                    status: 400
                    title: Bad Request
                Minimum Cycles Not Met:
                  description: >-
                    Customer portal attempting to cancel before minimum cycles
                    completed
                  value:
                    detail: >-
                      This membership requires a minimum of 3 billing cycles
                      before cancellation. Current cycle: 1
                    errorKey: min_cycles_not_met
                    status: 400
                    title: Bad Request
          description: Invalid request - validation failed
        '401':
          description: Authentication required
        '500':
          description: Internal server error - Shopify API failure or email sending error

````