# Refunds with the CreateTransactions API

Source: https://developer.avalara.com/avatax-dm-combined-erp/sales-tax-badge/transactions/refunds-with-create-transactions/

# Refunds with the CreateTransactions API

You can use the [CreateTransaction API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/) 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

-   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 transaction`code` in the return invoice must match the transaction`code` of the original sale.
-   Set the transaction`date` to the date when the return is being processed. Do not use the date of the original order.
-   Pass only line items being returned. Do not include the line items that will not be returned.
-   Set the`amount` value to a negative dollar amount.

## Example requests

Below are two examples that show how to create return invoices for different scdnarios. Another example is included in the Test Transactions section of the "Sales Tax Badge Milestones."

### Example 1

The example below shows a $100 refund request using the CreateTransaction API. The response details show the refunded state, county, and city sales tax amounts. 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.

Request

```
curl    -X POST    -H 'Accept: application/json'    -H 'Authorization: Basic aHR0cHdhdQNoOmY='    -H 'Content-Type: application/json'    --data '{        "lines": [          {            "number":"1",            "quantity":1,            "amount":-100,            "taxCode":"P0000000",            "itemCode":"Test SKU",            "description":"Test Item Description"          }        ],        "taxOverride":{          "type": "TaxDate",          "taxDate":"2020-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":"2020-11-12",        "customerCode":"Test Customer ID",        "commit":true,        "currencyCode":"USD"    }'    'https://sandbox-rest.avatax.com/api/v2/transactions/create'
```

Response

```
...      "details": [        {          "id": 0,          "transactionLineId": 0,          "transactionId": 0,          "country": "US",          "region": "WA",          "exemptAmount": 0,          "jurisCode": "53",          "jurisName": "WASHINGTON",          "stateAssignedNo": "",          "jurisType": "STA",          "jurisdictionType": "State",          "nonTaxableAmount": 0,          "rate": 0.065,          "tax": -6.5,          "taxableAmount": -100,          "taxType": "Sales",          "taxSubTypeId": "S",          "taxName": "WA STATE TAX",          "taxAuthorityTypeId": 45,          "taxCalculated": -6.5,          "rateType": "General",          "rateTypeCode": "G",          "unitOfBasis": "PerCurrencyUnit",          "isNonPassThru": false,          "isFee": false,          "reportingTaxableUnits": -100,          "reportingNonTaxableUnits": 0,          "reportingExemptUnits": 0,          "reportingTax": -6.5,          "reportingTaxCalculated": -6.5,          "liabilityType": "Seller"        },        {          "id": 0,          "transactionLineId": 0,          "transactionId": 0,          "country": "US",          "region": "WA",          "exemptAmount": 0,          "jurisCode": "035",          "jurisName": "KITSAP",          "stateAssignedNo": "1800",          "jurisType": "CTY",          "jurisdictionType": "County",          "nonTaxableAmount": 0,          "rate": 0,          "tax": 0,          "taxableAmount": -100,          "taxType": "Sales",          "taxSubTypeId": "S",          "taxName": "WA COUNTY TAX",          "taxAuthorityTypeId": 45,          "taxCalculated": 0,          "rateType": "General",          "rateTypeCode": "G",          "unitOfBasis": "PerCurrencyUnit",          "isNonPassThru": false,          "isFee": false,          "reportingTaxableUnits": -100,          "reportingNonTaxableUnits": 0,          "reportingExemptUnits": 0,          "reportingTax": 0,          "reportingTaxCalculated": 0,          "liabilityType": "Seller"        },        {          "id": 0,          "transactionLineId": 0,          "transactionId": 0,          "country": "US",          "region": "WA",          "exemptAmount": 0,          "jurisCode": "03736",          "jurisName": "BAINBRIDGE ISLAND",          "stateAssignedNo": "1804",          "jurisType": "CIT",          "jurisdictionType": "City",          "nonTaxableAmount": 0,          "rate": 0.025,          "tax": -2.5,          "taxableAmount": -100,          "taxType": "Sales",          "taxSubTypeId": "S",          "taxName": "WA CITY TAX",          "taxAuthorityTypeId": 45,          "taxCalculated": -2.5,          "rateType": "General",          "rateTypeCode": "G",          "unitOfBasis": "PerCurrencyUnit",          "isNonPassThru": false,          "isFee": false,          "reportingTaxableUnits": -100,          "reportingNonTaxableUnits": 0,          "reportingExemptUnits": 0,          "reportingTax": -2.5,          "reportingTaxCalculated": -2.5,          "liabilityType": "Seller"        }      ],...
```

### Example 2

The example below shows how to refund a transaction shipping from Mexico to Canada. You can see in the response details that the return invoice itemizes the landed cost and output tax types.

Request

```
curl    -X POST    -H 'Accept: application/json'    -H 'Authorization: Basic aHR0cHdhdQNoOmY='    -H 'Content-Type: application/json'    --data '{      "lines": [        {          "number": "1",          "quantity": 1,          "amount": -2000,          "taxCode": "PA020000",          "hsCode": "0105159000",          "description": "Yarn"        }      ],      "taxOverride":{        "type": "TaxDate",        "taxDate":"2021-08-01",        "reason": "Return"      },      "addresses": {        "shipFrom": {          "line1": "",          "city": "",          "region": "",          "country": "MX",          "postalCode": ""        },        "shipTo": {          "line1": "9 McKinnon Ave",          "city": "georgetown",          "region": "",          "country": "CA",          "postalCode": "L7G 5H6"        }      },      "type": "ReturnInvoice",      "companyCode": "DEFAULT",      "date": "2021-08-14",      "customerCode": "test",      "commit": true,      "currencyCode": "USD",      "description": "Yarn",      "isSellerImporterOfRecord":"true"    }'    'https://sandbox-rest.avatax.com/api/v2/transactions/create'
```

Response

```
...      "details": [        {          "id": 0,          "transactionLineId": 0,          "transactionId": 0,          "country": "CA",          "region": "CA",          "exemptAmount": 0,          "jurisCode": "CA",          "jurisName": "CANADA",          "stateAssignedNo": "",          "jurisType": "CNT",          "jurisdictionType": "Country",          "nonTaxableAmount": 0,          "rate": 0.025,          "tax": -50,          "taxableAmount": -2000,          "taxType": "LandedCost",          "taxSubTypeId": "ImportDuty",          "taxName": "CA LandedCost",          "taxAuthorityTypeId": 45,          "taxCalculated": -50,          "rateType": "Standard",          "rateTypeCode": "S",          "unitOfBasis": "PerCurrencyUnit",          "isNonPassThru": false,          "isFee": false,          "reportingTaxableUnits": -2000,          "reportingNonTaxableUnits": 0,          "reportingExemptUnits": 0,          "reportingTax": -50,          "reportingTaxCalculated": -50,          "liabilityType": "Seller"        },        {          "id": 0,          "transactionLineId": 0,          "transactionId": 0,          "country": "CA",          "region": "CA",          "exemptAmount": 0,          "jurisCode": "CA",          "jurisName": "CANADA",          "stateAssignedNo": "",          "jurisType": "CNT",          "jurisdictionType": "Country",          "nonTaxableAmount": 0,          "rate": 0.05,          "tax": -102.5,          "taxableAmount": -2050,          "taxType": "Output",          "taxSubTypeId": "O",          "taxName": "CANADA GST/TPS",          "taxAuthorityTypeId": 45,          "taxCalculated": -102.5,          "rateType": "Standard",          "rateTypeCode": "S",          "unitOfBasis": "PerCurrencyUnit",          "isNonPassThru": false,          "isFee": false,          "reportingTaxableUnits": -2050,          "reportingNonTaxableUnits": 0,          "reportingExemptUnits": 0,          "reportingTax": -102.5,          "reportingTaxCalculated": -102.5,          "liabilityType": "Seller"        },        {          "id": 0,          "transactionLineId": 0,          "transactionId": 0,          "country": "CA",          "region": "ON",          "exemptAmount": 0,          "jurisCode": "ON",          "jurisName": "ONTARIO",          "stateAssignedNo": "",          "jurisType": "STA",          "jurisdictionType": "State",          "nonTaxableAmount": 0,          "rate": 0.08,          "tax": -160,          "taxableAmount": -2000,          "taxType": "Output",          "taxSubTypeId": "O",          "taxName": "ONTARIO HST",          "taxAuthorityTypeId": 45,          "taxCalculated": -160,          "rateType": "Standard",          "rateTypeCode": "S",          "unitOfBasis": "PerCurrencyUnit",          "isNonPassThru": false,          "isFee": false,          "reportingTaxableUnits": -2000,          "reportingNonTaxableUnits": 0,          "reportingExemptUnits": 0,          "reportingTax": -160,          "reportingTaxCalculated": -160,          "liabilityType": "Seller"        }      ],      "nonPassthroughDetails": [],      "hsCode": "0105159000",      "costInsuranceFreight": 0,      "vatCode": "",      "vatNumberTypeId": 0    }  ],...
```

[Previous](/avatax-dm-combined-erp/sales-tax-badge/transactions/refunds-with-refundtransactions-api)

[Next](/avatax-dm-combined-erp/sales-tax-badge/transactions/cert-document-codes)