# CancelBatch

Cancel an in progress batch

`POST /api/v2/companies/{companyId}/batches/{id}/cancel`

**API:** AvaTax API
**Tag:** Batches
**API Version:** v2
**Base URL:** https://sandbox-rest.avatax.com/
**Accepts:** `application/json`
**Authentication:** API Key (`Authorization` in header) or OAuth 2.0 or Basic (username + license key)

Source: https://developer.avalara.com/products/avatax/api/methods/Batches/CancelBatch/

## Description

Marks the in progress batch identified by this URL as cancelled.
            
Only JSON batches can be cancelled. If you attempt to cancel a file batch, you will receive an error message.
            
Only in progress batches can be cancelled.  If you attempt to cancel a batch that its status is not Waiting or Processing, you will receive an error message.
Cancelling an in progress batch does not delete any transactions that were created before the cancellation.
            
Because the batch system processes with a degree of concurrency, and
because of batch sizes in the queue vary, AvaTax API is unable to accurately
predict when a batch will complete. If high performance processing is
required, please use the
[CreateTransaction API](https://developer.avalara.com/api-reference/avatax/rest/v2/methods/Transactions/CreateTransaction/).

### Security Policies

* This API requires one of the following user roles: AccountAdmin, AccountOperator, AvaTaxOnlyAccountAdmin, AvaTaxOnlyCompanyAdmin, BatchServiceAdmin, CompanyAdmin, CSPTester, FirmAdmin, SSTAdmin, SystemAdmin, SystemOperator, TechnicalSupportAdmin.

## Parameters

| Name | Type | In | Required | Description |
|---|---|---|---|---|
| `companyId` | integer | path | Yes | The ID of the company that owns this batch. |
| `id` | integer | path | Yes | The ID of the batch to cancel. |
| `X-Avalara-Client` | string | header | No | Identifies the software you are using to call this API.  For more information on the client header, see [Client Headers](https://developer.avalara.com/avatax/client-headers/) . |

## Responses

| Status | Description | Schema |
|---|---|---|
| 200 | Success | `BatchModel` |
| 400 | Bad Request |  |
| 401 | Unauthorized |  |
| 404 | Not Found |  |

### 200 Response: `BatchModel`

Represents a batch of uploaded documents.

| Property | Type | Required | Description |
|---|---|---|---|
| `type` | string | **Yes** | The type of this batch. Values: `AvaCertUpdate`, `AvaCertUpdateAll`, `BatchMaintenance`, `CompanyLocationImport`, `DocumentImport`, `ExemptCertImport`, `ItemImport`, `SalesAuditExport`, `SstpTestDeckImport`, `TaxRuleImport`, `TransactionImport`, `UPCBulkImport`, `UPCValidationImport`, `CustomerSupplierImport`, `VarianceImport`, `CostCenterImport`, `GLAccountImport`, `AdvancedRulesImport`, `ItemImportV2`, `VatValidationImport`, `TxnWithDynamicParamBag`. Example: `AvaCertUpdate`. |
| `batchAgent` | string | No | The agent used to create this batch Example: `manual`. |
| `id` | integer | No | The unique ID number of this batch. |
| `options` | string | No | Any optional flags provided for this batch |
| `name` | string | **Yes** | The user-friendly readable name for this batch. Example: `TestBatch`. |
| `accountId` | integer | No | The Account ID number of the account that owns this batch. |
| `companyId` | integer | No | The Company ID number of the company that owns this batch. |
| `status` | string | No | This batch's current processing status Values: `Waiting`, `SystemErrors`, `Cancelled`, `Completed`, `Creating`, `Deleted`, `Errors`, `Paused`, `Processing`, `Cancelling`. Example: `Waiting`. |
| `startedDate` | string | No | The date/time when this batch started processing |
| `recordCount` | integer | No | The number of records in this batch; determined by the server |
| `currentRecord` | integer | No | The current record being processed |
| `completedDate` | string | No | The date/time when this batch was completely processed |
| `createdDate` | string | No | The date when this record was created. |
| `createdUserId` | integer | No | The User ID of the user who created this record. |
| `modifiedDate` | string | No | The date/time when this record was last modified. |
| `modifiedUserId` | integer | No | The user ID of the user who last modified this record. |
| `files` | BatchFileModel[] | No | The list of files contained in this batch. |

## Example Request

```bash
curl -X POST "https://sandbox-rest.avatax.com/api/v2/companies/{companyId}/batches/{id}/cancel" \
  -H "Authorization: Basic <credentials>" \
  -H "Accept: application/json"
```