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

# Cancel a subscription

> Cancel a subscription at the end of the paid period, or now. Requires the WRITE_CHARGES scope.

Ends a subscription. By default the merchant keeps access until the end of the period they paid for.


## OpenAPI

````yaml apps-api/specs/billing.json POST /app-billing/subscriptions/{id}/cancel
openapi: 3.1.0
info:
  title: 'Salesive Apps API: Billing'
  version: 1.0.0
  description: >-
    Charge the merchant a store is installed for, once or on a schedule. Every
    endpoint authenticates with an installed-app access token (prefix `app_`).
    Creating a charge or subscription never moves money: the store owner
    approves it in the dashboard first. Salesive keeps 5% of every payment and
    credits the rest to your payout store's wallet.
servers:
  - url: https://api.salesive.com/api/v1
    description: Production
security:
  - AppToken: []
paths:
  /app-billing/subscriptions/{id}/cancel:
    post:
      tags:
        - Subscriptions
      summary: Cancel a subscription
      description: >-
        By default the subscription ends at the end of the period the merchant
        already paid for, so they keep what they paid for and are not charged
        again. Pass `immediately: true` to end it now. There is no refund: money
        already paid stays paid. A subscription that is not yet active ends
        immediately. Requires `WRITE_CHARGES`. Authenticate with `Authorization:
        Bearer app_<token>`. The store is bound to the token server-side, never
        send a shop id.
      operationId: cancelSubscription
      parameters:
        - $ref: '#/components/parameters/SubscriptionId'
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                immediately:
                  type: boolean
                  default: false
                reason:
                  type: string
                  maxLength: 200
            example:
              reason: Customer asked to cancel
      responses:
        '200':
          description: The subscription, now cancelled or scheduled to end.
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/EnvelopeBase'
                  - type: object
                    properties:
                      data:
                        $ref: '#/components/schemas/Subscription'
              example:
                status: 200
                success: true
                message: Subscription cancelled
                data:
                  id: 66d1f0a3c2d4e5f6a7b8c9d1
                  reference: aps_8c21e0b4a96f47d3
                  status: active
                  name: Pro plan
                  description: null
                  amount: 10
                  currency: USD
                  interval: month
                  platformFee: 0.5
                  netAmount: 9.5
                  currentPeriodStart: null
                  currentPeriodEnd: null
                  nextChargeAt: null
                  cancelAtPeriodEnd: true
                  cancelledAt: null
                  cancelledBy: app
                  cancelReason: Customer asked to cancel
                  cycles: 0
                  failures: 0
                  lastFailureReason: null
                  test: false
                  metadata: null
                  returnUrl: null
                  confirmationUrl: null
                  expiresAt: '2026-10-27T10:30:00.000Z'
                  createdAt: '2026-10-25T10:30:00.000Z'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    SubscriptionId:
      name: id
      in: path
      required: true
      description: The subscription id.
      schema:
        type: string
  schemas:
    EnvelopeBase:
      type: object
      description: >-
        Standard Salesive response envelope. The operation-specific payload is
        carried in `data`.
      required:
        - status
        - success
        - message
      properties:
        status:
          type: integer
          description: HTTP status code, echoed in the body.
        success:
          type: boolean
          description: Whether the request succeeded.
        message:
          type: string
          description: Human-readable result message.
    Subscription:
      type: object
      description: >-
        A recurring charge. The merchant approves once and picks a wallet, then
        each period is taken from that wallet automatically.
      properties:
        id:
          type: string
        reference:
          type: string
          description: Starts with `aps_`.
        status:
          type: string
          enum:
            - pending
            - activating
            - active
            - past_due
            - cancelled
            - expired
            - declined
        name:
          type: string
        description:
          type:
            - string
            - 'null'
        amount:
          type: number
        currency:
          type: string
          enum:
            - USD
            - NGN
        interval:
          type: string
          enum:
            - month
            - year
        platformFee:
          type: number
        netAmount:
          type: number
        currentPeriodStart:
          type:
            - string
            - 'null'
          format: date-time
        currentPeriodEnd:
          type:
            - string
            - 'null'
          format: date-time
          description: >-
            The merchant has paid up to here. Keep their access on until this
            passes.
        nextChargeAt:
          type:
            - string
            - 'null'
          format: date-time
        cancelAtPeriodEnd:
          type: boolean
        cancelledAt:
          type:
            - string
            - 'null'
          format: date-time
        cancelledBy:
          type:
            - string
            - 'null'
          enum:
            - merchant
            - app
            - system
            - uninstall
            - null
        cancelReason:
          type:
            - string
            - 'null'
        cycles:
          type: integer
          description: Periods paid so far.
        failures:
          type: integer
          description: Failed renewal attempts in a row.
        lastFailureReason:
          type:
            - string
            - 'null'
        test:
          type: boolean
        metadata:
          type:
            - object
            - 'null'
        returnUrl:
          type:
            - string
            - 'null'
        confirmationUrl:
          type:
            - string
            - 'null'
          description: Present only while `pending`.
        expiresAt:
          type:
            - string
            - 'null'
          format: date-time
        createdAt:
          type: string
          format: date-time
    Envelope:
      allOf:
        - $ref: '#/components/schemas/EnvelopeBase'
        - type: object
          properties:
            data:
              description: Operation-specific payload (object, array, or null).
  responses:
    Unauthorized:
      description: Missing or invalid app access token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 401
            success: false
            message: Authentication required
            data: null
    Forbidden:
      description: The app token is missing the OAuth scope required for this operation.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 403
            success: false
            message: Insufficient scope
            data: null
    NotFound:
      description: >-
        The resource does not exist or does not belong to the installation's
        store.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Envelope'
          example:
            status: 404
            success: false
            message: Resource not found
            data: null
  securitySchemes:
    AppToken:
      type: http
      scheme: bearer
      description: >-
        Installed-app access token (prefix app_), issued by the OAuth install
        flow. The store is bound to the token server-side, never send a shop id.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.