Skip to main content

Update Document

curl -X PUT "https://api.example.com/api/documentos/456" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fecha_vencimiento": "2027-06-01",
    "numero_documento": "SOAT-2026-UPDATED",
    "observaciones": "Fecha de vencimiento actualizada"
  }'
Updates an existing vehicle document in the documentos_vehiculos table. Only the fields provided in the request body will be updated.

Path Parameters

id
integer
required
The unique identifier of the document to update

Request Body

Include only the fields you want to update. All fields from the create endpoint are supported:
fecha_vencimiento
string
Updated expiration date (YYYY-MM-DD format)
fecha_emision
string
Updated issue date (YYYY-MM-DD format)
numero_documento
string
Updated document number
aseguradora
string
Updated insurance company name
pdf_url
string
Updated PDF document URL
observaciones
string
Updated observations or notes
valor_soat
number
Updated SOAT premium amount (for SOAT documents)
numero_poliza
string
Updated policy number (for insurance documents)
tipo_cobertura
string
Updated coverage type (for insurance documents)
certificado_rtm
string
Updated RTM certificate number (for RTM documents)

Response

Returns the updated document object with all fields.
id
integer
Document identifier
vehiculo_id
integer
Vehicle ID
tipo_documento
string
Document type
fecha_vencimiento
string
Expiration date
updated_at
string
Timestamp of last update

Example Response

{
  "id": 456,
  "vehiculo_id": 123,
  "tipo_documento": "SOAT",
  "fecha_emision": "2026-03-01",
  "fecha_vencimiento": "2027-06-01",
  "numero_documento": "SOAT-2026-UPDATED",
  "aseguradora": "Seguros Bolívar",
  "pdf_url": "https://storage.example.com/soat/abc123-2026.pdf",
  "observaciones": "Fecha de vencimiento actualizada",
  "created_at": "2026-03-04T10:30:00Z",
  "updated_at": "2026-03-04T15:45:00Z"
}

Error Responses

{
  "error": "Error updating documento: [error details]"
}

Common Update Scenarios

Renew Expired Document

When a document expires and needs renewal:
curl -X PUT "https://api.example.com/api/documentos/456" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fecha_emision": "2026-03-04",
    "fecha_vencimiento": "2027-03-04",
    "numero_documento": "SOAT-2027-123456",
    "pdf_url": "https://storage.example.com/soat/abc123-2027.pdf",
    "observaciones": "Documento renovado"
  }'

Update PDF After Re-upload

If you need to replace the PDF document:
curl -X PUT "https://api.example.com/api/documentos/456" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "pdf_url": "https://storage.example.com/soat/abc123-corrected.pdf",
    "observaciones": "PDF corregido y actualizado"
  }'

Extend Expiration Date

If the expiration date needs to be corrected:
curl -X PUT "https://api.example.com/api/documentos/456" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "fecha_vencimiento": "2027-12-31"
  }'

Update Insurance Details

For updating insurance-specific fields:
curl -X PUT "https://api.example.com/api/documentos/789" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "aseguradora": "Seguros del Estado",
    "numero_poliza": "POL-2026-789",
    "tipo_cobertura": "Todo Riesgo",
    "valor_asegurado": 50000000,
    "prima": 1200000
  }'

Partial Updates

The API supports partial updates - you only need to include the fields you want to change. Fields not included in the request body will remain unchanged.

Example: Update Only Observations

curl -X PUT "https://api.example.com/api/documentos/456" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "observaciones": "Documento verificado por el área legal"
  }'

Validation

The API validates:
  • Document ID must exist
  • Date formats must be valid (YYYY-MM-DD)
  • Expiration date should be in the future (warning only)
  • References to other entities must be valid

Automatic Updates

The updated_at timestamp is automatically updated on every change.

Best Practices

  1. Always include observations when updating to maintain an audit trail
  2. Upload new PDF first before updating the pdf_url
  3. Verify dates before submitting to avoid expiration tracking issues
  4. Keep old PDFs in storage for historical records
  5. Update immediately when renewal documents are received to maintain accurate expiration tracking

Build docs developers (and LLMs) love