This document provides examples on how to quickly integrate with the DocFlow workflow via APIs.
If you have not used DocFlow in the Web UI before, we recommend uploading a file on the Web page first to get a clear idea of how DocFlow works.

01 Prerequisites: Obtain Access Credentials

1.1 Public Cloud Usage

When using the Docflow API, you need to obtain an API Key first.
Please log in first and go to TextIn Console - Account & Developer Information to obtain your x-ti-app-id and x-ti-secret-code.

1.2 Private Cloud Usage

Please contact the technical support personnel you are working with to obtain API call credentials for private deployment.

02 Preparation

2.1 Configure Docflow Workspace and Classification

First, refer to the Get Workspace ID and Configure File Categories documents to complete the configuration and obtain the workspace ID.

2.2 Upload Files

Example:
curl \
  -H "x-ti-app-id: <your-app-id>" \
  -H "x-ti-secret-code: <your-secret-code>" \
  -F file=@</path/to/your/file.pdf \
  "https://docflow.textin.com/api/app-api/sip/platform/v2/file/upload?workspace_id=<your-workspace-id>"
After executing the above example code with your parameters, you can view the just uploaded file in the corresponding workspace on the Web page.

2.3 Retrieve Results

Example:
curl \
  -H "x-ti-app-id: <your-app-id>" \
  -H "x-ti-secret-code: <your-secret-code>" \
  "https://docflow.textin.com/api/app-api/sip/platform/v2/file/fetch?workspace_id=<your-workspace-id>"

2.4 Result Parsing

The retrieved result is in JSON format containing the processed document results. You can obtain the document parsing, classification, and extraction results by parsing the JSON.
The example below shows the extracted document fields in the output. For parsing of other information, refer to the relevant sections of this documentation.
# Continuing from the "Retrieve Results" example code

for file in resp_json["result"]["files"]:
  for item in file["data"]["items"]:
    print(f"{item["key"]}: {item["value"]}")