# Void/delete documents

Source: https://developer.avalara.com/vat-erp/transactions/void-delete-documents/

If your platform supports voiding documents, then you must include this functionality in your integration. You can do this using the [VoidTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/VoidTransaction/) endpoint. This endpoint provides a way to recover from posting problems and cancelled transactions. The effect of the [VoidTransaction](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/VoidTransaction/) endpoint depends on both the current state of the document (uncommitted/saved, posted, or committed) and the `code` parameter used in the request body.

Below are some simple examples. Depending on your workflow, you can come across instances where a user cancelled a transaction before any money transfers. In this case, because you don’t owe the customer a refund, and depending on how you’ve submitted the transaction to AvaTax, you can either void or delete the transaction.

## Use DocVoided

For the first case, let’s assume you already saved and committed a transaction, but your customer found an issue when they looked over their receipt. In this case, you can void the transaction altogether and resubmit a new one. Because you’ve already committed the transaction for reporting, your best option is to record the void with the `DocVoided` code. Here’s what your request can look like in that case:

[![Closed](https://avalara-devdocs-prod.mcoutput.com/vat-erp/Skins/Default/Stylesheets/Images/transparent.gif)View example](javascript:void\(0\);)

```
 {  ...  "companyCode": 555,   "transactionCode": "5555555aa-5aa5-5a55-a555-55a555a5555a",  "code": "DocVoided",  "commit": true} 
```

The response returns a detailed summary of this action of the following structure:

[![Closed](https://avalara-devdocs-prod.mcoutput.com/vat-erp/Skins/Default/Stylesheets/Images/transparent.gif)View example](javascript:void\(0\);)

```
 {  "id": 55555555,   "code": "5555555aa-5aa5-5a55-a555-55a555a5555a",  "companyId": 5555555,  "date": "2024-07-15T00:00:00",  "taxDate": "2024-07-15T00:00:00",  "paymentDate": "2024-08-01T00:00:00",  "status": "Cancelled",  "type": "SalesInvoice",  ...} 
```

You’ll notice this transaction status in the response changed to `"status": "Cancelled"`. Also, when viewed in AvaTax, the transaction will now change to **Voided** under your company's transactions tab. You can also include this transaction in your reports.

## Use DocDeleted

For the next example, let’s this time assume that the customer included items in their shopping cart. When submitted to AvaTax, these become saved but uncommitted transactions. Then the customer abandons their cart. For this case, you can either use the `DocVoided` method like we did above or you can delete the transaction altogether. The following example shows hot to submit a request to delete the transaction.

[![Closed](https://avalara-devdocs-prod.mcoutput.com/vat-erp/Skins/Default/Stylesheets/Images/transparent.gif)View example](javascript:void\(0\);)

```
{  ...  "companyCode": 555,  "transactionCode": "5555555aa-5aa5-5a55-a555-55a555a5555a",  "code": "DocDeleted",  "commit": false} 
```

Notice here we specified `DocDeleted` rather than `DocVoided` in the `code` field. Because you didn't commit the file, AvaTax will delete the transaction instead of voiding int. If you wanted to keep a record of this, you could use `DocVoided`.

## Supported RESTv2 code parameters

Now that we’ve run through a couple of example requests using the REST API, the table below describes the various types of RESTv2-supported `code` options. You can find more information about the request/response parameters in our [API reference](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/VoidTransaction/).

CODE

UNCOMMITTED (SAVED)

UNCOMMITTED (POSTED

COMMITTED

COMMITTED (ADJUSTED)

VOIDED

_Unspecified_  

Uncommitted (Saved)

Uncommitted (Posted)

Committed

Committed (Adjusted)

Voided

PostFailed

DocStatusError

Saved

DocStatusError

DocStatusError

DocStatusError

DocDeleted

Deleted

Deleted

Voided

Voided

Deleted

DocVoided

Voided

Voided

Voided

Voided

Voided

Adjustment Cancelled

DocStatusError

DocStatusError

DocStatusError

Removes last adjustment

DocStatusError