This document demonstrates how to upload files to DocFlow through REST API. For more supported file formats, see File Format Support.
Docflow’s business processing workflow is asynchronous. The upload interface can upload one or more files to Docflow. Once uploaded successfully, you will receive a batch code (batch_number) and several file identifiers (file_id) for subsequent business workflow queries and result retrieval. Docflow supports common image formats, PDF, and Office file formats, with multi-page documents supporting up to 1000 pages. You can refer to the more detailed File Format Support and Limitations page.

01 Upload Single File

curl -X POST \
  -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>"

Parameter Description

Required Parameters

Optional Parameters

Can be added to URL query parameters as needed:
  • category: File category (e.g., invoice)
  • batch_number: Batch number, automatically generated by the system when not provided (recommended: use the same batch number for multiple files in the same batch for easier querying)
  • auto_verify_vat: Whether to enable invoice verification, default false
  • split_flag: Whether to perform file splitting, default false (see File Splitting section)
  • crop_flag: Whether to perform multi-image cropping, default false (see Multi-Image Cropping section)
  • target_process: Target processing type, options are classify or extract.
    Docflow will perform the complete workflow of parsing -> classification -> extraction by default. When target_process is classify, the workflow ends at classification to achieve classification-only requirements.
Example:
curl
curl -X POST \
  -H "x-ti-app-id: <your-app-id>" \
  -H "x-ti-secret-code: <your-secret-code>" \
  -F "file=@/path/to/invoice.pdf" \
  "https://docflow.textin.com/api/app-api/sip/platform/v2/file/upload?workspace_id=<your-workspace-id>&category=invoice"

02 Batch Upload

When you want to associate multiple files to one batch, you can use batch upload. There are two ways for batch upload:
  1. Upload multiple files in one request. This approach is relatively simple, and you can implement batch upload by repeatedly including multiple file fields in the same request:
Example:
curl -X POST \
  -H "x-ti-app-id: <your-app-id>" \
  -H "x-ti-secret-code: <your-secret-code>" \
  -F "file=@/path/to/1.pdf" \
  -F "file=@/path/to/2.pdf" \
  "https://docflow.textin.com/api/app-api/sip/platform/v2/file/upload?workspace_id=<your-workspace-id>"
The response will return result.batch_number and a list of successfully uploaded files.
  1. Upload through multiple requests, associating these files through batch_number.
    When the total size of multiple files is too large, you can associate multiple files this way. The first request will return a batch_number, and subsequent requests reuse this batch_number to associate remaining files.
Example:
import requests
import json
from requests_toolbelt.multipart.encoder import MultipartEncoder
import time
import os

ti_app_id = "your_app_id"
ti_secret_code = "your_app_secret"
workspace_id = "your_workspace_id"
filepaths = ["/path/to/your/file1.png", "/path/to/your/file2.png"]

host = "https://docflow.textin.com"
url = "/api/app-api/sip/platform/v2/file/upload"
params = {
    "workspace_id":workspace_id, 
    }

payload = MultipartEncoder(
    fields=[
        ("file", (os.path.basename(filepaths[0]), open(filepaths[0], "rb"), "image/png")),
    ]
)

resp = requests.post(url=f"{host}{url}", 
                     params=params, 
                     data=payload.to_string(), 
                     headers={"Content-Type": payload.content_type,
                              "x-ti-app-id": ti_app_id,
                              "x-ti-secret-code": ti_secret_code,
                              })

print(resp.text)
resp_json = json.loads(resp.text)

# get and reuse `batch_number`
batch_number = resp_json["result"]["batch_number"]
params["batch_number"] = batch_number
payload = MultipartEncoder(
    fields=[
        ("file", (os.path.basename(filepaths[1]), open(filepaths[1], "rb"), "image/png")),
    ]
)

resp = requests.post(url=f"{host}{url}", 
                     params=params, 
                     data=payload.to_string(), 
                     headers={"Content-Type": payload.content_type,
                              "x-ti-app-id": ti_app_id,
                              "x-ti-secret-code": ti_secret_code,
                              })

print(resp.text)
resp_json = json.loads(resp.text)

03 Query Processing Results by Batch Number

After upload is complete, you can use batch_number to query processing results for that batch:
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>&batch_number=<your-batch-number>"