API Reference
Segment Document
Segment a document into sections using a schema. Returns page ranges for each identified segment. Provide a file for end-to-end processing, or a checkpoint_id from a previous /convert call.
Authorizations
X-API-KeystringheaderrequiredYour API key for authentication
Body Parameters
segmentation_schemastringbodyrequiredThe JSON schema for document segmentation. Should contain segment names and descriptions.
file_urlstringbodyOptional file URL. Provide either file/file_url or checkpoint_id.
checkpoint_idstringbodyCheckpoint ID from a previous /convert request. Skips re-parsing.
modestringbodyOutput mode for parsing. 'fast', 'balanced', or 'accurate'.
max_pagesintegerbodyMaximum number of pages to process.
page_rangestringbodyPage range to process, comma separated like 0,5-10,20.
save_checkpointbooleanbodySave a checkpoint after processing.
skip_cachebooleanbodySkip the cache and re-run.
webhook_urlstringbodyOptional webhook URL to call when complete.
filefilebodyInput PDF, Word, PowerPoint, or image file. Images must be png, jpg, or webp.
Cookies
wos-sessionstringcookieSession cookie
access_tokenstringcookieAccess token cookie
datalab_active_teamstringcookieActive team cookie
Response
Successful Response
Segment Document
import requests
url = "https://www.datalab.to/api/v1/segment"
files = {
"file.0": ("example-file", open("example-file", "rb"))
}
payload = {
"segmentation_schema": "<string>",
"mode": "fast",
"skip_cache": "false"
}
headers = {"X-API-Key": "<api-key>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)200Success
{
"request_id": "<string>",
"request_check_url": "<string>",
"success": true,
"error": "<string>",
"versions": {}
}