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

# Reverse a transaction

> Cancel all or part of an uncaptured authorization to release the hold on the cardholder's account using the reverse transaction mutation.

Reversals are used to cancel previous transaction requests.
Authorization reversals notify the cardholder's issuer that all or part of a transaction has been canceled and that the authorization hold should be released.
You cannot reverse an authorization that has been captured and has had money withdrawn from the customer's
account. For those transactions, you would need to submit a [refund](/acquiring/transaction-processing/refund-transaction). Reversals cannot be applied on previously reversed transaction or account verifications.

<Tip type="when to use">
  **When to Use**

  <ul>
    <li>You need to cancel all or part of an authorization.</li>
    <li>The authorization cannot be captured within 10 days.</li>
  </ul>
</Tip>

<Callout icon="clapperboard-play" color="#6938EF" type="scenario">
  **Scenario**

  Ben makes a purchase from Maple Street Coffee, one of Clearpath Payment's acceptors. After he finishes checking out, he realizes he already bought the same item last week and cancels the order minutes later. Because the authorization has not been captured yet, Clearpath Payments is able to reverse the authorization on behalf of Maple Street Coffee.
</Callout>

### Steps

1. Retrieve the `transactionId` from the previous transaction you need to reverse. This is how we link the reversal to its previous transaction.

   <Note>
     Reversal mutations differ from the other transaction mutations (i.e.,
     [captures](/acquiring/transaction-processing/capture-authorization), [incremental
     authorizations](/acquiring/transaction-processing/increment-authorization), and
     [refunds](/acquiring/transaction-processing/refund-transaction)) in that you must reference the
     previous transaction's `transactionId` instead of the `paymentId`. This is because
     `transactionId` targets the specific transaction in the payment life cycle to be reversed,
     whereas `paymentId` identifies the cohort of related transactions within a payment.
   </Note>

2. Run the [reverseTransaction](/acquiring/reference/graphql/operations/reversetransaction) mutation, passing in the pertinent inputs

   | Required input             | Description                                                                                                                                                                                               |
   | -------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
   | `transactionId`            | The unique "payment ID" returned on the original, approved authorization, used to tie that transaction together with this incremental authorization.                                                      |
   | `acceptorID`               | The unique, 36 character identifier assigned to the entity providing the goods or services to the cardholder. Other processors may refer to this as the Merchant ID (MID), Outlet ID, or Customer number. |
   | `transactionReference`     | The unique transaction identifier created by YOU to distiniguish this transaction from another.                                                                                                           |
   | `transactionAmountDetails` | The transaction currency and amount to be refunded. You can refund the full amount or only a portion of it. If you do not specify an amount, Tesouro will by default refund the full amount.              |

<RequestExample>
  ```graphql Operation lines expandable theme={null}
  mutation reverseTransaction($input: ReverseTransactionInput!) {
    reverseTransaction(reverseTransactionInput: $input) {
      reverseTransactionResponse {
        status: __typename
        activityDate
        transactionId
        paymentId
        activityDate
      }
      errors {
        errorType: __typename
        ... on RuleInViolationError {
          explanationOfRule
          advice
        }
        ... on ValidationFailureError {
          fieldName
          fieldPath
          valueInError
        }
        ... on IGraphQlError {
          message
          transactionId
          processorResponseCode
        }
      }
    }
  }
  ```

  ```json Variables lines theme={null}
  {
    "input": {
      "transactionId": "b2a92262-4c17-11ee-900c-7944c7cf2a3c",
      "acceptorId": "05a39b14-f29f-443b-a107-da3e3e8969fb",
      "transactionReference": "reference-1"
    }
  }
  ```
</RequestExample>

<ResponseExample>
  ```json title="Response" lines theme={null}
  {
    "data": {
      "reverseTransaction": {
        "transactionInformation": {
          "paymentId": "64495c8b-4c0f-11ee-bf97-0e7d489d8cb0"
        }
      }
    }
  }
  ```
</ResponseExample>
