# Refunds using the CreateTransaction API

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

You can use the [CreateTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/) API with a document `type` of `ReturnInvoice` to create a custom refund transaction. Use this method for more complex refunds such as the following scenarios:

-   Creating a partial dollar amount refund

-   Refunding a partial quantity of items on a line instead of all quantities of a specific item

-   Creating full or partial dollar amount refunds for multitax transactions (for example, transactions that resulted in both sales tax and landed cost tax)

## Recommendations and requirements

-   You can use this method for committed documents where the tax has been paid to the appropriate tax jurisdiction.

-   You can use this method for locked transactions.

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

-   Set the transaction `date` to the date when you process the return. Don't use the date of the original order.

-   Pass only line items being returned. Don't include the line items that won't be returned.

-   Set the `amount` to a negative dollar amount and the `quantity` to a positive value.

## Example request

The example below shows how to use the CreateTransaction API to submit a refund request. After successful completion, the refunded items will be reversed on your tax reporting and will appear essentially as a “credit” on the current month’s tax liability.

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

```
{  "lines": [    {      "number":"1",      "quantity":1,      "amount":-100,      "taxCode":"P0000000",      "itemCode":"Test SKU",      "description":"Test Item Description"    }  ],  "taxOverride":{    "type": "TaxDate",    "taxDate":"2024-10-29",    "reason": "Return"  },  "addresses": {    "singleLocation":{      "line1":"100 Ravine Ln NE",      "city":"Bainbridge Island",      "region":"WA",      "country":"US",      "postalCode":"98110-2687"    }  },   "type":"ReturnInvoice",  "code":"TestTransaction1",  "companyCode":"DEFAULT",  "date":"2024-11-12",  "customerCode":"Test Customer ID",  "commit":true,  "currencyCode":"USD"}
```