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

# Cancel a subscription now or at a future date

> Use this endpoint to cancel a subscription now or at a future
date, given the unique identifier allocated by Bango for the
subscription. This endpoint returns the updated subscription
record.

If set to a future date, API consumers might want to show users
that date. In the updated record, use the `cancelledDate` field.

If you set a future date, either using `requestedDate` or by
setting `entitlementPolicy` to `END_OF_TERM`, the subscription
remains in state `ACTIVE` and the `cancelledDate` field is set.
For these subscriptions, you can undo the cancellation
("uncancel") using `POST
/subscription/{subscriptionId}/uncancel`. Subscriptions in state
`CANCELLED` may not be uncancelled.

Note that there is no automatic refund of advance payments if a
subscription is cancelled before the next billing date.



## OpenAPI

````yaml /openapi/legacy/subscriptions/partner-to-bango/openapi.yaml delete /subscription/{subscriptionId}
openapi: 3.0.1
info:
  title: Bango Subscriptions API
  version: 1.4.0
  description: |-
    Manage user subscriptions to products and services.

    ### Change log
    - 1.4.0: 
        - Adding Plan Management API methods
          - Add `POST /plan`
          - Add `GET /plan/{planName}`
          - Add `GET /plan/{planId}`
          - Add `GET /plans`
        - Support for additional character types  as the first character of `planName`'s 
    - 1.3.0:
        - Add `productName` update functionality to `PUT /subscription/{subscriptionId}`
    - 1.2.0:
        - Move to OpenAPI 3.0.1 and refactor
        - Synchronize with API behavior
    - 1.1.0:
        - Remove `billingPolicy`, `useRequestedDateForBilling` from `DELETE /subscription/{subscriptionId}/cancel`
    - 1.0.0:
        - Add `merchantAccountKey` to `POST` and `GET`
    - 0.0.1:
        - Initial release
  contact:
    name: Bango Support
    url: https://bango.com
    email: support@bango.com
  termsOfService: https://bango.com/privacy
servers:
  - url: https://virtserver.swaggerhub.com/BangoProducts/Subscriptions-API/1.4.0
security:
  - basicAuth: []
tags:
  - name: echo
    description: Service availability
  - name: subscriptions
    description: Subscription management
  - name: plans
    description: Plan management
externalDocs:
  description: Bango developer documentation
  url: https://developer.bango.com
paths:
  /subscription/{subscriptionId}:
    delete:
      tags:
        - subscriptions
      summary: Cancel a subscription now or at a future date
      description: |-
        Use this endpoint to cancel a subscription now or at a future
        date, given the unique identifier allocated by Bango for the
        subscription. This endpoint returns the updated subscription
        record.

        If set to a future date, API consumers might want to show users
        that date. In the updated record, use the `cancelledDate` field.

        If you set a future date, either using `requestedDate` or by
        setting `entitlementPolicy` to `END_OF_TERM`, the subscription
        remains in state `ACTIVE` and the `cancelledDate` field is set.
        For these subscriptions, you can undo the cancellation
        ("uncancel") using `POST
        /subscription/{subscriptionId}/uncancel`. Subscriptions in state
        `CANCELLED` may not be uncancelled.

        Note that there is no automatic refund of advance payments if a
        subscription is cancelled before the next billing date.
      operationId: delete-subscription-by-id
      parameters:
        - $ref: '#/components/parameters/IdempotencyHeader'
        - $ref: '#/components/parameters/SubscriptionId'
        - name: requestedDate
          in: query
          description: >-
            The YYYY-MM-DD UTC date on which the subscription should end.


            Ignored if `entitlementPolicy` is set.


            If this date is in the past, equivalent to `entitlementPolicy`
            `IMMEDIATE`.
          schema:
            type: string
            format: date
        - name: entitlementPolicy
          in: query
          description: >-
            IMMEDIATE - is hard cancel, also revoke (user does not have more
            access to the service) . END_OF_TERM - is soft cancel (user still
            has access for the entire paid period)
          schema:
            type: string
            default: IMMEDIATE
            enum:
              - IMMEDIATE
              - END_OF_TERM
      responses:
        '200':
          description: Subscription cancelled
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuccessResponse'
        '400':
          $ref: '#/components/responses/ErrorBadRequest'
        '401':
          $ref: '#/components/responses/ErrorUnauthorized'
        '404':
          $ref: '#/components/responses/ErrorSubscriptionNotFound'
        '429':
          $ref: '#/components/responses/ErrorTooManyRequests'
        '500':
          $ref: '#/components/responses/ErrorUnexpected'
        '503':
          $ref: '#/components/responses/ErrorUnavailable'
components:
  parameters:
    IdempotencyHeader:
      name: X-RequestIdentifier
      in: header
      description: >-
        An arbitrary, optional, globally unique identifier for the request. If
        present, this ID is used for idempotency.
      schema:
        type: string
    SubscriptionId:
      name: subscriptionId
      in: path
      required: true
      description: The unique identifier generated by Bango for a subscription.
      schema:
        $ref: '#/components/schemas/SubscriptionId'
  schemas:
    SuccessResponse:
      type: object
      properties:
        responseCode:
          description: Always 'OK'
          type: string
          enum:
            - OK
        responseMessage:
          type: string
          example: Success
      required:
        - responseCode
        - responseMessage
    SubscriptionId:
      description: >-
        The unique identifier generated by Bango for a subscription. This is a
        globally unique, opaque string
      type: string
      format: uuid
      example: 123e4567-e89b-12d3-a456-426614174000
  responses:
    ErrorBadRequest:
      description: Bad request
      content:
        application/json:
          schema:
            type: object
            properties:
              responseCode:
                description: Always 'BAD_REQUEST'
                type: string
                enum:
                  - BAD_REQUEST
              responseMessage:
                type: string
                example: Invalid request
            required:
              - responseCode
              - responseMessage
    ErrorUnauthorized:
      description: User is not authorized to access the endpoint
      content:
        application/json:
          schema:
            type: object
            properties:
              responseCode:
                description: Always 'UNAUTHORIZED'
                type: string
                enum:
                  - UNAUTHORIZED
              responseMessage:
                type: string
                example: Invalid access credential
            required:
              - responseCode
              - responseMessage
    ErrorSubscriptionNotFound:
      description: Subscription not found
      content:
        application/json:
          schema:
            type: object
            properties:
              responseCode:
                description: Always 'NOT_FOUND'
                type: string
                enum:
                  - NOT_FOUND
              responseMessage:
                type: string
                example: Subscription not found
            required:
              - responseCode
              - responseMessage
    ErrorTooManyRequests:
      description: Too many requests
      content:
        application/json:
          schema:
            type: object
            properties:
              responseCode:
                description: Always 'TOO_MANY_REQUESTS'
                type: string
                enum:
                  - TOO_MANY_REQUESTS
              responseMessage:
                type: string
                example: Request limit reached. Please try again later
            required:
              - responseCode
              - responseMessage
    ErrorUnexpected:
      description: Unexpected error
      content:
        application/json:
          schema:
            type: object
            properties:
              responseCode:
                description: Always 'INTERNAL_ERROR'
                type: string
                enum:
                  - INTERNAL_ERROR
              responseMessage:
                type: string
                example: >-
                  The server encountered an unexpected condition which prevented
                  it from fulfilling the request
            required:
              - responseCode
              - responseMessage
    ErrorUnavailable:
      description: Service unavailable
      content:
        application/json:
          schema:
            type: object
            properties:
              responseCode:
                description: Always 'SERVICE_UNAVAILABLE'
                type: string
                enum:
                  - SERVICE_UNAVAILABLE
              responseMessage:
                type: string
                example: >-
                  The server is undergoing maintenance and is not available.
                  Please, try again later
            required:
              - responseCode
              - responseMessage
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Base64 encoding of username:password as supplied by Bango Support

````