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

# Cancel a subscription

> Cancel a subscription



## OpenAPI

````yaml /api-reference/openapi3.json post /subscriptions/cancel/{id}
openapi: 3.0.1
info:
  contact: {}
  description: Billing API
  title: Billing
  version: '2.0'
servers:
  - url: https://sandbox-api.paynext.com/
security: []
paths:
  /subscriptions/cancel/{id}:
    post:
      tags:
        - Subscriptions
      summary: Cancel a subscription
      description: Cancel a subscription
      parameters:
        - description: Specifies the version of the API to use
          in: header
          name: X-API-Version
          schema:
            enum:
              - 1.0.0
            type: string
            default: 1.0.0
          required: true
        - description: Subscription ID
          in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/core_model.SubscriptionResWithPlanCustomerRelationsDTO
          description: OK
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg_server.HttpResErrorDTO'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg_server.HttpResErrorDTO'
          description: Unauthorized
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg_server.HttpResErrorDTO'
          description: Not Found
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/pkg_server.HttpResErrorDTO'
          description: Internal Server Error
      security:
        - Auth: []
components:
  schemas:
    core_model.SubscriptionResWithPlanCustomerRelationsDTO:
      properties:
        created_at:
          description: >-
            The date and time at which the subscription was created in UTC
            format
          example: '2025-05-26T10:00:00Z'
          type: string
          x-order: '1'
        current_period_end:
          type: string
        cancelled_at:
          description: >-
            UTC timestamp of when the subscription became cancelled; null unless
            the subscription is cancelled
          example: '2026-06-10T14:32:08Z'
          type: string
        cancellation_details:
          description: >-
            Server-attested cancellation attribution. Always present; sub-fields
            are null unless the subscription is cancelled (or scheduled for
            cancellation).
          properties:
            reason:
              description: Why the subscription was cancelled
              enum:
                - merchant_initiated
                - past_due_max_attempts_reached
                - workflow_action
                - fraud_prevention
              example: fraud_prevention
              type: string
            trigger_payment_id:
              description: >-
                Payment that triggered a system cancellation (prefixed pay_);
                null for merchant-initiated cancels
              example: pay_e8a1b2c3-1d2e-3f4a-5b6c-7d8e9f0a1b2c
              type: string
          type: object
        current_period_start:
          type: string
        id:
          description: Unique identifier for the subscription
          example: sub_123e4567-e89b-12d3-a456-426614174000
          type: string
          x-order: '0'
        metadata:
          additionalProperties:
            type: string
          description: |-
            Custom metadata associated with the subscription
            A dictionary of key-value pairs.
          example:
            key: value
          type: object
        next_billing_date:
          description: Next scheduled billing date for the subscription
          example: '2025-06-26T12:00:00Z'
          type: string
        past_due:
          allOf:
            - $ref: '#/components/schemas/core_model.SubscriptionPastDueAttemptsInfo'
          description: Information about past due attempts
          type: object
        plan:
          $ref: '#/components/schemas/core_model.PlanCustomerResDTO'
        status:
          description: Current status of the subscription
          enum:
            - trial
            - active
            - past_due
            - cancelled
            - scheduled_for_cancellation
          type: string
        updated_at:
          description: The date and time of the last subscription update in UTC format
          example: '2025-05-27T10:00:00Z'
          type: string
          x-order: '2'
      type: object
    pkg_server.HttpResErrorDTO:
      properties:
        error:
          allOf:
            - $ref: '#/components/schemas/pkg_server.HttpErrorDTO'
          description: Description of the error
          type: object
      type: object
    core_model.SubscriptionPastDueAttemptsInfo:
      properties:
        attempt_count:
          description: Number of current attempts count
          example: 2
          type: integer
        max_attempts_count:
          description: Maximum count of attempts
          example: 7
          type: integer
      type: object
    core_model.PlanCustomerResDTO:
      properties:
        id:
          description: Unique identifier for the plan
          example: price_1a2b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
          type: string
          x-order: '0'
        interval:
          description: Type of the billing period
          enum:
            - days
            - months
            - years
          example: days
          type: string
          x-order: '4'
        interval_count:
          description: Number of billing periods per cycle
          example: 1
          type: integer
          x-order: '5'
        name:
          description: Display name of the plan
          example: Pro Plan
          type: string
          x-order: '2'
        price:
          allOf:
            - $ref: '#/components/schemas/core_model.PlanPrice'
          description: Pricing details for the plan
          type: object
          x-order: '6'
        tax:
          allOf:
            - $ref: '#/components/schemas/core_model.PlanTax'
          description: Tax info
          type: object
          x-order: '10'
        trial_interval:
          description: Type of trial period
          enum:
            - days
            - months
            - years
          example: days
          type: string
          x-order: '7'
        trial_interval_count:
          description: Length of the trial period
          example: 14
          type: integer
          x-order: '8'
        trial_price:
          allOf:
            - $ref: '#/components/schemas/core_model.PlanPrice'
          description: Trial pricing details
          type: object
          x-order: '9'
        type:
          description: Type of the plan
          enum:
            - recurring
            - one-off
          example: recurring
          type: string
          x-order: '3'
      type: object
    pkg_server.HttpErrorDTO:
      properties:
        message:
          description: Description of the error
          example: some error message
          type: string
      type: object
    core_model.PlanPrice:
      properties:
        amount:
          description: Price amount  in minor units
          example: 1999
          type: integer
        currency:
          description: >-
            The 3-letter currency code in ISO 4217 format. e.g. use USD for US
            dollars
          enum:
            - AED
            - AFN
            - ALL
            - AMD
            - AOA
            - ARS
            - AUD
            - AWG
            - AZN
            - BAM
            - BBD
            - BDT
            - BGN
            - BHD
            - BIF
            - BMD
            - BND
            - BOB
            - BRL
            - BSD
            - BTN
            - BWP
            - BYN
            - BZD
            - CAD
            - CDF
            - CHF
            - CLP
            - CNY
            - COP
            - CRC
            - CUC
            - CUP
            - CVE
            - CZK
            - DJF
            - DKK
            - DOP
            - DZD
            - EGP
            - ERN
            - ETB
            - EUR
            - FJD
            - FKP
            - GBP
            - GEL
            - GHS
            - GIP
            - GMD
            - GNF
            - GTQ
            - GYD
            - HKD
            - HNL
            - HTG
            - HUF
            - IDR
            - ILS
            - IMP
            - INR
            - IQD
            - IRR
            - ISK
            - JEP
            - JMD
            - JOD
            - JPY
            - KES
            - KGS
            - KHR
            - KMF
            - KPW
            - KRW
            - KWD
            - KYD
            - KZT
            - LAK
            - LBP
            - LKR
            - LRD
            - LSL
            - LYD
            - MAD
            - MDL
            - MGA
            - MKD
            - MMK
            - MNT
            - MOP
            - MRU
            - MUR
            - MVR
            - MWK
            - MXN
            - MYR
            - MZN
            - NAD
            - NGN
            - NIO
            - NOK
            - NPR
            - NZD
            - OMR
            - PAB
            - PEN
            - PGK
            - PHP
            - PKR
            - PLN
            - PYG
            - QAR
            - RON
            - RSD
            - RUB
            - RWF
            - SAR
            - SBD
            - SCR
            - SDG
            - SEK
            - SGD
            - SHP
            - SLE
            - SOS
            - SRD
            - SSP
            - STD
            - STN
            - SVC
            - SYP
            - SZL
            - THB
            - TJS
            - TMT
            - TND
            - TOP
            - TRY
            - TTD
            - TWD
            - TZS
            - BOV
            - COU
            - CHE
            - CHW
            - MXV
            - UGX
            - VES
            - VND
            - VUV
            - XAF
            - XCD
            - XCG
            - XOF
            - XPF
            - YER
            - USD
          example: AED
          type: string
      type: object
    core_model.PlanTax:
      properties:
        collect_tax:
          allOf:
            - $ref: '#/components/schemas/core_model.PlanTaxCollection'
          example: DEFAULT
          type: object
      type: object
    core_model.PlanTaxCollection:
      enum:
        - DEFAULT
        - COLLECT
        - DONT_COLLECT
      type: string
      x-enum-varnames:
        - PlanTaxCollectionDEFAULT
        - PlanTaxCollectionCOLLECT
        - PlanTaxCollectionDONTCOLLECT
  securitySchemes:
    Auth:
      bearerFormat: JWT
      description: >-
        Authentication header of the form `api key`, where `api key` is your
        organization api key.
      scheme: bearer
      type: http

````