Nexcar

Documents

Upload individual files to a case, fetch their OCR and reclassify them when needed.

Endpoints#

MethodPathDescription
POST/v1/documentsUpload a document to a case
GET/v1/documents/{document_id}Read metadata and OCR for a document
GET/v1/documents/{document_id}/extraction-dataAdvanced extraction (validity, QR/barcodes, owner info)
DELETE/v1/documents/{document_id}Soft-delete a document
POST/v1/documents/{document_id}/restoreRestore a soft-deleted document
PATCH/v1/documents/{document_id}/ocrInject OCR manually
POST/v1/documents/{document_id}/classifyRe-classify the document (manual or automatic)
POST/v1/documents/{document_id}/processTrigger automatic OCR
POST/v1/documents/{document_id}/reclassifyChange the type and re-process

POST /v1/documents — Upload a document#

Uploads a file and attaches it to a case.

Body#

FieldTypeRequiredDescription
case_idUUIDYesCase the document belongs to
mime_typestringYesFile MIME (see supported types)
urlstringConditionalPublic URL of the file. XOR with base64.
base64stringConditionalFile content in base64. XOR with url.
typestringNoDocument type (see Document types). If omitted, classification runs automatically.
parent_file_idUUIDNoParent document inside the same case (e.g. an invoice attachment).

Size limit: 20 MB per file. You must send exactly one of url or base64.

Supported MIME types#

application/pdf · application/xml · image/jpeg · image/jpg · image/png · image/tiff · image/tif · image/x-tiff

curl example (URL)#

curl -X POST https://api.nexcar.mx/v1/documents \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "case_id": "7040fd87-5f49-4187-b2a3-b4a19670825c",
    "url": "https://your-storage.example.com/repuve-certificate.pdf",
    "mime_type": "application/pdf",
    "type": "repuve"
  }'

curl example (base64)#

BASE64=$(base64 -i ./invoice.pdf)
curl -X POST https://api.nexcar.mx/v1/documents \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d "{
    \"case_id\": \"7040fd87-5f49-4187-b2a3-b4a19670825c\",
    \"base64\": \"$BASE64\",
    \"mime_type\": \"application/pdf\",
    \"type\": \"factura\"
  }"

Response 201#

{
  "document_id": "abc123",
  "url": "https://...nexcar.mx/storage/.../repuve-certificate.pdf"
}

Errors#

HTTPCodeCause
400MISSING_PARAMETERMissing case_id, mime_type or the file source
400VALIDATION_ERRORInvalid UUID, unsupported MIME, file > 20 MB, both url and base64
404RESOURCE_NOT_FOUNDThe case_id or parent_file_id does not exist

GET /v1/documents/{document_id}#

Returns metadata, OCR and extracted data for the document.

curl example#

curl https://api.nexcar.mx/v1/documents/abc123 \
  -H "x-api-key: your_api_key"

Response 200#

{
  "case_id": "7040fd87-5f49-4187-b2a3-b4a19670825c",
  "url": "https://...nexcar.mx/storage/.../invoice.pdf",
  "mime_type": "application/pdf",
  "type": "factura",
  "json_ocr": { "...": "..." },
  "parsed_data": {
    "vin": "3VWFE21C04M000001",
    "rfc_emisor": "ABC010101AAA",
    "monto_total": 285000.00,
    "fecha_emision": "2024-08-15"
  },
  "validity": {
    "document_validity": "vigente",
    "codes": ["QR detectado"],
    "userInfo": { "nombre": "JUAN PÉREZ GARCÍA" }
  }
}

json_ocr and parsed_data are null while OCR has not finished. Instead of polling, configure a webhook.

POST /v1/documents/{document_id}/classify#

Sets or changes the document type. Useful when you uploaded the file without a type and want to classify it manually, or when you want to force a fresh automatic detection.

curl -X POST https://api.nexcar.mx/v1/documents/abc123/classify \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "type": "tenencia" }'

If you omit the body, automatic classification runs against the file's content.

POST /v1/documents/{document_id}/reclassify#

Changes the document type and re-runs OCR with the new classification. The response is 202 Accepted with the job_id of the new processing job.

curl -X POST https://api.nexcar.mx/v1/documents/abc123/reclassify \
  -H "x-api-key: your_api_key" \
  -H "Content-Type: application/json" \
  -d '{ "type": "factura_xml" }'