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

# Cancel a subscription

> Schedules a cancellation for a subscription. The `effective` timing can be a keyword (e.g. `immediate`, `end_of_term`) or a specific date. A cancellation reason code is required and a free-text note is optional.



## OpenAPI

````yaml /api-reference/specs/2026-04-01.json post /subscriptions/{id}/cancel
openapi: 3.1.0
info:
  description: >-
    Alguna is the AI-native quote-to-revenue platform for B2B companies: CPQ,
    subscription and usage-based billing, invoicing, payment collection, and
    revenue recognition in one system of record. The API operates on one
    versioned agreement per customer: quotes, subscriptions and their versions,
    usage, invoices, payments, and revenue schedules read from it. Official
    SDKs: TypeScript (@alguna/sdk), Python (alguna), Go
    (github.com/alguna-io/alguna-go), Rust (alguna), and the alguna CLI
    (@alguna/cli).
  title: Alguna Public API
  version: '2026-04-01'
servers:
  - url: https://api.alguna.io
    x-fern-server-name: Production
security:
  - bearerAuth: []
tags:
  - name: Billing Events and Metrics
  - name: Checkout Sessions
  - name: Credit Notes
  - name: Credits
  - name: Customer Portal Sessions
  - name: Customers
  - name: Feedback
  - name: Insights
  - name: Integrations
  - name: Invoices
  - name: Merchants
  - name: Payments
  - name: Plans
  - name: Product Bundles
  - name: Products
  - name: Quotes
  - name: Refunds
  - name: Revenue Schedules
  - name: Subscription Changes
  - name: Subscription Versions
  - name: Subscriptions
  - name: Tags
  - name: Tax
  - name: Users
  - name: Wallet Grants
  - name: Wallets
paths:
  /subscriptions/{id}/cancel:
    post:
      tags:
        - Subscriptions
      summary: Cancel a subscription
      description: >-
        Schedules a cancellation for a subscription. The `effective` timing can
        be a keyword (e.g. `immediate`, `end_of_term`) or a specific date. A
        cancellation reason code is required and a free-text note is optional.
      operationId: cancel-subscription
      parameters:
        - in: header
          name: Alguna-Version
          required: true
          schema:
            enum:
              - '2026-04-01'
            type: string
        - in: header
          name: Idempotency-Key
          schema:
            description: >-
              A unique string that makes a retried write safe. If you send the
              same request with the same key within 24 hours, the API returns
              the stored response and does not run the request again. A 5xx or
              429 response is not stored, so a retry with that key runs the
              request again.
            example: ik_a1b2c3d4e5f6
            maxLength: 255
            type: string
        - in: path
          name: id
          required: true
          schema:
            description: Unique identifier for the subscription
            type: string
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CancelSubscriptionRequest'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SubscriptionResponse'
          description: Success
          headers:
            Idempotency-Key:
              description: Echo of the idempotency key provided in the request
              schema:
                type: string
            Idempotent-Replayed:
              description: >-
                Whether this response was replayed from a previous request
                (true) or freshly executed (false)
              schema:
                type: boolean
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Bad Request
        '401':
          content:
            application/json:
              schema:
                oneOf:
                  - $ref: '#/components/schemas/ErrorResponse'
                  - $ref: '#/components/schemas/GatewayErrorResponse'
          description: Unauthorized
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Forbidden — the organization does not have access to this feature
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Not Found
        '409':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: >-
            Conflict — a request with this idempotency key is currently being
            processed
          headers:
            Retry-After:
              description: >-
                Seconds to wait before retrying with the same idempotency key.
                Sent only when a request with this key is still being processed;
                a 409 without it is a conflict that a retry will not resolve.
              schema:
                type: integer
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Unprocessable Entity
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: Internal Server Error
        '502':
          description: >-
            Bad Gateway — sent by the infrastructure in front of the API; the
            body is not JSON. Safe to retry.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: >-
            Service Unavailable — a dependency is temporarily unavailable. Retry
            with backoff.
        '504':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
          description: >-
            Gateway Timeout — the request did not finish in time. Retry with
            backoff; use an idempotency key for writes.
components:
  schemas:
    CancelSubscriptionRequest:
      properties:
        effective:
          description: When cancellation takes effect
          example: end_of_term
          nullable: true
          type: string
        reason:
          allOf:
            - $ref: '#/components/schemas/SubscriptionCancelationReason'
          description: Cancellation reason
          example: no_longer_required
        reason_description:
          description: Additional context for the cancellation
          example: Customer is consolidating vendors
          nullable: true
          type: string
      required:
        - reason
      type: object
    SubscriptionResponse:
      properties:
        activated_at:
          description: When the subscription was activated
          example: '2026-01-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        approval:
          allOf:
            - $ref: '#/components/schemas/SubscriptionApprovalResponse'
          description: >-
            The approval of the subscription's creation: its activation or its
            send. approval.status tells that a new subscription waits for
            approval or was rejected. The approval of a change to a live
            subscription is in open_change.
        assignments:
          description: Users assigned to the subscription, such as its owner
          items:
            $ref: '#/components/schemas/SubscriptionAssignment'
          type: array
        billing:
          allOf:
            - $ref: '#/components/schemas/BillingResponse'
          description: Billing configuration
        contract:
          allOf:
            - $ref: '#/components/schemas/ContractResponse'
          description: Contract configuration
        created_at:
          description: When the subscription was created
          example: '2025-12-15T10:30:00Z'
          format: date-time
          type: string
        currency:
          description: ISO 4217 currency code
          example: USD
          type: string
        current_version_id:
          description: Current active version ID
          example: subv_abc123
          nullable: true
          type: string
        customer_id:
          description: Customer ID
          example: cust_abc123
          type: string
        discount:
          allOf:
            - $ref: '#/components/schemas/DiscountResponse'
          description: Subscription-level discount
          nullable: true
        id:
          description: Unique identifier
          example: sub_abc123
          type: string
        maximum_spend:
          allOf:
            - $ref: '#/components/schemas/SpendingThresholdResponse'
          description: Maximum spend threshold
          nullable: true
        metadata:
          description: Key-value metadata
          type: object
        minimum_spend:
          allOf:
            - $ref: '#/components/schemas/SpendingThresholdResponse'
          description: Minimum spend threshold
          nullable: true
        name:
          description: Subscription name
          example: Acme Corp - Enterprise
          type: string
        open_change:
          allOf:
            - $ref: '#/components/schemas/OpenChangeResponse'
          description: >-
            The open direct change of the subscription, when one waits. A
            dashboard user resolves a waiting, rejected or stale change
          nullable: true
        pending_changes:
          description: Pending version changes
          items:
            $ref: '#/components/schemas/PendingChangeResponse'
          type: array
        plan_id:
          description: Plan ID
          example: pln_abc123
          nullable: true
          type: string
        price_escalation:
          allOf:
            - $ref: '#/components/schemas/PriceEscalationResponse'
          description: Price escalation configuration
          nullable: true
        renewal:
          allOf:
            - $ref: '#/components/schemas/RenewalResponse'
          description: Renewal configuration
        status:
          description: Subscription status
          enum:
            - draft
            - active
            - canceled
            - approved
            - ended
          example: active
          type: string
        trial_period_days:
          description: Trial period in days
          example: 30
          format: int64
          nullable: true
          type: integer
        updated_at:
          description: When the subscription was last updated
          example: '2026-04-04T10:00:05Z'
          format: date-time
          type: string
      required:
        - approval
        - assignments
        - billing
        - contract
        - created_at
        - currency
        - customer_id
        - id
        - metadata
        - name
        - pending_changes
        - renewal
        - status
        - updated_at
      type: object
    ErrorResponse:
      description: The body of every error the API returns.
      properties:
        code:
          description: >-
            Machine-readable error code, such as `not_found` or
            `invoice_already_issued`. New codes may be added at any time, so
            handle a code you do not know by its HTTP status.
          type: string
        detail:
          description: Explanation of what went wrong
          type: string
        request_id:
          description: >-
            Identifies the request, as the `X-Request-Id` response header does.
            Quote it when contacting support.
          type: string
        status:
          description: HTTP status code of the response
          format: int64
          type: integer
        title:
          description: >-
            HTTP status text. Sent only by version, idempotency and
            credit-refusal errors.
          type: string
        type:
          description: Always `about:blank`. Sent only by version and idempotency errors.
          type: string
      required:
        - status
        - detail
      type: object
    GatewayErrorResponse:
      description: >-
        Returned by the API gateway when a request carries no valid API key,
        before the API handles it.
      properties:
        code:
          description: Machine-readable error code, e.g. `unauthenticated`
          type: string
        details:
          nullable: true
          type: object
        message:
          description: Explanation of what went wrong
          type: string
      required:
        - code
        - message
      type: object
    SubscriptionCancelationReason:
      enum:
        - no_longer_required
        - moving_provider
        - pricing
        - support
        - features
        - upgraded
        - other
      type: string
    SubscriptionApprovalResponse:
      properties:
        decided_at:
          description: When the approval request was decided, if decided
          example: '2026-08-21T12:00:00Z'
          format: date-time
          nullable: true
          type: string
        flow_id:
          description: >-
            The approval request. An answer that an approval stops names the
            same request in approval.flow_id.
          example: 3f2b8c1e-5d4a-4f7b-9c2e-1a6d8e0f4b21
          nullable: true
          type: string
        generation:
          description: >-
            Version of the approval request's content; it increases when the
            request is evaluated again for changed terms
          example: 1
          format: int64
          nullable: true
          type: integer
        operation:
          description: >-
            The action the approval covers: send_quote sends the subscription's
            quote once approved, manual_hold leaves the subscription for someone
            to activate or send, activate activates the subscription. Absent
            when no approval was requested.
          enum:
            - send_quote
            - manual_hold
            - activate
          example: activate
          nullable: true
          type: string
        requested_at:
          description: When the approval was requested
          example: '2026-08-21T10:00:00Z'
          format: date-time
          nullable: true
          type: string
        status:
          description: >-
            Where the creation approval stands. none: no approval was requested.
            pending: waiting for a decision. approved_manual_hold: approved, and
            waiting for someone to activate or send the subscription.
            approved_awaiting_execution: approved, and the approved action has
            not run yet. executed: approved, and the approved action ran.
            failed: approved, but the approved action failed. stale: the
            subscription changed after the request, so the approval no longer
            applies and approval must be requested again for the current terms.
            rejected: an approver rejected the request. canceled: the request
            was canceled.
          enum:
            - none
            - pending
            - approved_awaiting_execution
            - approved_manual_hold
            - executed
            - stale
            - failed
            - rejected
            - canceled
          example: pending
          type: string
      required:
        - status
      type: object
    SubscriptionAssignment:
      properties:
        type:
          description: Role the user holds on the subscription
          enum:
            - owner
          example: owner
          type: string
        user_id:
          description: User ID of the assignee; resolve it with the users endpoints
          example: usr_abc123
          type: string
      required:
        - type
        - user_id
      type: object
    BillingResponse:
      properties:
        auto_issue_invoices:
          description: Whether invoices are auto-issued
          example: true
          type: boolean
        auto_pay_invoices:
          description: Whether invoices are auto-paid
          example: false
          type: boolean
        autopay_timing:
          allOf:
            - $ref: '#/components/schemas/AutopayTiming'
          description: >-
            When auto-pay charges the subscription's invoices. When absent, the
            invoices inherit the customer's Autopay Timing.
          example: on_due_date
          nullable: true
        first_billing_date:
          description: First billing date
          example: '2026-01-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        payment_collection_method:
          allOf:
            - $ref: '#/components/schemas/PaymentCollectionMethod'
          description: How invoices are collected
          example: autopay
        payment_method_id:
          description: >-
            Saved payment method that auto-pay charges for this subscription.
            When absent, auto-pay charges the customer's default payment method.
          example: pm_01H1VECT
          nullable: true
          type: string
        payment_terms:
          description: Payment terms
          example: net_30
          nullable: true
          type: string
      required:
        - auto_issue_invoices
        - auto_pay_invoices
        - payment_collection_method
      type: object
    ContractResponse:
      properties:
        duration_months:
          description: Contract duration in months
          example: 12
          format: int64
          nullable: true
          type: integer
        end_date:
          description: Contract end date
          example: '2027-01-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        period_type:
          description: Contract period type
          enum:
            - fixed
            - monthly_rolling
          example: fixed
          type: string
        start_date:
          description: Contract start date
          example: '2026-01-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
      required:
        - period_type
      type: object
    DiscountResponse:
      properties:
        amount:
          description: Discount amount
          example: '10'
          type: string
        duration_type:
          allOf:
            - $ref: '#/components/schemas/DurationType'
          description: Duration type
          example: fixed
        duration_unit:
          description: Duration unit
          example: months
          nullable: true
          type: string
        duration_value:
          description: Duration value
          example: 6
          format: int64
          nullable: true
          type: integer
        type:
          allOf:
            - $ref: '#/components/schemas/DiscountType'
          description: Discount type
          example: percentage
      required:
        - amount
        - duration_type
        - type
      type: object
    SpendingThresholdResponse:
      properties:
        amount:
          description: Spending threshold amount
          example: '500.00'
          type: string
        billing_direction:
          allOf:
            - $ref: '#/components/schemas/BillingDirection'
          description: >-
            Whether the minimum spend is billed in advance of each period and
            drawn down by spend, or trued up in arrears
          example: arrears
        period:
          allOf:
            - $ref: '#/components/schemas/BillingInterval'
          description: Billing period for the threshold
          example: monthly
      required:
        - amount
        - period
      type: object
    OpenChangeResponse:
      properties:
        approval_status:
          description: Approval position of the change; absent until approval is requested
          enum:
            - pending_approval
            - approved
            - rejected
          example: pending_approval
          nullable: true
          type: string
        change_id:
          description: ID of the open change
          example: subchg_abc123
          type: string
        flow_id:
          description: ID of the approval flow of the change
          example: 0f8fad5b-d9cb-469f-a165-70867728950e
          nullable: true
          type: string
        progression:
          description: >-
            What happens after approval: the change applies automatically, or
            waits for a person to apply it
          enum:
            - automatic
            - manual
          example: automatic
          nullable: true
          type: string
        stale:
          description: >-
            Whether the subscription changed after the change was staged; a
            stale change cannot apply and a dashboard user withdraws it
          example: false
          type: boolean
      required:
        - change_id
        - stale
      type: object
    PendingChangeResponse:
      properties:
        description:
          description: Change description
          example: Q3 upgrade
          nullable: true
          type: string
        effective_at:
          description: When the change takes effect
          example: '2027-01-01T00:00:00Z'
          format: date-time
          nullable: true
          type: string
        status:
          description: Version status
          enum:
            - draft
            - published
          example: draft
          type: string
        version_id:
          description: Version ID
          example: subv_abc123
          type: string
      required:
        - status
        - version_id
      type: object
    PriceEscalationResponse:
      properties:
        enabled:
          description: Whether price escalation is enabled
          example: true
          type: boolean
        escalate_metered_unit_rates:
          description: Whether to escalate metered unit rates
          example: false
          nullable: true
          type: boolean
        interval_months:
          description: Interval between escalations in months
          example: 12
          format: int64
          type: integer
        percentage:
          description: Escalation percentage
          example: '5.00'
          nullable: true
          type: string
        type:
          description: Escalation type
          example: percentage
          type: string
      required:
        - enabled
        - interval_months
        - type
      type: object
    RenewalResponse:
      properties:
        auto_renew:
          description: Whether the subscription auto-renews
          example: true
          type: boolean
        duration_months:
          description: Renewal duration in months
          example: 12
          format: int64
          nullable: true
          type: integer
        period_type:
          description: Renewal period type
          enum:
            - fixed
            - monthly_rolling
          example: fixed
          nullable: true
          type: string
      required:
        - auto_renew
      type: object
    AutopayTiming:
      enum:
        - on_issue
        - on_due_date
      type: string
    PaymentCollectionMethod:
      enum:
        - manual
        - autopay
        - external
      type: string
    DurationType:
      enum:
        - fixed
        - monthly_rolling
      type: string
    DiscountType:
      enum:
        - percentage
        - fixed
      type: string
    BillingDirection:
      enum:
        - advance
        - arrears
      type: string
    BillingInterval:
      enum:
        - monthly
        - quarterly
        - semi_annual
        - yearly
      type: string
  securitySchemes:
    bearerAuth:
      bearerFormat: API Key
      description: API key authentication. Pass your API key as a Bearer token.
      scheme: bearer
      type: http
      x-fern-bearer:
        env: ALGUNA_API_KEY
        name: apiKey

````

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