Submitting a Document
Submitting a Document for Standard Analysis
To start document analysis, send a POST request to the /document endpoint using the multipart/form-data format.
Endpoint: https://api.caas.qitech.app/document_analysis/document
Request Format
The request must be sent as multipart/form-data and include data fields and a file field. The required fields for an analysis are id, document_analysis_type, and document_bytes.
Request example:
curl -X POST "https://api.caas.qitech.app/document_analysis/document" \
-H "Authorization: YOUR_API_KEY" \
-H "Content-Type: multipart/form-data" \
-F "id=request-abc-12345" \
-F "document_analysis_type=proof_of_address" \
-F "document_bytes=@/path/to/your/proof.pdf"
Submission Attributes Description
| Attribute | Description |
|---|---|
| id (required) | A unique identifier for the request, provided by you. This ID can be used later to retrieve the analysis results. |
| document_analysis_type (required) | A string that specifies the type of analysis to be performed on the document. See the table below for supported types. |
| document_bytes (required) | The document file to be analyzed. Must be sent as a file in the multipart request body. Note: Do not send this field as a base64-encoded string. |
| async (optional, default=false) | A boolean (true or false) that defines the processing mode. - false (synchronous): The API will attempt to process the document and return the result in the same request. - true (asynchronous): The API will acknowledge receipt and process in the background. The result will be sent via webhook to a previously configured URL (see more in the webhooks section). |
The async field must be used to indicate an asynchronous request. Synchronous requests should only be used for small documents and quick analyses where an immediate response is critical. If a request takes longer than 30 seconds it will be automatically redirected to a queue, the return status will be 202 Accepted, and the analysis result will be sent to the previously configured webhook URL (see more in the webhooks section).
Supported Analysis Types
The document_analysis_type field determines which data extraction model will be applied to your document. Below are the types currently supported.
| Analysis Type | Document Type | Description |
|---|---|---|
| company_statute_default | Contract/Articles of Association | Performs basic extraction and validation of articles of association. Extracts general company and partner information. |
| company_statute_credit_assignment | Contract/Articles of Association | Performs advanced extraction of articles of association, including validation of signing authority for credit assignment agreements. |
| proof_of_address_default | Proof of Address (utility bills, gas, internet, government letters, declarations, among others) | Extracts and validates proof of address information, such as postal code, full address, name and date. |
| invoice | Invoices, DANFEs | Extracts key information from invoices, including supplier/customer details, totals and line items. |
| bankslip | Bank Slips | Extracts information from bank slips, such as payee, amount and due date. |
| ccb_default | Bank Credit Notes (CCBs) | Extracts data from Bank Credit Notes. |
For analysis types not listed here, contact our support team at suporte.caas@qitech.com.br to inquire about custom implementations.
Responses
Success Response (200 OK)
If the document in a synchronous analysis is processed successfully, the API will return an HTTP 200 OK status and a JSON object containing the extracted data. The structure of this JSON object will vary depending on the requested document_analysis_type. If the request times out, the API will return an HTTP 202 Accepted status and the request will be processed asynchronously. After a short time you can retrieve the document analysis using a GET request, as described below.
Accepted Response (202 Accepted)
If the document is processed asynchronously, the API will return an HTTP 202 Accepted status and the request will be processed asynchronously. After a short time you can retrieve the document analysis using a GET request, as described below.
Error Response (4xx)
If there is a problem with the request or the document, the API will return a 4xx status code with a JSON body describing the error.
Error Code Reference
The following tables list all possible error codes returned by the API. You can use these codes to implement robust error handling in your application.
Category 1: Request Errors (DOC001xx)
| Code | Title | Description |
|---|---|---|
DOC00100 | Missing required field | The request does not contain a required field in the multipart/form-data body. |
DOC00101 | Invalid field length | The length of a value in a form-data field is invalid. |
DOC00102 | Invalid content type at request | The request Content-Type header is not multipart/form-data. |
DOC00103 | Invalid field at request | The request contains an unexpected or invalid field in the form-data body. |
Category 2: File Processing Errors (DOC002xx)
These errors occur when the file itself has issues that prevent its processing.
| Code | Title | Description |
|---|---|---|
DOC00200 | Invalid Document Analysis Type | The document_analysis_type is not valid for the document sent. (e.g. a company_statute_default analysis from a utility bill.) |
DOC00201 | Invalid File Size | The size of the document sent exceeds the maximum allowed limit. |
DOC00202 | Invalid File Type | The file could not be processed due to inconsistencies in its type or format (e.g. a .jpg file was sent with type application/pdf). |
DOC00203 | PDF exceeds page limit | The provided PDF file contains more pages than the maximum limit allowed for processing (the current limit is 200 pages). |
Category 3: Document Analysis Errors (DOC003xx)
These errors occur during the data extraction and analysis phase, after the file has been successfully opened.
| Code | Title | Description |
|---|---|---|
DOC00300 | Missing Information | The document does not contain the essential information required for the analysis to be completed. |
DOC00301 | Bad Quality | The document quality (e.g. resolution, legibility, sharpness) is too low to be analyzed accurately. |
DOC00302 | Invalid Data | The document contains inconsistent or invalid data (e.g. incorrect checksums, contradictory fields). |
DOC00303 | Incorrect Document Type | The document content does not match the expected document type for the selected document_analysis_type. |
DOC00304 | Invalid PDF File | The provided file is not a valid or well-formed PDF and could not be opened. |
DOC00305 | Password Protected PDF | The submitted PDF is encrypted with a password and cannot be processed. |
DOC00306 | Parsing Error | The document analysis could not be processed. |
Retrieve a Document Analysis
You can retrieve the results of a previously submitted document analysis at any time using its unique id.
https://api.caas.qitech.app/document_analysis/document/{document_id}
Replace document_id with the same value you used for the POST request.