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

# Adapt the sample project for use with the ABBYY FlexiCapture Cloud REST API

> Adapt the sample Banking Card Application project for the FlexiCapture Cloud REST API: configure workflow stages and export settings, and then upload it.

## REST API workflow

The typical REST API workflow is as follows:

<Frame>
  <img src="https://mintcdn.com/abbyy/8aWHPAJyzWmTqglX/images/flexi-capture/restapi_workflow.png?fit=max&auto=format&n=8aWHPAJyzWmTqglX&q=85&s=a64343c0f3c211bbd21a481090c08c90" alt="Diagram of the typical FlexiCapture Cloud REST API workflow, showing the steps from uploading files and creating a task through polling status, getting results for verification, optional custom verification and training, and removing input and output files." width="1865" height="702" data-path="images/flexi-capture/restapi_workflow.png" />
</Frame>

Any FlexiCapture project to be used with your REST API application must include a properly configured workflow. The instructions below show how to adapt the workflow of the sample Banking Card Application project for use with the REST API. For more information about the sample projects, see [ABBYY FlexiCapture sample projects](/flexi-capture/appendix/samples).

Before proceeding with this walkthrough, launch the Project Setup Station and open the sample Banking Card Application project (the default location is `C:\Users\Public\ABBYY\FlexiCapture\12.0\Samples\FlexiCapture\English\Banking_eng\banking_eng.fcproj`).

## Adjust workflow stages

<Note>
  The REST API always submits data to be processed as the "Default" batch type. For this reason, all document processing in the project must be configured for the "Default" batch type.
</Note>

<Steps>
  <Step title="Select the Advanced workflow schema">
    On the **Project** menu, click **Project Properties** and then click the **Workflow** tab. From the **Schema** drop-down list, select **Advanced** and modify the workflow settings as shown below.

    <Frame>
      <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_properties.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=cfb7da635d5288dd20e60e1ff78d7198" alt="Screenshot of the Workflow tab in the Project Properties dialog box of the ABBYY FlexiCapture Project Setup Station, showing the Advanced schema selected with its workflow stages." width="527" height="594" data-path="images/flexi-capture/cloud_getstarted_properties.png" />
    </Frame>
  </Step>

  <Step title="Enable web stations for verification">
    Click **Verification** → **General** and select the **Enable web stations** option.

    **Note:** You can omit this setting if you don't need a verification stage in your project.
  </Step>

  <Step title="Set the verification entry condition">
    Click **Verification** → **Entry Conditions** and set the **Documents are admitted to stage** option to **Always**.

    <Note>
      Depending on the requirements of your solution, you may want to disable the verification stage temporarily or conditionally using a script-based rule on the Entry Conditions tab.
    </Note>

    <Frame>
      <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_scriptstage2.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=2af880f47b09cccf9a3dbbf5f8dbecc1" alt="Screenshot of the Entry Conditions tab of a verification stage in the ABBYY FlexiCapture Project Setup Station, showing the Documents are admitted to stage option set to Always." width="525" height="594" data-path="images/flexi-capture/cloud_getstarted_scriptstage2.png" />
    </Frame>
  </Step>

  <Step title="Add a stage to export the XML layout">
    To enable the `training/layout/{taskId}/{fileId}` endpoint for your project, export the XML file containing the field data and layout. Create a document processing stage immediately preceding the verification stage.

    <Frame>
      <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_scriptstage.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=ca883ba4911aba6ada4a7a639ce5e5cb" alt="Screenshot of the workflow stages in the ABBYY FlexiCapture Project Setup Station, with a new document processing stage added immediately before the verification stage." width="525" height="593" data-path="images/flexi-capture/cloud_getstarted_scriptstage.png" />
    </Frame>
  </Step>

  <Step title="Set the new stage's entry condition">
    On the **Entry Conditions** tab, choose **Always**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_scriptstage2.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=2af880f47b09cccf9a3dbbf5f8dbecc1" alt="Screenshot of the Entry Conditions tab of the new processing stage in the ABBYY FlexiCapture Project Setup Station, with the admission condition set to Always." width="525" height="594" data-path="images/flexi-capture/cloud_getstarted_scriptstage2.png" />
    </Frame>
  </Step>

  <Step title="Open the script editor">
    On the **Script** tab, click **Edit script…**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_scriptstage3.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=364824b4ab24e2e0fb36d7293a96d9f7" alt="Screenshot of the Script tab of a processing stage in the ABBYY FlexiCapture Project Setup Station, with the Edit script button." width="526" height="594" data-path="images/flexi-capture/cloud_getstarted_scriptstage3.png" />
    </Frame>
  </Step>

  <Step title="Set the script language">
    Change the script language to **C# .NET**.

    <Frame>
      <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_scriptstage4.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=5ab83efc9369628550fd9269b975f88d" alt="Screenshot of the script editor in the ABBYY FlexiCapture Project Setup Station, with the script language set to C# .NET." width="629" height="463" data-path="images/flexi-capture/cloud_getstarted_scriptstage4.png" />
    </Frame>
  </Step>

  <Step title="Add the export script">
    Copy and paste the following code snippet into the script pane:

    ```csharp theme={null}
    using System;
    Document.SaveXmlToFileStorage();
    ```
  </Step>

  <Step title="Save your changes">
    Click **OK** to save your changes.
  </Step>
</Steps>

<Warning>
  The project settings on document assembly (Image processing → Create document) are ignored when uploading files via the REST API. A separate document is created for each file.
</Warning>

## Adjust data export settings

Once a batch submitted through the REST API is processed, the REST API picks up any exported files to make them available for download by the client.

<Warning>
  ABBYY FlexiCapture Cloud stores exported files in object storage. For this reason, you must not use rooted export paths in your REST API project.
</Warning>

REST API projects do not require any special folder structure. You can use a flat folder structure, using the name of the root folder for each batch and document IDs as parts of file names. The REST API services assign a unique, random batch name to each batch submitted via the REST API, so unique file names are generated when exporting data from those batches.

The following screenshot shows the original export settings, which result in a multi-level folder structure:

<Frame>
  <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_export1.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=780b107c87ebaaf8b5aa41750439908d" alt="Screenshot of the export settings in the ABBYY FlexiCapture Project Setup Station, showing the original file naming that produces a multi-level folder structure." width="502" height="638" data-path="images/flexi-capture/cloud_getstarted_export1.png" />
</Frame>

The following screenshot shows the modified export settings, which result in a flat folder structure:

<Frame>
  <img src="https://mintcdn.com/abbyy/M5jnw37NmJ-asKkj/images/flexi-capture/cloud_getstarted_export2.png?fit=max&auto=format&n=M5jnw37NmJ-asKkj&q=85&s=a3f52b3974beebb94fedbafddfcba2a6" alt="Screenshot of the export settings in the ABBYY FlexiCapture Project Setup Station, showing the modified file naming that produces a flat folder structure." width="500" height="638" data-path="images/flexi-capture/cloud_getstarted_export2.png" />
</Frame>

## Upload your modified project to ABBYY FlexiCapture Cloud

<Steps>
  <Step title="Open the upload dialog">
    Click **File** > **Upload Project to Server...** to upload your project to ABBYY FlexiCapture Cloud.
  </Step>

  <Step title="Enter the server and tenant">
    In the dialog box that opens, enter the URL of the cloud server hosting your tenant and specify the name of your tenant.
  </Step>

  <Step title="Enter your credentials">
    Select **Use server authentication** and enter your tenant admin credentials.
  </Step>

  <Step title="Test the connection">
    Click **Test connection** to check your connection settings.
  </Step>

  <Step title="Upload the project">
    Click **OK** and wait until your project is uploaded.
  </Step>
</Steps>

## Your next steps

Once you have uploaded your project to ABBYY FlexiCapture Cloud, here is what you can try next:

* Create an application that is connected to your project. For more information, see [Create applications using the FlexiCapture REST API interface](/flexi-capture/rest-api-apps).
* To test whether you have connected your application correctly, process a sample batch.
* If you encounter any problems, see [Processing error diagnostics](/flexi-capture/rest-api-tasks).
