Skip to main content
Version: 3.0.1

Passports

POST

  https://api.apptenticate.com/api/v3/ocr/


Authentication

Use your JWT obtained from the authentication process to make requests to this endpoint.

The response will be 401 unauthorized if the JWT is expired. In this case you will have to obtain a new JWT.


This endpoint receives all requests directed to the Apptenticate OCR microservice that allows data to be extracted from identification documents. In this case, it is possible to process passports that contain MRZ (Machine Readable Zone) and Panamanian ID cards with or without QR code. These requests must specify the type of document to be processed, an image of the front of the document and an image of the back (in the case of identity cards). In the end, the ID Reader microservice will return a JSON with the extracted data if the operation was successful, or the appropriate error if it was not.

NOTE

• The response may be 401 unauthorized if the JWT token must be refreshed.

• Images sent in jpg format must not exceed 2MB.

• If you want to obtain the transaction ID in the response, you must indicate "return_id": "True" in the JSON of the request.

• It must be specified in the request whether a photo of a passport or ID is sent using the “document_type” parameter, which can take the values ​​"passport" or "identification_card".

Request structure - method: POST

Ruta: api/ocr/

Payload for base request:

Payload: {
'frontside': Image of the front of the document,
'document_type': 'passport'
'document_id': Passport code // optional if you want to obtain the OCR of a passport that is supported in the library
} // (where images are .jpg files)

If you want to obtain the transaction ID:

Payload: {
'frontside': Image of the front of the document,
'document_type': 'passport',
'return_id':True
'document_id': Passport code // optional if you want to obtain the OCR of a passport that is supported in the library
} // (where images are .jpg files)

If you want to improve the precision of the life test

Payload: {
'frontside': Image of the front of the document,
'document_type': 'passport',
'device':'IOS', // Devices: IOS, ANDROID or DESKTOP
'document_id': Passport code // optional if you want to obtain the OCR of a passport that is supported in the library
} // (where images are .jpg files)

Request examples

Python

# JWT Token
header = { 'Authorization': 'Bearer {}'.format(token) }

# Payload para request base
data = {'document_type': 'passport'}
files = {
'frontside': imagen_1.jpg,
} # Where images are .jpg files

# Si se desea obtener el ID de la transacción:
data = {'document_type': 'passport', 'return_id': True}
files = {
'frontside': imagen_1.jpg,
} # Where images are .jpg files

# Payload para request base para obtener MRZ y OCR de pasaporte
data = {'document_type': 'passport','document_id': '052' }
files = {
'frontside': imagen_1.jpg
} # Where images are .jpg files

# Envío de request
response = requests.post(
apptenticate_url,
data=data,
files=files,
headers=header
)
response = json.loads(response.content)

Response structure

• Response for transaction id (passport):

Formato de respuesta: JSON
{
"document_number": "AN123456",
"registry_number": "CC0123456789",
"country": "COL",
"names": "JULIAN ANDRES",
"surnames": "PEREZ GARCIA",
"birth_date": "02-05-94",
"gender": "M",
"expiration_date": "30-07-22",
"image_score": 100,
"valid": true,
"id": 281234
}

• Response with OCR for document_id (052):

Formato de respuesta: JSON
{
"MRZ": {
"document_number": "N12345678",
"registry_number": "",
"country": "MEX",
"names": "MARIA FERNANDA",
"surnames": "PENAFLOR AMADO",
"birth_date": "19-08-94",
"gender": "F",
"expiration_date": "24-08-26",
"image_score": 100
},
"OCR": {
"country": "MEX",
"document_number": "N12345678",
"CURP": "PEAF940819MDFXMR03",
"gender": "F",
"names": "MARIA",
"midlename": "FERNANDA",
"expiration_date": "24-08-2026",
"birth_date": "19-08-1994",
"issuing_date": "24-08-2023",
"place_of_birth": "ALVARO OBREGON DISTRITO FEDERAL"
}
}

• In case of a failed OCR:

Response format: JSON
{ 
"MRZ": {
"document_number": "N10354307",
"registry_number": "",
"country": "VEN",
"names": "MARIA FERNANDA",
"surnames": "PENAFLOR AMADO",
"birth_date": "24-04-94",
"gender": "F",
"expiration_date": "08-10-31"
}
"OCR": {
"error": "El código de pasaporte enviando no está soportado aún por el servicio",
"error_code": 817
}
}

Passports supported to obtain OCR

CountryCode (document_id)
Mexico052

Códigos de error:

CodeMessage
800Submitted file could not be processed correctly.
801The MRZ could not be extracted from the document.
802The date of birth could not be processed.
803The gender could not be processed.
804The expiration date could not be processed.
816The document does not match the one specified in the parameters
817The sending passport code is not yet supported by the service