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

# Cancel Subscription

> Cancel a subscription either immediately or at the end of the current billing period.



## OpenAPI

````yaml POST /subscription/{id}/cancel
openapi: 3.1.0
info:
  title: Clink API
  description: >-
    Official API documentation for Clink's payment processing platform. This API
    enables merchants to create and manage payment sessions, handle
    subscriptions, and process transactions.
  version: 1.0.0
servers:
  - url: https://uat-api.clinkbill.com/api/
security:
  - ApiKeyAuth: []
    timestamp: []
paths:
  /subscription/{id}/cancel:
    post:
      tags:
        - Subscription API
      summary: Cancel Subscription
      description: >-
        Cancel a subscription either immediately or at the end of the current
        billing period.
      operationId: cancelSubscription_1
      parameters:
        - name: id
          in: path
          description: Unique identifier of the subscription
          required: true
          schema:
            type: string
      requestBody:
        description: Cancel subscription request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelSubscriptionApiRequest'
            examples:
              cancelAtPeriodEnd:
                summary: Cancel at period end
                value:
                  cancelReasonCode: no_longer_needed
                  reason: No longer needed
                  cancelImmediately: false
              cancelImmediately:
                summary: Cancel immediately
                value:
                  cancelReasonCode: no_longer_needed
                  reason: No longer needed
                  cancelImmediately: true
        required: true
      responses:
        '200':
          description: updated subscription
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/SubscriptionApiResponse'
        '401':
          description: Unauthorized
          content:
            '*/*':
              schema:
                type: string
components:
  schemas:
    CancelSubscriptionApiRequest:
      required:
        - reason
      type: object
      properties:
        cancelReasonCode:
          type: string
          description: Allowed cancel reason codes
          enum:
            - too_expensive
            - need_more_features
            - found_alternative
            - no_longer_needed
            - poor_customer_service
            - poor_usability
            - poor_quality
            - other_reasons
        reason:
          maxLength: 255
          minLength: 1
          type: string
        cancelImmediately:
          type: boolean
          description: >-
            Whether to cancel the subscription immediately. true cancels
            immediately without refund; false or omitted cancels at the end of
            the current billing period.
          default: false
    SubscriptionApiResponse:
      type: object
      properties:
        code:
          type: integer
          format: int32
        msg:
          type: string
        data:
          $ref: '#/components/schemas/SubscriptionApiData'
    SubscriptionApiData:
      required:
        - billing
        - createTime
        - customerId
        - paymentInstrumentId
        - paymentMethodType
        - priceId
        - priceSnapshotId
        - productId
        - quantity
        - recurringInvoiceItem
        - status
        - subscriptionId
      type: object
      properties:
        merchantReference:
          type: string
        subscriptionId:
          type: string
        sessionId:
          type: string
        customerId:
          type: string
        productId:
          type: string
        priceId:
          type: string
        priceSnapshotId:
          type: string
        createTime:
          type: integer
          format: int64
        quantity:
          type: integer
          format: int32
        paymentMethodType:
          type: string
        paymentInstrumentId:
          type: string
        trialStart:
          type: integer
          format: int64
        trialEnd:
          type: integer
          format: int64
        currentPeriodStart:
          type: integer
          format: int64
        currentPeriodEnd:
          type: integer
          format: int64
        cancelAt:
          type: integer
          format: int64
        cancelAtPeriodEnd:
          type: boolean
        canceledAt:
          type: integer
          format: int64
        cancelReason:
          type: string
        status:
          type: string
        billing:
          type: string
        currency:
          type: string
          enum:
            - USD
            - EUR
            - JPY
            - GBP
            - AUD
            - CAD
            - CNY
            - HKD
            - SGD
            - KRW
            - AED
            - THB
            - IDR
            - PHP
            - MYR
            - BRL
            - INR
        recurringInvoiceItem:
          $ref: '#/components/schemas/InvoiceItemVo'
        upcomingInvoiceItem:
          $ref: '#/components/schemas/InvoiceItemVo'
        scheduledPhases:
          type: array
          description: >-
            Remaining scheduled subscription plan changes that have not taken
            effect yet.
          items:
            $ref: '#/components/schemas/ScheduledPhase'
        elapsedCycles:
          type: integer
          description: >-
            Number of billing period boundaries already crossed. Compare this
            with scheduledPhases.effectiveCycle to determine when a remaining
            phase takes effect.
          format: int32
        metadata:
          type: object
          additionalProperties:
            type: string
    InvoiceItemVo:
      type: object
      properties:
        invoiceItemId:
          type: string
        amount:
          type: number
        discountAmount:
          type: number
        paymentAmount:
          type: number
        couponTerms:
          type: string
        promotionCode:
          type: string
        currency:
          type: string
          enum:
            - USD
            - EUR
            - JPY
            - GBP
            - AUD
            - CAD
            - CNY
            - HKD
            - SGD
            - KRW
            - AED
            - THB
            - IDR
            - PHP
            - MYR
            - BRL
            - INR
        periodStart:
          type: integer
          format: int64
        periodEnd:
          type: integer
          format: int64
        proration:
          type: boolean
        price:
          $ref: '#/components/schemas/PriceVo'
    ScheduledPhase:
      required:
        - sequence
        - effectiveCycle
        - priceSnapshotId
        - quantity
      type: object
      description: >-
        A scheduled subscription plan change that takes effect at a future
        billing period boundary.
      properties:
        sequence:
          minimum: 1
          type: integer
          description: >-
            Position of this phase in the schedule. Values must be strictly
            increasing.
          format: int32
        effectiveCycle:
          minimum: 1
          type: integer
          description: >-
            The renewal boundary when this phase takes effect, counted from
            subscription creation. Values must be strictly increasing.
          format: int32
        priceSnapshotId:
          type: string
          description: >-
            Target subscription price snapshot ID. The snapshot must exist, have
            priceType=SUBSCRIBE with valid recurring details, and support the
            subscription payment currency.
        quantity:
          minimum: 1
          type: integer
          description: Target quantity for the scheduled phase.
          format: int32
        metadata:
          type: object
          description: >-
            Optional metadata for this scheduled phase. Maximum 20 keys. Key
            length must be 40 characters or fewer and string value length must
            be 500 characters or fewer.
          maxProperties: 20
          propertyNames:
            maxLength: 40
          additionalProperties:
            type: string
            maxLength: 500
    PriceVo:
      type: object
      properties:
        productId:
          type: string
        productName:
          type: string
        priceId:
          type: string
        priceSnapshotId:
          type: string
        unitAmount:
          type: number
        quantity:
          type: integer
          format: int32
        recurring:
          $ref: '#/components/schemas/Recurring'
    Recurring:
      required:
        - interval
        - pricingModel
        - tiersMode
      type: object
      properties:
        interval:
          type: string
          enum:
            - week
            - month
            - year
            - day
            - quarter
            - half_year
            - custom
          description: >-
            Frequency of recurring charges. `quarter` bills every 3 months,
            `half_year` bills every 6 months, and `custom` uses interval count
            to define the cycle.
        trialPeriodDays:
          type: integer
          description: Number of days in the trial period
          format: int32
        pricingModel:
          type: string
          enum:
            - flat_rate
            - per_seat
          description: >-
            Billing model (flat_rate, per_seat, with tiered and usage_based
            models coming soon)
        tiersMode:
          type: string
          enum:
            - volume
            - graduated
          description: >-
            Coming soon. Tiered pricing mode, can be volume (quantity-based) or
            graduated (incremental tiers)
        intervalCount:
          type: integer
          description: >-
            Number of interval units per billing cycle. For custom intervals,
            this value represents the number of days.
          format: int32
      description: Recurring billing configuration information
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
      description: >-
        Your secret API key obtained from the Clink dashboard (Developers
        section)
    timestamp:
      type: apiKey
      in: header
      name: X-Timestamp
      description: >-
        Current timestamp in milliseconds since Unix epoch (required for request
        signing)

````