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

# Cancel Subscription

> Cancel the user's active subscription. Can cancel immediately or at the end of the current billing period.



## OpenAPI

````yaml cloud-api/openapi.json post /api/v1/payments/stripe/cancel-subscription
openapi: 3.1.0
info:
  title: Dev Kit for AI API
  description: 'API for Dev Kit for AI: Developer Toolkit for AI-Powered Web Applications'
  version: 1.6.1
servers:
  - url: https://api.devkit4ai.com
    description: Dev Kit for AI Production Server
  - url: https://api.vibecoding.ad
    description: Vibe Coding Production Server
security: []
paths:
  /api/v1/payments/stripe/cancel-subscription:
    post:
      tags:
        - Stripe Subscriptions
      summary: Cancel Subscription
      description: >-
        Cancel the user's active subscription. Can cancel immediately or at the
        end of the current billing period.
      operationId: cancel_subscription_api_v1_payments_stripe_cancel_subscription_post
      parameters:
        - name: test_mode
          in: query
          required: false
          schema:
            type: boolean
            description: Use test mode
            default: true
            title: Test Mode
          description: Use test mode
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelSubscriptionRequest'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CancelSubscriptionResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - HTTPBearer: []
components:
  schemas:
    CancelSubscriptionRequest:
      properties:
        cancel_immediately:
          type: boolean
          title: Cancel Immediately
          description: If true, cancels immediately. Otherwise cancels at period end.
          default: false
      type: object
      title: CancelSubscriptionRequest
      description: Request to cancel a subscription.
    CancelSubscriptionResponse:
      properties:
        subscription_id:
          type: string
          title: Subscription Id
        status:
          type: string
          title: Status
        cancel_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Cancel At
        cancelled_at:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Cancelled At
        message:
          type: string
          title: Message
      type: object
      required:
        - subscription_id
        - status
        - message
      title: CancelSubscriptionResponse
      description: Cancel subscription response.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    HTTPBearer:
      type: http
      scheme: bearer

````