Skip to main content

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

AttributeDescription
document_b64Required field. Document image to be analyzed in base64 format.
templateRequired field. Declares the template that should be applied for image analysis.
file_typeOptional 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.

TemplateDescription
cnhComplete Brazilian Driver's License.
cnh_frontBrazilian Driver's License front (Photo side).
cnh_backBrazilian Driver's License back (Signature side).
cnh_digitalPDF of Brazilian digital Driver's License.
rg_frontBrazilian Identity Card front (Photo side).
rg_backBrazilian Identity Card back (Data side).
danfeAuxiliary Document of Electronic Invoice (NF-e).
proof_of_addressProof of address.
letter_of_attorneyPower of attorney that grants powers regarding a company.
company_statuteArticles 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:
FormatMaximum supported size
.JPEG3MB
.PNG10MB
.PDF30MB

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

AttributeDescription
ocr_keyIdentification 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_front
  • passport_front
  • ctps_front
  • regional_nursing_council_registry_front
  • regional_nursing_council_registry
  • national_registry_of_foreigners_back
  • passport
  • national_migration_registry
  • national_registry_of_foreigners
  • cnh_digital
  • rg_front
  • rg
  • cnh_front
  • cnh

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_faceThe image was captured too close to the face. Reposition the document.
distant_faceThe image was captured too far from the face. Reposition the document.
wearing_acessoriesThe person in the image is wearing sunglasses or accessories that cover the eyes.
brightness_problemThe image is too dark. Resend with more lighting.
no_facesIt was not possible to detect a face in the image. Check if the face is visible.