> ## Documentation Index
> Fetch the complete documentation index at: https://docs.abbyy.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrate to version 2 of the API

> Update your code when upgrading from v1 to v2 of the ABBYY FlexiCapture for Invoices Cloud REST API: applications, multi-column fields, and renamed v2 URLs.

When you upgrade from version 1 to version 2 of the ABBYY FlexiCapture for Invoices Cloud REST API, you need to make some changes to your code.

The essential changes are:

* **Applications** — Version 2 introduces the concept of applications. One account can have multiple applications that operate independently. Each application works only with its own tasks, processing data, and training models, and cannot access this information belonging to other applications.
* **Multi-column fields** — Fields can now have variants, allowing for spelling differences and mistakes, which makes it easier to match vendors and business units. The captured fields are represented by arrays with variants.
* **Version updated in URLs** — The URLs were renamed according to the version: `v1` in the URL changed to `v2`.

The version 1 API methods are listed below by category. Each entry shows the version 2 URL and the changes to its request and response.

## Working with files

### POST /file

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/file
POST https://api-{location-id}.flexicapture.com/v2/file
```

* Removed the `email` query parameter; the email address of the account is used instead.
* Added to the response: `application` (application ID) and `expiring` (the file expiration date).
* Removed from the response: the keys concerning file validation and deletion (`validated`, `is_validated`, `deleted`, `is_deleted`), the error message (`error`), and the number of pages (`pages_count`).

### GET /file/{id}/{token}/info

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/file/{id}/{token}/info
GET https://api-{location-id}.flexicapture.com/v2/file/{id}/{token}/info
```

* For deleted files, you can no longer get metadata; a `404` response is now returned.
* Added to the response: `application` (application ID) and `expiring` (the file expiration date).
* Removed from the response: the keys concerning file validation and deletion (`validated`, `is_validated`, `deleted`, `is_deleted`), the error message (`error`), and the number of pages (`pages_count`).

### GET /file/{id}/{token}

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/file/{id}/{token}
GET https://api-{location-id}.flexicapture.com/v2/file/{id}/{token}
```

### DELETE /file/{id}/{token}

```http theme={null}
DELETE https://api-{location-id}.flexicapture.com/v1/file/{id}/{token}
DELETE https://api-{location-id}.flexicapture.com/v2/file/{id}/{token}
```

## Capturing documents

### POST /task/capture/documents

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/capture/data
POST https://api-{location-id}.flexicapture.com/v2/task/capture/documents
```

Changes to the request:

* The request body should no longer contain the `email` and `label` keys.
* The `region`, `export_format`, and `verification_type` keys are moved to the `properties` dictionary.

Changes to the response:

* Added keys: `batch_id`, `is_realtime_enabled`, `processing_priority`, `is_demo`, `account`, `application`, `is_extra_error`, `documents > data`, `documents > is_moved`, `documents > traininglayout_fileid`.
* Removed keys: `label`, `lead_time`, `started`, `delivered`, `deleted`, `wait_for_action`, `is_test`, `region`, `export_format`, `verification_type`, `business_unit`, `properties > export_format`, `properties > verification_type`.
* The `services` array was removed; the `files` key moved from the `services` array to the `documents` array.
* `number` is now a string instead of an integer.
* `progress` is now a floating-point number instead of an integer.

## Invoice capturing tasks

### POST /task/capture/invoices

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/capture/invoices
POST https://api-{location-id}.flexicapture.com/v2/task/capture/invoices
```

Changes to the request:

* The request body should no longer contain the `business_unit`, `email`, and `label` keys.
* The `region`, `export_format`, and `verification_type` keys are moved to the `properties` dictionary.

Changes to the response:

* Added keys: `batch_id`, `is_realtime_enabled`, `processing_priority`, `is_demo`, `account`, `application`, `is_extra_error`, `documents > data`, `documents > is_moved`, `documents > traininglayout_fileid`.
* Removed keys: `label`, `lead_time`, `started`, `delivered`, `deleted`, `wait_for_action`, `is_test`, `region`, `export_format`, `verification_type`, `business_unit`, `properties > export_format`, `properties > verification_type`.
* The `services` array was removed; the `files` key moved from the `services` array to the `documents` array.
* `number` is now a string instead of an integer.
* `progress` is now a floating-point number instead of an integer.

### GET /task/{id}

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/task/{id}
GET https://api-{location-id}.flexicapture.com/v2/task/{id}
```

The response is now organized in the same way as for the task creation method.

* Added keys, similar to the task creation method: `batch_id`, `is_realtime_enabled`, `processing_priority`, `is_demo`, `account`, `application`, `documents_count`, `pages_count`, `is_extra_error`, `documents > data`, `documents > is_moved`, `documents > traininglayout_fileid`.
* Added more keys relating to the extracted data — `documents > data > { region, export_format, verification_type, vendor_name, invoice_date, total, currency }` — and to task billing: `billed`, `is_billed`.
* Removed keys: `label`, `lead_time`, `deleted`, `wait_for_action`, `is_test`, `region`, `export_format`, `verification_type`, `business_unit`.
* The `services` array was removed; the `files` key moved from the `services` array to the `documents` array.
* `number` is now a string instead of an integer.
* `progress` is now a floating-point number instead of an integer.

### DELETE /task/{id}

```http theme={null}
DELETE https://api-{location-id}.flexicapture.com/v1/task/{id}
DELETE https://api-{location-id}.flexicapture.com/v2/task/{id}
```

## Working with datasets

### POST /dataset/businessunits

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/dataset/businessunits
POST https://api-{location-id}.flexicapture.com/v2/dataset/businessunits
```

* In both the request and the response, the following keys now contain arrays with variants: `name`, `street`, `city`, `state`, `zip`, `vat`.

### PUT /dataset/businessunits

```http theme={null}
PUT https://api-{location-id}.flexicapture.com/v1/dataset/businessunits
PUT https://api-{location-id}.flexicapture.com/v2/dataset/businessunits
```

* In both the request and the response, the following keys now contain arrays with variants: `name`, `street`, `city`, `state`, `zip`, `vat`.

### GET /dataset/businessunits/{region}

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/dataset/businessunits/{region}
GET https://api-{location-id}.flexicapture.com/v2/dataset/businessunits/{region}
```

* Optional query parameters can now be used to get the data on one of the business units: `externalId`, `skip`, `take`.
* In both the request and the response, the following keys now contain arrays with variants: `name`, `street`, `city`, `state`, `zip`, `vat`.

### DELETE /dataset/businessunits/{region}

```http theme={null}
DELETE https://api-{location-id}.flexicapture.com/v1/dataset/businessunits/{region}
DELETE https://api-{location-id}.flexicapture.com/v2/dataset/businessunits/{region}
```

### DELETE /dataset/businessunit/{region}/{externalId}

```http theme={null}
DELETE https://api-{location-id}.flexicapture.com/v1/dataset/businessunit/{region}/{externalId}
DELETE https://api-{location-id}.flexicapture.com/v2/dataset/businessunit/{region}/{externalId}
```

### POST /dataset/vendors

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/dataset/vendors
POST https://api-{location-id}.flexicapture.com/v2/dataset/vendors
```

* In both the request and the response, the following keys now contain arrays with variants: `name`, `street`, `city`, `state`, `zip`, `vat`, `national_vat`, `iban`, `bank_account`, `bank_code`, `gl_code`.

### PUT /dataset/vendors

```http theme={null}
PUT https://api-{location-id}.flexicapture.com/v1/dataset/vendors
PUT https://api-{location-id}.flexicapture.com/v2/dataset/vendors
```

* In both the request and the response, the following keys now contain arrays with variants: `name`, `street`, `city`, `state`, `zip`, `vat`, `national_vat`, `iban`, `bank_account`, `bank_code`, `gl_code`.

### GET /dataset/vendors/{region}

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/dataset/vendors/{region}
GET https://api-{location-id}.flexicapture.com/v2/dataset/vendors/{region}
```

* Optional query parameters can now be used to get the data on one of the vendors: `externalId`, `skip`, `take`.
* In both the request and the response, the following keys now contain arrays with variants: `name`, `street`, `city`, `state`, `zip`, `vat`, `national_vat`, `iban`, `bank_account`, `bank_code`, `gl_code`.

### DELETE /dataset/vendors/{region}

```http theme={null}
DELETE https://api-{location-id}.flexicapture.com/v1/dataset/vendors/{region}
DELETE https://api-{location-id}.flexicapture.com/v2/dataset/vendors/{region}
```

### DELETE /dataset/vendors/{region}/{externalId}

```http theme={null}
DELETE https://api-{location-id}.flexicapture.com/v1/dataset/vendors/{region}/{externalId}
DELETE https://api-{location-id}.flexicapture.com/v2/dataset/vendors/{region}/{externalId}
```

## Training the data capture models

### POST /training

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/data/train
POST https://api-{location-id}.flexicapture.com/v2/training
```

### PUT /training

```http theme={null}
PUT https://api-{location-id}.flexicapture.com/v1/data/train
PUT https://api-{location-id}.flexicapture.com/v2/training
```

### GET /training/layout/{taskId}/{fileId}

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/data/{taskId}/{fileId}
GET https://api-{location-id}.flexicapture.com/v2/training/layout/{taskId}/{fileId}
```

### POST /training/station/{taskId}

```http theme={null}
POST https://api-{location-id}.flexicapture.com/v1/data/train/station/{taskId}
POST https://api-{location-id}.flexicapture.com/v2/training/station/{taskId}
```

### PUT /training/station/{taskId}

```http theme={null}
PUT https://api-{location-id}.flexicapture.com/v1/data/train/station/{taskId}
PUT https://api-{location-id}.flexicapture.com/v2/training/station/{taskId}
```

### GET /training/batch{region}

```http theme={null}
GET https://api-{location-id}.flexicapture.com/v1/data/batch/{region}
GET https://api-{location-id}.flexicapture.com/v2/training/batch{region}
```
