# CreateBatches

Create a new batch

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

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

Source: https://developer.avalara.com/products/crossborder/api/methods/Batches/CreateBatches/

## Description

Create one or more new batch objects attached to this company.
            
Each batch object may have one or more file objects (currently only one file is supported).
            
When a batch is created, it is added to the AvaTax Batch Queue and will be
processed as quickly as possible in the order it was received. To check the
status of a batch, fetch the batch and retrieve the results of the batch
operation.
            
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/).
            
The maximum content length of the request body is limited to 28.6 MB. If this limit
is exceeded, a 404 Not Found status will be returned (possibly with a CORS error if
the API is called from a browser). In this situation, please split the request into
smaller batches.

### 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. |
| `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/) . |

## Request Body

**Schema:** `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. |

## Responses

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

## Example Request

```bash
curl -X POST "https://sandbox-rest.avatax.com/api/v2/companies/{companyId}/batches" \
  -H "Authorization: Basic <credentials>" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '[
  {
    "type": "TransactionImport",
    "batchAgent": "manual",
    "name": "TestBatch",
    "files": [
      {
        "name": "samplebatch.csv",
        "content": "UHJvY2Vzc0NvZGUsRG9jQ29kZSxEb2NUeXBlLERvY0RhdGUsQ29tcGFueUNvZGUsQ3VzdG9tZXJDb2RlLEVudGl0eVVzZUNvZGUsTGluZU5vLFRheENvZGUsV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SF9JUlJGLEJSQnV5ZXJfSXNFeGVtcHRPckNhbm5vdFdIX1BJU1JGLEJSQnV5ZXJfSXNFeGVtcHRPckNhbm5vdFdIX0NPRklOU1JGLEJSQnV5ZXJfSXNFeGVtcHRPckNhbm5vdFdIX0NTTExSRixCUkJ1eWVyX0lzRXhlbXB0X1BJUyxCUkJ1eWVyX0lzRXhlbXB0X0NPRklOUyxCUkJ1eWVyX0lzRXhlbXB0X0NTTEwsSGVhZGVyX0Rlc2NyaXB0aW9uLEVtYWlsDQozLDlhYzI4MGMzLTNhNTUtNGEzNS1iZWQyLWE4M2RiNTNiMDUxZSwxLDEvMS8yMDE0LERFRkFVTFQsQ3VzdDEsLDEsLCwsLCwxMDAwLCwsLCwsMjM1IEUgNDJuZCBTdCAsTmV3IFlvcmssTlksMTAwMTctNTcwMyAgLFVTLDkwMCBXaW5zbG93IFdheSxCYWluYnJpZGdlIElzbGFuZCxXQSw5ODExMCxVUywsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwsLCwNCg==",
        "contentLength": 0,
        "contentType": "text/csv",
        "fileExtension": ".csv",
        "filePath": "samplebatch.csv"
      }
    ]
  }
]'
```