# Using the RefundTransactions API for refunds

Source: https://developer.avalara.com/sales-tax-integration-guide/xnp8079364821636/

# Using the RefundTransactions API for refunds

Learn how to use the RefundTransaction API to create refunds for previous transactions, including full, partial, and tax-only refunds.

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, taxing jurisdictions, or any other setting.

This API is intended to be a shortcut to allow you 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"`

Tip

-   The `RefundTransaction` API can’t be used 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.
-   The `RefundTransaction` API can’t be used to for multitax transactions (for example, transactions that resulted in both sales tax and landed cost. Use the `CreateTransaction` API with a `TaxOverride` for each tax type.

## Recommendations and requirements

Understand the guidelines for processing refunds and partial transactions.

The following recommendations and requirements outline the key considerations to keep in mind when creating refund transactions:

-   Refunds can be made for documents that have been committed and where the tax has been remitted 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. Do not 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

Learn how to create a refund request using the RefundTransaction API.

Below is an example 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.

**Example**

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