> ## 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.

# API バージョン2への移行

> ABBYY FlexiCapture for Invoices Cloud REST API を v1 から v2 にアップグレードする際に必要なコードの変更点について説明します。対象は、アプリケーション、複数列 field、v2 に変更された URL です。

ABBYY FlexiCapture for Invoices Cloud REST API をバージョン 1 からバージョン 2 にアップグレードする場合は、コードにいくつか変更を加える必要があります。

主な変更点は次のとおりです。

* **アプリケーション** — 新しいバージョンでは、アプリケーションの概念が導入されています。1 つのアカウントに複数のアプリケーションを作成でき、それぞれが独立して動作します。各アプリケーションが扱えるのは、自身のタスク、処理データ、モデルだけであり、他のアプリケーションのこれらの情報にはアクセスできません。
* **複数列 field** — field は候補を持てるようになり、表記ゆれや誤りがあっても、ベンダーや事業部門との照合がしやすくなりました。抽出された field は、候補を含む配列として表現されます。
* **URL 内のバージョン更新** — URL はバージョンに応じて変更されました。URL 内の `v1` は `v2` に変更されています。

バージョン 1 の API メソッドを以下にカテゴリ別に示します。各エントリには、バージョン 2 の URL と、リクエストおよびレスポンスの変更点が記載されています。

<div id="working-with-files">
  ## ファイルの操作
</div>

<div id="post-file">
  ### POST /file
</div>

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

* `email` クエリパラメーターを削除しました。代わりに、アカウントのメールアドレスを使用します。
* レスポンスに `application` (application ID) と `expiring` (ファイルの有効期限日) を追加しました。
* レスポンスから削除しました: ファイルの検証と削除に関するキー (`validated`、`is_validated`、`deleted`、`is_deleted`) 、エラーメッセージ (`error`) 、およびページ数 (`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
```

* 削除されたファイルではメタデータを取得できなくなり、現在は `404` レスポンス が返されます。
* レスポンス に追加: `application` (application ID) および `expiring` (ファイルの有効期限) 。
* レスポンス から削除: ファイルの検証と削除に関するキー (`validated`、`is_validated`、`deleted`、`is_deleted`) 、エラーメッセージ (`error`) 、およびページ数 (`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}
```

<div id="capturing-documents">
  ## ドキュメントの抽出
</div>

<div id="post-taskcapturedocuments">
  ### POST /task/capture/documents
</div>

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

リクエストの変更:

* リクエスト本文には、`email` キーと `label` キーが含まれなくなりました。
* `region`、`export_format`、`verification_type` キーは `properties` 辞書に移動されました。

レスポンスの変更:

* 追加されたキー: `batch_id`, `is_realtime_enabled`, `processing_priority`, `is_demo`, `account`, `application`, `is_extra_error`, `documents > data`, `documents > is_moved`, `documents > traininglayout_fileid`.
* 削除されたキー: `label`, `lead_time`, `started`, `delivered`, `deleted`, `wait_for_action`, `is_test`, `region`, `export_format`, `verification_type`, `business_unit`, `properties > export_format`, `properties > verification_type`.
* `services` 配列は削除され、`files` キーは `services` 配列から `documents` 配列に移動されました。
* `number` は、整数ではなく string になりました。
* `progress` は、整数ではなく浮動小数点数になりました。

<div id="invoice-capturing-tasks">
  ## 請求書抽出タスク
</div>

<div id="post-taskcaptureinvoices">
  ### POST /task/capture/invoices
</div>

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

リクエストの変更点:

* リクエスト本文には、`business_unit`、`email`、`label` の各キーを含めなくなりました。
* `region`、`export_format`、`verification_type` の各キーは、`properties` 辞書に移動されました。

レスポンスの変更点:

* 追加されたキー: `batch_id`、`is_realtime_enabled`、`processing_priority`、`is_demo`、`account`、`application`、`is_extra_error`、`documents > data`、`documents > is_moved`、`documents > traininglayout_fileid`。
* 削除されたキー: `label`、`lead_time`、`started`、`delivered`、`deleted`、`wait_for_action`、`is_test`、`region`、`export_format`、`verification_type`、`business_unit`、`properties > export_format`、`properties > verification_type`。
* `services` 配列は削除され、`files` キーは `services` 配列から `documents` 配列に移動されました。
* `number` は、integer ではなく string になりました。
* `progress` は、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}
```

レスポンスは現在、タスク作成メソッドと同じ形式で構成されています。

* タスク作成メソッドと同様に、次のキーが追加されました: `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`.
* 抽出データに関連するキー — `documents > data > { region, export_format, verification_type, vendor_name, invoice_date, total, currency }` — と、タスクの請求に関連するキー `billed`, `is_billed` が追加されました。
* 次のキーが削除されました: `label`, `lead_time`, `deleted`, `wait_for_action`, `is_test`, `region`, `export_format`, `verification_type`, `business_unit`.
* `services` 配列は削除され、`files` キーは `services` 配列から `documents` 配列に移動しました。
* `number` は整数ではなく文字列になりました。
* `progress` は整数ではなく浮動小数点数になりました。

### 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}
```

<div id="working-with-datasets">
  ## データセットの操作
</div>

<div id="post-datasetbusinessunits">
  ### POST /dataset/businessunits
</div>

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

* リクエストとレスポンスの両方で、次のキーには候補を含む配列が含まれるようになりました: `name`, `street`, `city`, `state`, `zip`, `vat`.

<div id="put-datasetbusinessunits">
  ### PUT /dataset/businessunits
</div>

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

* リクエストとレスポンスの両方で、次のキーには候補を含む配列が含まれるようになりました: `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}
```

* オプションのクエリ パラメーター `externalId`、`skip`、`take` を使用して、いずれかの事業部門のデータを取得できるようになりました。
* リクエストとレスポンスの両方で、次のキーには候補を含む配列が入るようになりました: `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}
```

<div id="post-datasetvendors">
  ### POST /dataset/vendors
</div>

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

* リクエストとレスポンスの両方で、次のキーには候補の配列が含まれるようになりました: `name`, `street`, `city`, `state`, `zip`, `vat`, `national_vat`, `iban`, `bank_account`, `bank_code`, `gl_code`.

<div id="put-datasetvendors">
  ### PUT /dataset/vendors
</div>

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

* リクエストとレスポンスの両方で、次のキーの値が候補を含む配列になりました: `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}
```

* オプションのクエリパラメーター `externalId`、`skip`、`take` を使用して、いずれか 1 つのベンダーのデータを取得できるようになりました。
* リクエストとレスポンスの両方で、次のキーには候補を含む配列が入るようになりました: `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}
```

<div id="training-the-data-capture-models">
  ## データ抽出モデルの学習
</div>

<div id="post-training">
  ### POST /training
</div>

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

<div id="put-training">
  ### PUT /training
</div>

```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}
```
