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

# Cancel checkout session



## OpenAPI

````yaml /api-reference/openapi.json post /checkout/sessions/{id}/cancel
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /checkout/sessions/{id}/cancel:
    post:
      tags:
        - Checkout
      summary: Cancel checkout session
      operationId: cancelCheckoutSession
      parameters:
        - name: id
          in: path
          description: Checkout session ID
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CheckoutSessionResponse'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    CheckoutSessionResponse:
      type: object
      properties:
        action:
          $ref: '#/components/schemas/types.CheckoutAction'
        cancel_url:
          type: string
        cancelled_at:
          type: string
          format: date-time
        checkout_invoice_id:
          type: string
        checkout_payment_id:
          type: string
        checkout_status:
          $ref: '#/components/schemas/types.CheckoutStatus'
        completed_at:
          type: string
          format: date-time
        created_at:
          type: string
          format: date-time
        customer_id:
          type: string
        expires_at:
          type: string
          format: date-time
        failure_reason:
          type: string
        failure_url:
          type: string
        id:
          type: string
        idempotency_key:
          type: string
        metadata:
          $ref: '#/components/schemas/types.Metadata'
        next_poll_after_ms:
          type: integer
          description: >-
            NextPollAfterMs is how long a client should wait before reading
            again.

            Zero means stop — either the session is terminal, or this response
            did not

            come from a polling read.
        payment:
          $ref: '#/components/schemas/CheckoutPaymentBlock'
        payment_action:
          $ref: '#/components/schemas/types.PaymentAction'
        payment_provider:
          $ref: '#/components/schemas/types.CheckoutPaymentProvider'
        stale:
          type: boolean
          description: >-
            Stale reports that this response is stored state that was not
            checked against

            the payment provider on this request — the read was debounced, or
            the gateway

            did not answer. A UI should say "still checking" rather than
            presenting a

            stale answer as fact.
        success_url:
          type: string
        terminal:
          type: boolean
          description: >-
            Terminal reports whether the session has finished. Clients poll
            until this is

            true rather than hardcoding the status set, which would go stale if
            a status

            is ever added.
        updated_at:
          type: string
          format: date-time
    errors.ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/errors.ErrorCode'
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.CheckoutAction:
      type: string
      enum:
        - create_subscription
        - modify_subscription
        - wallet_topup
        - add_addon
        - pay_invoice
      x-enum-varnames:
        - CheckoutActionCreateSubscription
        - CheckoutActionModifySubscription
        - CheckoutActionWalletTopup
        - CheckoutActionAddAddon
        - CheckoutActionPayInvoice
      x-speakeasy-name-override: CheckoutAction
    types.CheckoutStatus:
      type: string
      enum:
        - initiated
        - pending
        - completed
        - failed
        - expired
      x-enum-varnames:
        - CheckoutStatusInitiated
        - CheckoutStatusPending
        - CheckoutStatusCompleted
        - CheckoutStatusFailed
        - CheckoutStatusExpired
      x-speakeasy-name-override: CheckoutStatus
    types.Metadata:
      type: object
      additionalProperties:
        type: string
      x-speakeasy-name-override: Metadata
    CheckoutPaymentBlock:
      type: object
      properties:
        gateway:
          type: string
        id:
          type: string
        status:
          $ref: '#/components/schemas/types.PaymentStatus'
    types.PaymentAction:
      type: object
      properties:
        type:
          $ref: '#/components/schemas/types.PaymentActionType'
        url:
          type: string
      x-speakeasy-name-override: PaymentAction
    types.CheckoutPaymentProvider:
      type: string
      enum:
        - razorpay
        - chargebee
      x-enum-varnames:
        - CheckoutPaymentProviderRazorpay
        - CheckoutPaymentProviderChargebee
      x-speakeasy-name-override: CheckoutPaymentProvider
    errors.ErrorCode:
      type: string
      enum:
        - http_client_error
        - system_error
        - internal_error
        - not_found
        - already_exists
        - version_conflict
        - validation_error
        - invalid_operation
        - permission_denied
        - database_error
        - service_unavailable
        - too_many_requests
        - not_implemented
      x-enum-varnames:
        - ErrCodeHTTPClient
        - ErrCodeSystemError
        - ErrCodeInternalError
        - ErrCodeNotFound
        - ErrCodeAlreadyExists
        - ErrCodeVersionConflict
        - ErrCodeValidation
        - ErrCodeInvalidOperation
        - ErrCodePermissionDenied
        - ErrCodeDatabase
        - ErrCodeServiceUnavailable
        - ErrCodeTooManyRequests
        - ErrCodeNotImplemented
      x-speakeasy-name-override: ErrorCode
    types.PaymentStatus:
      type: string
      enum:
        - INITIATED
        - PENDING
        - PROCESSING
        - SUCCEEDED
        - OVERPAID
        - FAILED
        - REFUNDED
        - PARTIALLY_REFUNDED
        - VOIDED
      x-enum-varnames:
        - PaymentStatusInitiated
        - PaymentStatusPending
        - PaymentStatusProcessing
        - PaymentStatusSucceeded
        - PaymentStatusOverpaid
        - PaymentStatusFailed
        - PaymentStatusRefunded
        - PaymentStatusPartiallyRefunded
        - PaymentStatusVoided
      x-speakeasy-name-override: PaymentStatus
    types.PaymentActionType:
      type: string
      enum:
        - checkout_url
        - payment_link
      x-enum-varnames:
        - PaymentActionTypeCheckoutURL
        - PaymentActionTypePaymentLink
      x-speakeasy-name-override: PaymentActionType
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````