Nexcar

Documents

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

Endpoints#

MethodPathDescription
GET/v1/documentsPaginated list of the company's documents
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

GET /v1/documents — List documents#

Returns the paginated list of documents for the authenticated user's company, ordered from newest to oldest.

Requires Bearer Token (JWT). Unlike the other endpoints in this series, this one does not accept x-api-key.

Query parameters#

ParameterTypeDefaultDescription
case_idUUID—Filter by case. Combinable with document_id (AND).
document_idUUID—Filter by document. Combinable with case_id (AND).
limitinteger10Page size (max 100)
offsetinteger0Numeric cursor for pagination

A case_id or document_id that doesn't exist, or belongs to another company, returns an empty list (not 404/403) to avoid revealing the existence of resources you don't own.

curl example#

curl "https://api.nexcar.mx/v1/documents?case_id=11111111-2222-3333-4444-555555555555&limit=10&offset=0" \
  -H "Authorization: Bearer your_jwt_token"

Response 200#

{
  "data": [
    {
      "document_id": "abc123",
      "case_id": "11111111-2222-3333-4444-555555555555",
      "type": "factura",
      "mime_type": "application/pdf",
      "status": "completed",
      "url": "https://...nexcar.mx/storage/.../invoice.pdf",
      "created_at": "2026-06-08T10:00:00+00:00",
      "active": true
    }
  ],
  "pagination": {
    "limit": 10,
    "offset": 0,
    "total": 1,
    "has_more": false
  }
}

Field reference#

FieldTypeDescription
document_idUUIDDocument identifier
case_idUUIDCase the document belongs to
typestring | nullDocument type
mime_typestring | nullFile MIME type
statusstring | nullDocument processing status
urlstring | nullPublic URL of the stored file
created_atstringCreation date in ISO 8601 format
activebooleantrue = document is active
pagination.totalintegerTotal number of matching records
pagination.has_morebooleantrue if more pages are available

Errors#

HTTPCodeCause
400VALIDATION_ERRORcase_id/document_id are not valid UUIDs, or limit/offset are not integers
401UNAUTHORIZEDMissing token, or company_id could not be determined from the token/profile

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": "11111111-2222-3333-4444-555555555555",
    "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\": \"11111111-2222-3333-4444-555555555555\",
    \"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": "11111111-2222-3333-4444-555555555555",
  "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" }'