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

# Process invoices via the API

> Process your first invoices with the FlexiCapture for Invoices Cloud API: build the authorization header, upload a file, start a task, and download results.

This walkthrough shows how to process your first invoices with the ABBYY FlexiCapture for Invoices Cloud API: build the authorization header, upload a file, start a task, and download the results.

All endpoints use the base URL `https://api-{location-id}.flexicapture.com`, where `{location-id}` is the [supported location](/flexi-capture/cloud/cloud-f-cfor-invoices-api#icaas-supported-countries): `us` (USA and Canada), `au` (Australia), or `eu` (the European Union countries).

<Steps>
  <Step title="Create an account">
    To interact with the API, you need an account. If you have not created one yet, do so via the [ABBYY FlexiCapture Cloud web portal](https://flexicapture.com).
  </Step>

  <Step title="Get the authorization header">
    All requests to the API must contain an authorization header, built from your application ID and token. For instructions, see [Authentication](/flexi-capture/cloud/cloud-f-cfor-invoices-api-auth). The examples below use the sample header `Basic QWxhZGRpbjpPcGVuU2VzYW1l`.
  </Step>

  <Step title="Upload a file">
    [Upload a file to the server](/flexi-capture/cloud/cloud-f-cfor-invoices-api-upload-file). You get the file's identifier and token in the response; they are used in all subsequent requests concerning this file.

    ```bash theme={null}
    curl -X POST \
      --header "Accept: application/json" \
      --header "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l" \
      --form "file=@/path/to/file/Letter.tif" \
      "https://api-{location-id}.flexicapture.com/v2/file"
    ```

    <Warning>
      The project settings for document assembly are ignored when uploading a file via the REST API. A separate document is created for each file.
    </Warning>
  </Step>

  <Step title="Start a task">
    After your document has been uploaded, start a task to begin data extraction. You can specify multiple files in this request. The request may contain the following optional parameters: invoice [region](/flexi-capture/cloud/cloud-f-cfor-invoices-languages), verification type, and the [export format](/flexi-capture/cloud/cloud-f-cfor-invoices-formats) for the results. The response contains a task identifier.

    ```bash theme={null}
    curl -X POST \
      --header "Content-Type: application/json" \
      --header "Accept: application/json" \
      --header "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l" \
      -d '{
        "properties": {
          "region": "US",
          "export_format": "Xls",
          "verification_type": "NoVerification"
        },
        "files": [
          {
            "id": "5ea16ff21b777315586713bf",
            "token": "34FB84AA68684F0F2BF496045224EB6C436F596B"
          }
        ]
      }' \
      "https://api-{location-id}.flexicapture.com/v2/task/capture/invoices"
    ```
  </Step>

  <Step title="Get the task status">
    Processing the task takes some time, so the extracted data is not available immediately. You can [check the task status](/flexi-capture/cloud/cloud-f-cfor-invoices-api-get-task) using the identifier you received when starting the task. Wait until the status changes to `Done`.

    ```bash theme={null}
    curl -X GET \
      --header "Accept: application/json" \
      --header "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l" \
      "https://api-{location-id}.flexicapture.com/v2/task/5ea18adc220e0d1c58177c59"
    ```
  </Step>

  <Step title="Download the result">
    After the task status changes to `Done`, you can [download](/flexi-capture/cloud/cloud-f-cfor-invoices-api-download-file) the output files using their identifiers and tokens. Repeat this request for each input file in the task request.

    ```bash theme={null}
    curl -X GET \
      --header "Accept: application/json" \
      --header "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l" \
      "https://api-{location-id}.flexicapture.com/v2/file/5ea21f6b7a9ae6193831d671/D188E5EFC0042A83529899AC1E1D94400A25DCF6"
    ```
  </Step>

  <Step title="Delete the task">
    After downloading the output data, [delete the task](/flexi-capture/cloud/cloud-f-cfor-invoices-api-delete-task) to remove all input and output files.

    ```bash theme={null}
    curl -X DELETE \
      --header "Accept: application/json" \
      --header "Authorization: Basic QWxhZGRpbjpPcGVuU2VzYW1l" \
      "https://api-{location-id}.flexicapture.com/v2/task/5ea18adc220e0d1c58177c59"
    ```
  </Step>
</Steps>
