Before processing your file with DocAI, you first need to upload it and obtain a file ID to use in your subsequent requests.
Using this guide
This guide uses plain Python 3 and built-in libraries here for illustrative purposes, but if you plan to use Python in your own code you may want to check out our prebuilt Python wrapper.
To run the code samples, you’ll need the following imports and constants:
Step 1: Upload a file to DocAI
Make a POST request to the ‘files’ API to upload your file using the following function:
The content type can be omitted (defaulting to
application/octet-stream) for most file types. However, the content type
application/eocr must be specified for
eOCR documents. It is also a good practise to explicitly declare the content type of text files (
plain/text) and PDF files (
The expiration time of the file may be specified using the
Expiration request header, as either an absolute timestamp (e.g.
2022-12-23T12:34:56Z) or an interval (e.g
10d). The maximum allowed value is 14 days.
Step 2 (optional): File validation
If desired, you can check the sha-256 hash to ensure the integrity of your uploaded file.
The hash can be found from the Submit File response:
You can also find the sha-256 hash using your operating system’s native tools:
Step 3: Process a file
file_id from the response for use in any of the other workflows: classification, language, field extraction, OCR and training.
Step 4 (Optional): Delete a file from DocAI
Files uploaded to DocAI are automatically deleted after 48 hours. However, if you would like to delete the file sooner, you can use the Delete file endpoint as follows:
On This Page