# Refunds using the RefundTransaction API

Source: https://developer.avalara.com/ecommerce-integration-guide/transactions/refunds/refunds-with-refundtransactions/

As previously stated, the [RefundTransaction API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/RefundTransaction/) allows you to quickly and easily create a `ReturnInvoice` representing a refund for a previously created `SalesInvoice` transaction. You can choose to create a full or partial refund, and specify individual line items from the original sale for refund.

The RefundTransaction API ensures that the tax amount you refund to the customer exactly matches the tax that was calculated during the original transaction, regardless of any changes to your company's configuration, rules, tax jurisdictions, or any other setting.

This API provides a shortcut to quickly and accurately generate a refund for the following common refund scenarios:

-   A full refund of a previous sale using `refundType="Full"`

-   Refund the tax that was charged on a previous sale, when the customer provides an exemption certificate after the purchase using `refundType="TaxOnly"`

-   Refund one or more items (lines) from a previous sale using `refundType="Partial"`

-   Granting a customer a percentage refund of a previous sale using `refundType="Percentage"`

**Advice**:  
You can't use the RefundTransaction API to refund a partial dollar amount or partial quantity. Use the CreateTransaction API with a `ReturnInvoice` doc `type` and negative dollar value for these types of partial refunds.

## Recommendations and requirements

-   Refunds can be made for documents that have been committed and where the tax has been paid to the appropriate jurisdiction.

-   Refunds can be made for locked transactions.

-   The `refundTransactionCode` in the return invoice must match the transaction `code` of the original sale.

-   Set the `refundDate` to the date when the return is being processed. This will override the date used for tax calculation so that the same taxes are calculated as on the original order. Don’t use the date of the original order.

-   If doing a partial transaction, pass only the line items being returned. Don’t include the line items that won’t be returned.

## Example request

The example below shows a refund request using the RefundTransaction API. After successful completion, the refunded item will be reversed on your tax reporting and will appear essentially as a “credit” on the current month’s tax liability. In the request URL, the company code is `DEFAULT`, and the code for the original transaction is `TestTransaction1`.

[![Closed](https://avalara-devdocs-prod.mcoutput.com/avatax-for-ecom/Content/Skins/Default/Stylesheets/Images/transparent.gif)Example](javascript:void\(0\);)

```
curl  -X POST  -H 'Accept: application/json'  -H 'Authorization: Basic ${btoa!(`:`)}'  -H 'Content-Type: application/json'  --data '{    "refundTransactionCode": "RefundTransaction1",    "refundDate": "2024-07-12",    "refundType": "Full",    "referenceCode": "Refund for a committed transaction"  }'  'https://sandbox-rest.avatax.com/api/v2/companies/DEFAULT/transactions/TestTransaction1/refund' 
```