Sending a Document
Send a document using the /image endpoint as indicated below. This endpoint will return a GUID (Globally Unique Identifier) for the document, which can then be referenced in other QI Tech system services.
Submission
To send a document, simply perform a POST method sending the base64 code of the image in json format to the following address:
https://api.caas.qitech.app/ocr/image
Request Body
{
"document_b64": "\<BASE64_IMAGE\>",
"template": "cnh",
"file_type": "jpeg"
}
Replace the base64 code of your document in place of the placeholder.
Request Attributes Description
| Attribute | Description |
|---|---|
| document_b64 | Required field. Document image to be analyzed in base64 format. |
| template | Required field. Declares the template that should be applied for image analysis. |
| file_type | Optional field. Identifies the format of the sent file, jpeg or pdf. If not sent, the value jpeg is assumed. |
Available templates
At this time, QI Tech presents the following templates available for OCR analysis. If your required document is not included in this list, send an email to suporte.caas@qitech.com.br and inquire about the details regarding the implementation of this feature.
| Template | Description |
|---|---|
| cnh | Complete Brazilian Driver's License. |
| cnh_front | Brazilian Driver's License front (Photo side). |
| cnh_back | Brazilian Driver's License back (Signature side). |
| cnh_digital | PDF of Brazilian digital Driver's License. |
| rg_front | Brazilian Identity Card front (Photo side). |
| rg_back | Brazilian Identity Card back (Data side). |
| danfe | Auxiliary Document of Electronic Invoice (NF-e). |
| proof_of_address | Proof of address. |
| letter_of_attorney | Power of attorney that grants powers regarding a company. |
| company_statute | Articles of incorporation or company statute. |
Image
To ensure greater reliability of the analyses performed, it is necessary for the client to follow some rules when taking the photo:
- Remove the document from the plastic;
- Ensure that the document is centered in the photo;
- Ensure that the document is well-lit;
- Ensure that all document data is clear, visible and legible;
- Ensure that the photo is visible and clear.
Image Requirements
For the API to function properly, pay attention to the following parameters.
- The image must be in JPEG or PDF format;
- The image must have at least 500 pixels in height and 500 pixels in width;
- The API does not support reading handwritten documents;
- The maximum image size varies according to the chosen format, following the limits below:
| Format | Maximum supported size |
|---|---|
| .JPEG | 3MB |
| .PNG | 10MB |
| 30MB |
Response
If your document reading request is processed successfully, an HTTP status 200 and a JSON object with the identifier pointing to the document that was sent will be returned.
Response Body
{
"ocr_key": "f1c0d2e1-f950-4360-896d-36588e443fc9"
}
Response Attributes Description
| Attribute | Description |
|---|---|
| ocr_key | Identification key of the provided image that can be used in any other QI Tech system service. |
Document recovery
Image recovery
curl "https://api.caas.qitech.app/ocr/image/f4b5337a-7b50-406e-8c8e-7d0e77b5aa02/file" \
-H "Authorization: EXAMPLE_API_KEY"
At any time it is possible to recover the sent images. For this, simply send a properly authenticated GET request to the endpoint:
https://api.caas.qitech.app/ocr/image/{image_key}/file
Where image_key is the value returned during image submission.
Image quality validation
Response Body: Invalid image case
{
"title": "document_quality",
"description": "A imagem enviada não pode ser processada com êxito."
}
When making a POST to the image endpoint, if the image is not sufficient for validation, an HTTP Status Code 400 will be returned, as can be seen in the example above. Status Code 400 is also returned when the document does not meet the image requirements mentioned above.
Attention - There are other reasons why we return 400 (All related to invalid data). Only returns with the title "document_quality" are the result of poor image quality validation and therefore should be passed on to the user.
Face quality validation
Image quality validation is applied exclusively to documents that contain faces, such as RG, CNH and passports. When an image is sent to the system, if it is identified as one of the types below, a face analysis is automatically performed:
national_migration_registry_frontpassport_frontctps_frontregional_nursing_council_registry_frontregional_nursing_council_registrynational_registry_of_foreigners_backpassportnational_migration_registrynational_registry_of_foreignerscnh_digitalrg_frontrgcnh_frontcnh
During this analysis, the system checks if there is a visible face in the image and evaluates aspects such as:
- Adequate lighting (brightness);
- Presence of accessories such as sunglasses;
- Excessive proximity or distance from the face;
- Complete absence of faces in the image.
If any of these criteria indicate that the image is not adequate, an error will be returned with title: "face_validation" and the respective description, as detailed below.
{
"title": "face_validation",
"description": "<error_code>"
}
Return example:
No face detected
{
"title": "face_validation",
"description": "no_faces"
}
Message translation table for user display
Error code (description) | Friendly message |
|---|---|
close_face | The image was captured too close to the face. Reposition the document. |
distant_face | The image was captured too far from the face. Reposition the document. |
wearing_acessories | The person in the image is wearing sunglasses or accessories that cover the eyes. |
brightness_problem | The image is too dark. Resend with more lighting. |
no_faces | It was not possible to detect a face in the image. Check if the face is visible. |