API Reference

POST /api/upload

Upload an image of a Bolivian identity document, driver's license, or vehicle registration and receive structured, machine-readable JSON with extracted fields.

MethodPOST
URL/api/upload
Content-Typemultipart/form-data

Request

FieldTypeRequiredDescription
filebinaryYesImage file in JPG, PNG, or GIF format

Accepted formats: .jpg, .jpeg, .png, .gif. Unsupported formats return 400.

Success Response 200

The response always contains a documento field indicating the document type, plus three nested objects. Exactly one nested object is populated; the other two are null.

Identity Card (Carnet de Identidad)

{
  "documento": "carnet",
  "carnet": {
    "numero_de_cedula": "1234567",
    "nombre": "Juan",
    "nombres": "Juan Carlos",
    "apellidos": "Perez Quispe",
    "fecha_nacimiento": "1990-01-01",
    "lugar_nacimiento": "La Paz",
    "ocupacion": "Ingeniero",
    "estado_civil": "Soltero",
    "direccion": "Calle 123 #45",
    "fecha_emision": "2020-01-01",
    "fecha_vencimiento": "2025-01-01"
  },
  "licencia": null,
  "ruat": null,
  "mensaje": null
}

Driver's License (Licencia para Conducir)

{
  "documento": "licencia",
  "carnet": null,
  "licencia": {
    "nombre": "Maria",
    "nombres": "Maria Elena",
    "apellidos": "Lopez Garcia",
    "sexo": "F",
    "categoria": "P",
    "nacionalidad": "Boliviana",
    "numero_de_licencia": "9876543",
    "fecha_emision": "2021-06-01",
    "fecha_nacimiento": "1985-03-15",
    "fecha_vencimiento": "2026-06-01"
  },
  "ruat": null,
  "mensaje": null
}

Vehicle Registration (RUAT)

{
  "documento": "ruat",
  "carnet": null,
  "licencia": null,
  "ruat": {
    "placa": "1234ABC",
    "gobierno_municipal": "La Paz",
    "clase": "Automovil",
    "marca": "Toyota",
    "modelo": "Corolla",
    "tipo_vehiculo": "Sedan",
    "sub_tipo_vehiculo": "",
    "servicio": "Particular",
    "numero_motor": "1ZZ-1234567",
    "numero_chasis": "JT1234567890",
    "cilindrada": "1800",
    "peso": "1200",
    "traccion": "Delantera",
    "numero_ruedas": "4",
    "color": "Blanco",
    "numero_plazas": "5",
    "combustible": "Gasolina",
    "tipo_motor": "",
    "propietario": "Juan Perez",
    "direccion": "Av. Siempre Viva 742",
    "documento_identidad": "1234567"
  },
  "mensaje": null
}

Field Reference

Carnet Fields (11)

FieldTypeDescription
numero_de_cedulastringNational ID number
nombrestringFirst name
nombresstringFull given names
apellidosstringLast names
fecha_nacimientostringDate of birth
lugar_nacimientostringPlace of birth
ocupacionstringOccupation
estado_civilstringMarital status
direccionstringAddress
fecha_emisionstringIssue date
fecha_vencimientostringExpiration date

Licencia Fields (10)

FieldTypeDescription
nombrestringFirst name
nombresstringFull given names
apellidosstringLast names
sexostringGender (M/F)
categoriastringLicense category (P, A, B, C)
nacionalidadstringNationality
numero_de_licenciastringLicense number
fecha_emisionstringIssue date
fecha_nacimientostringDate of birth
fecha_vencimientostringExpiration date

RUAT Fields (21)

FieldTypeDescription
placastringLicense plate
gobierno_municipalstringMunicipal government
clasestringVehicle class
marcastringBrand
modelostringModel
tipo_vehiculostringVehicle type
sub_tipo_vehiculostringVehicle subtype
serviciostringService type
numero_motorstringEngine number
numero_chasisstringChassis number
cilindradastringEngine displacement
pesostringWeight
traccionstringDrive type
numero_ruedasstringNumber of wheels
colorstringColor
numero_plazasstringNumber of seats
combustiblestringFuel type
tipo_motorstringEngine type
propietariostringOwner name
direccionstringOwner address
documento_identidadstringOwner ID number

Error Responses

StatusScenarioExample
400 Unsupported file format
{"documento":"desconocido","mensaje":"Unsupported file format, file: doc.bmp",...}
400 LLM returned an error
{"documento":"desconocido","mensaje":"Error with LLM timeout",...}
400 LLM response was not valid JSON
{"documento":"desconocido","mensaje":"Failed to decode JSON from LLM response",...}
400 Document could not be identified
{"documento":"desconocido","mensaje":"documento invalido",...}

curl Example

curl -X POST http://localhost:5205/api/upload \
  -F "file=@carnet_frontal.jpg"

Corner Cases & Integration Notes

  • Always check documento first. Read the type, then access the corresponding nested object. The other two are always null.
  • All fields are strings. Even numeric-looking fields like numero_de_cedula or cilindrada are returned as strings. Dates are typically YYYY-MM-DD but may be free-form text if the LLM cannot parse them.
  • Missing values are empty strings. Fields the LLM cannot read come back as "", never null. Nested objects are null only when the document type does not match.
  • Strip whitespace. The LLM may include leading or trailing whitespace in field values. Always .strip() before use.
  • Low-quality or partial images will likely return documento: "desconocido" with a descriptive mensaje.
  • Only Bolivian documents are recognized. Foreign IDs, passports, or unrelated images will return desconocido.
  • Response time varies (1-5 seconds typically). The LLM processes the image server-side; no streaming or partial results.
  • No authentication required for this endpoint. The service is designed for internal BPM-to-service communication behind a secure network.