> For the complete documentation index, see [llms.txt](https://docs.sudoplatform.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sudoplatform.com/guides/virtual-cards-simulator/manage-reversals.md).

# Simulate Reversals

A reversal is a request to reverse or undo the effect of an authorization.

## Create a Simulated Reversal

A simulated reversal is created by calling the simulate reversal API and supplying the identifier of the authorization and the amount to reverse.

The `authorizationId` is the identifier of an authorization that was created by calling the [Create a Simulated Authorization](/guides/virtual-cards-simulator/manage-authorizations.md#create-a-simulated-authorization) API. The `amount` supplied as input is expressed as a multiple of the smallest unit of currency the merchant accepts. For example if the currency is US dollar then the amount is the number of US cents.

An example implementation of creating a simulated reversal is:

{% tabs %}
{% tab title="TypeScript" %}

```typescript
try {
  const result = await simulatorClient.simulateReversal({
    authorizationId: authorization.id,
    amount: 4200,
  })
} catch (error) {
  // Handle error
}
```

{% endtab %}

{% tab title="Swift" %}

```swift
do {
    let reversalInput = SimulateReversalInput(
        amount: 4200,
        authorizationId: authorization.id
    )
    let response = try await simulatorClient.simulateReversalWithInput(
        reversalInput
    )
    // Reversal has been applied
} catch let error {
    // Handle/notify the user of error
}
```

{% endtab %}

{% tab title="Kotlin" %}

```kotlin
val reversalInput = SimulateReversalInput(
    authorizationId = authorization.id,
    amount = 4200
)
launch {
    try {
        val reversal = withContext(Dispatchers.IO) {
            simulatorClient.simulateReversal(reversalInput)
        }
        // Reversal has been applied
    } catch (e: ReversalException) {
        // Handle/notify the user of exception
    }
}
```

{% endtab %}
{% endtabs %}

This API call reverses the effect of the authorization against a virtual card. If an exception occurs, the error or exception will contain a description of the fault that caused the exception.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sudoplatform.com/guides/virtual-cards-simulator/manage-reversals.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
