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

# Revenue Recovery - Cancel

> Cancel the revenue recovery workflow of an invoice that is still in recovery: its scheduled
retries are stopped and no further recovery attempts are made. A `failed` payment moves to
`cancelled`, and a partially captured payment moves to `cancelled_post_capture`. The request
is refused with `400` when the payment is in any other state, when a retry is in progress,
or when recovery already reached a terminal status. The invoice is looked up by its merchant
reference id within the business profile given in the `X-Profile-Id` header.



## OpenAPI

````yaml post /v2/recovery/{merchant_reference_id}/cancel
openapi: 3.0.3
info:
  title: Hyperswitch - API Documentation
  description: >

    ## Get started


    Hyperswitch provides a collection of APIs that enable you to process and
    manage payments.

    Our APIs accept and return JSON in the HTTP body, and return standard HTTP
    response codes.


    You can consume the APIs directly using your favorite HTTP/REST library.


    We have a testing environment referred to "sandbox", which you can setup to
    test API calls without

    affecting production data.

    Currently, our sandbox environment is live while our production environment
    is under development

    and will be available soon.

    You can sign up on our Dashboard to get API keys to access Hyperswitch API.


    ### Environment


    Use the following base URLs when making requests to the APIs:


    | Environment   |  Base URL                          |

    |---------------|------------------------------------|

    | Sandbox       | <https://sandbox.hyperswitch.io>   |

    | Production    | <https://api.hyperswitch.io>       |


    ## Authentication


    When you sign up on our [dashboard](https://app.hyperswitch.io) and create a
    merchant

    account, you are given a secret key (also referred as api-key) and a
    publishable key.

    You may authenticate all API requests with Hyperswitch server by providing
    the appropriate key in

    the request Authorization header.


    | Key             | 
    Description                                                                                 
    |

    |-----------------|-----------------------------------------------------------------------------------------------|

    | api-key         | Private key. Used to authenticate all API requests from
    your merchant server                  |

    | publishable key | Unique identifier for your account. Used to authenticate
    API requests from your app's client  |


    Never share your secret api keys. Keep them guarded and secure.
  contact:
    name: Hyperswitch Support
    url: https://hyperswitch.io
    email: support.global@juspay.io
  license:
    name: Apache-2.0
  version: 0.1.0
servers:
  - url: https://sandbox.hyperswitch.io
    description: Sandbox Environment
security: []
tags:
  - name: Merchant Account
    description: Create and manage merchant accounts
  - name: Profile
    description: Create and manage profiles
  - name: Merchant Connector Account
    description: Create and manage merchant connector accounts
  - name: Payments
    description: Create and manage one-time payments, recurring payments and mandates
  - name: Refunds
    description: Create and manage refunds for successful payments
  - name: Mandates
    description: Manage mandates
  - name: Customers
    description: Create and manage customers
  - name: Payment Methods
    description: Create and manage payment methods of customers
  - name: Disputes
    description: Manage disputes
  - name: API Key
    description: Create and manage API Keys
  - name: Payouts
    description: Create and manage payouts
  - name: payment link
    description: Create payment link
  - name: Routing
    description: Create and manage routing configurations
  - name: Event
    description: Manage events
paths:
  /v2/recovery/{merchant_reference_id}/cancel:
    post:
      tags:
        - Revenue Recovery
      summary: Revenue Recovery - Cancel
      description: >-
        Cancel the revenue recovery workflow of an invoice that is still in
        recovery: its scheduled

        retries are stopped and no further recovery attempts are made. A
        `failed` payment moves to

        `cancelled`, and a partially captured payment moves to
        `cancelled_post_capture`. The request

        is refused with `400` when the payment is in any other state, when a
        retry is in progress,

        or when recovery already reached a terminal status. The invoice is
        looked up by its merchant

        reference id within the business profile given in the `X-Profile-Id`
        header.
      operationId: Cancel a Revenue Recovery Workflow
      parameters:
        - name: merchant_reference_id
          in: path
          description: >-
            Merchant reference id of the invoice whose revenue recovery workflow
            should be cancelled
          required: true
          schema:
            type: string
        - name: X-Profile-Id
          in: header
          description: >-
            Unique identifier of the business profile under which the invoice is
            processed.
          required: true
          schema:
            type: string
          example: pro_abcdefghijklmnop
      responses:
        '200':
          description: Revenue Recovery workflow cancelled successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RecoveryPaymentsResponse'
              example:
                id: 12_pay_01a3868d94a471219b5c4bc71638e2zc
                intent_status: cancelled
                merchant_reference_id: invoice_mbabizu24mvu3mela5njyh
        '400':
          description: >-
            The invoice cannot be cancelled: its payment is not failed or
            partially captured, a retry is in progress, or recovery already
            reached a terminal status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenericErrorResponseOpenApi'
        '404':
          description: Invoice not found
        '500':
          description: Internal server error
      security:
        - api_key: []
components:
  schemas:
    RecoveryPaymentsResponse:
      type: object
      required:
        - id
        - intent_status
      properties:
        id:
          type: string
          description: >-
            Unique identifier of the invoice in Hyperswitch against which the
            transaction has been recorded.
          example: pay_mbabizu24mvu3mela5njyhpit4
          maxLength: 30
          minLength: 30
        intent_status:
          allOf:
            - $ref: '#/components/schemas/IntentStatus'
          default: requires_confirmation
        merchant_reference_id:
          type: string
          description: >-
            Unique identifier of the invoice in the merchant's billing system
            against which the

            transaction is being recorded.
          example: invoice_mbabizu24mvu3mela5njyh
          nullable: true
          maxLength: 30
          minLength: 30
    GenericErrorResponseOpenApi:
      type: object
      required:
        - error_type
        - message
        - code
      properties:
        error_type:
          type: string
          example: invalid_request
        message:
          type: string
          example: 'Missing required param: {param}'
        code:
          type: string
          example: IR_04
    IntentStatus:
      type: string
      description: >-
        Represents the overall status of a payment intent.

        The status transitions through various states depending on the payment
        method, confirmation, capture method, and any subsequent actions (like
        customer authentication or manual capture).
      enum:
        - succeeded
        - failed
        - cancelled
        - cancelled_post_capture
        - processing
        - requires_customer_action
        - requires_merchant_action
        - requires_payment_method
        - requires_confirmation
        - requires_capture
        - partially_captured
        - partially_captured_and_capturable
        - partially_authorized_and_requires_capture
        - partially_captured_and_processing
        - conflicted
        - expired
        - review
  securitySchemes:
    api_key:
      type: apiKey
      in: header
      name: Authorization
      description: >-
        Format: `api-key=<api_key>`


        Use the API key created under your merchant account from the HyperSwitch
        dashboard. API key is used to authenticate API requests from your
        merchant server only. Don't expose this key on a website or embed it in
        a mobile application.

````

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