Tables are configurations in file categories used to extract structured tabular data. Each table can contain multiple fields to define the columns of the table. This guide introduces how to manage tables under file categories via API.
List Tables
Get all tables under a specified file category:
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/category/tables/list?workspace_id=<your-workspace-id>&category_id=<category-id>"
Request Parameters:
workspace_id (required): Workspace ID
category_id (required): File category ID
Response Example:
{
"code" : 200 ,
"msg" : "success" ,
"result" : {
"tables" : [
{
"id" : "table_123" ,
"name" : "Item Details" ,
"prompt" : "Please extract item name, quantity, and amount for each row" ,
"collect_from_multi_table" : true
},
{
"id" : "table_456" ,
"name" : "Fee Details" ,
"prompt" : "Please extract fee item and amount for each row" ,
"collect_from_multi_table" : false
}
]
}
}
Add Table
Add a table under a specified file category:
curl -X POST \
-H "x-ti-app-id: <your-app-id>" \
-H "x-ti-secret-code: <your-secret-code>" \
-H "Content-Type: application/json" \
-d '{
"workspace_id": "<your-workspace-id>",
"category_id": "<category-id>",
"name": "Item Details",
"prompt": "Please extract item name, quantity, and amount for each row",
"collect_from_multi_table": true
}' \
"https://docflow.textin.com/api/app-api/sip/platform/v2/category/tables/add"
Request Parameters:
workspace_id (required): Workspace ID
category_id (required): File category ID
name (required): Table name, max length 50
prompt (optional): Semantic extraction prompt for table, max length 200
collect_from_multi_table (optional): Whether to merge multiple tables, default is false
Response Example:
{
"code" : 200 ,
"msg" : "success" ,
"result" : {
"table_id" : "table_new_789"
}
}
Multi-table merge explanation : When a document contains multiple tables with the same structure, enabling collect_from_multi_table will merge them into one table result. For example, if invoice item details span across multiple pages, enabling multi-table merge will combine all pages of details into one.
Update Table
Update information for a specified table:
curl -X POST \
-H "x-ti-app-id: <your-app-id>" \
-H "x-ti-secret-code: <your-secret-code>" \
-H "Content-Type: application/json" \
-d '{
"workspace_id": "<your-workspace-id>",
"category_id": "<category-id>",
"table_id": "<table-id>",
"name": "Updated Table Name",
"prompt": "Updated prompt",
"collect_from_multi_table": true
}' \
"https://docflow.textin.com/api/app-api/sip/platform/v2/category/tables/update"
Request Parameters:
workspace_id (required): Workspace ID
category_id (required): File category ID
table_id (required): Table ID
name (optional): Table name, max length 50
prompt (optional): Semantic extraction prompt for table, max length 200
collect_from_multi_table (required): Whether to merge multiple tables
Delete Table
Delete specified table(s), supporting batch deletion:
curl -X POST \
-H "x-ti-app-id: <your-app-id>" \
-H "x-ti-secret-code: <your-secret-code>" \
-H "Content-Type: application/json" \
-d '{
"workspace_id": "<your-workspace-id>",
"category_id": "<category-id>",
"table_ids": ["table_123", "table_456"]
}' \
"https://docflow.textin.com/api/app-api/sip/platform/v2/category/tables/delete"
Request Parameters:
workspace_id (required): Workspace ID
category_id (required): File category ID
table_ids (required): Array of table IDs to delete
Deleting a table will also delete all fields under it. Please proceed with caution.
Table Field Management
After creating a table, you need to add fields to define the columns of the table. For table field management, please refer to the “Add Table Field” section in the Fields Management documentation.
Example: Create Table and Add Fields
import requests
ti_app_id = "<your-app-id>"
ti_secret_code = "<your-secret-code>"
workspace_id = "<your-workspace-id>"
category_id = "<category-id>"
host = "https://docflow.textin.com"
# 1. Create table
table_resp = requests.post(
url = f " { host } /api/app-api/sip/platform/v2/category/tables/add" ,
json = {
"workspace_id" : workspace_id,
"category_id" : category_id,
"name" : "Item Details" ,
"prompt" : "Please extract item name, quantity, and amount for each row" ,
"collect_from_multi_table" : True
},
headers = {
"x-ti-app-id" : ti_app_id,
"x-ti-secret-code" : ti_secret_code,
},
)
table_id = table_resp.json()[ "result" ][ "table_id" ]
print ( f "Table created successfully, ID: { table_id } " )
# 2. Add fields to table
fields_to_add = [
{ "name" : "Item Name" , "description" : "Name of goods or services" },
{ "name" : "Quantity" , "description" : "Item quantity" },
{ "name" : "Unit Price" , "description" : "Item unit price" },
{ "name" : "Amount" , "description" : "Item amount" }
]
for field_config in fields_to_add:
field_resp = requests.post(
url = f " { host } /api/app-api/sip/platform/v2/category/fields/add" ,
json = {
"workspace_id" : workspace_id,
"category_id" : category_id,
"table_id" : table_id, # Specify table ID
** field_config
},
headers = {
"x-ti-app-id" : ti_app_id,
"x-ti-secret-code" : ti_secret_code,
},
)
field_id = field_resp.json()[ "result" ][ "field_id" ]
print ( f "Field ' { field_config[ 'name' ] } ' created successfully, ID: { field_id } " )
print ( "Table and fields creation completed" )
See all 52 lines
Table Configuration
Table Properties
name : Table name, required
prompt : Semantic extraction prompt for table, used to guide AI in table extraction
collect_from_multi_table : Whether to merge multiple tables
Multi-table Merge Scenarios
The following scenarios are suitable for enabling multi-table merge:
Cross-page tables : Table content spans across multiple pages
Repeated tables : Multiple tables with the same structure exist in the document
Segmented tables : Tables are separated by other content
Example: If invoice item details span across multiple pages, enabling multi-table merge will combine all pages of item details into one complete table result.
Next Steps