The DocAI classification service is able to determine the type of document, first identifying it as contract or non-contract, and further classifying it as one of 15 contract and 20 non-contract types.
Like most of the DocAI API, the classification service works asynchronously, requiring you to first make a POST to create the classification request, then use a GET endpoint to poll the status of the request and obtain the results once complete. When you make a classification request, DocAI automatically applies OCR to the document (if necessary - see file submission for exceptions) and caches the OCR results for reuse by any of the other services (language, field extraction and OCR).
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 your file to DocAI
Follow the instructions in the File Management Workflow to upload your file to DocAI and obtain its
Step 2: Create a document classification request
To start processing your file, use the Create classification requests endpoint, providing the
file_id from step 1.
The response includes a
request_id for each
file_id - in this case, since we only asked to classify one file, we get a single-element array. We’ll need the
request_id in the next step:
Step 3: Poll for the status and results
Begin polling the Get classification request status endpoint until the
status is “complete”.
Note: you should also check for a “failed” status, to avoid waiting on a request that will never complete.
Once the status is complete, the response will also include the fields
classification, which are the results of the request.
When the request is complete, the results will be included in the response.
Step 4 (optional): Delete the file from DocAI
If desired, you may now Delete the file from DocAI. Otherwise, it will automatically be removed after 48 hours.
On This Page