Skip to main content

Create Document

curl -X POST "https://api.example.com/api/documentos" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "vehiculo_id": 123,
    "tipo_documento": "SOAT",
    "fecha_emision": "2026-03-01",
    "fecha_vencimiento": "2027-03-01",
    "numero_documento": "SOAT-2026-123456",
    "aseguradora": "Seguros Bolívar",
    "pdf_url": "https://storage.example.com/soat/abc123-2026.pdf",
    "observaciones": "Renovación anual"
  }'
Creates a new vehicle document record in the documentos_vehiculos table.

Request Body

The request body should contain document information. While the exact schema depends on your database structure, common fields include:
vehiculo_id
integer
required
ID of the vehicle this document belongs to
tipo_documento
string
required
Document type: SOAT, RTM, or Póliza
fecha_emision
string
Document issue date (YYYY-MM-DD format)
fecha_vencimiento
string
required
Document expiration date (YYYY-MM-DD format)
numero_documento
string
Document number or policy number
aseguradora
string
Insurance company or issuing entity name
pdf_url
string
URL to the PDF document in storage
observaciones
string
Additional notes or observations

SOAT-Specific Fields

For SOAT (Mandatory Traffic Accident Insurance) documents:
numero_soat
string
SOAT policy number
aseguradora_soat
string
Insurance company name
valor_soat
number
SOAT premium amount

RTM-Specific Fields

For RTM (Technical-Mechanical Review) documents:
centro_revision
string
Name of the inspection center
certificado_rtm
string
RTM certificate number
resultado
string
Inspection result (e.g., “Aprobado”, “Rechazado”)

Insurance Policy Fields

For Póliza (Insurance Policy) documents:
numero_poliza
string
Policy number
tipo_cobertura
string
Coverage type (e.g., “Todo Riesgo”, “Responsabilidad Civil”)
valor_asegurado
number
Insured value amount
prima
number
Premium amount

Response

Returns the created document object with all fields including the generated id.
id
integer
Unique identifier of the newly created document
vehiculo_id
integer
Vehicle ID
tipo_documento
string
Document type
fecha_vencimiento
string
Expiration date
pdf_url
string
PDF document URL

Example Response

{
  "id": 456,
  "vehiculo_id": 123,
  "tipo_documento": "SOAT",
  "fecha_emision": "2026-03-01",
  "fecha_vencimiento": "2027-03-01",
  "numero_documento": "SOAT-2026-123456",
  "aseguradora": "Seguros Bolívar",
  "pdf_url": "https://storage.example.com/soat/abc123-2026.pdf",
  "observaciones": "Renovación anual",
  "created_at": "2026-03-04T10:30:00Z",
  "updated_at": "2026-03-04T10:30:00Z"
}

Error Response

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

Document Upload Workflow

For a complete document creation workflow:
  1. Upload PDF to storage (using your storage provider’s API)
  2. Get the PDF URL from the upload response
  3. Create the document record with the PDF URL

Example: Complete SOAT Creation

# Step 1: Upload PDF (example with presigned URL)
curl -X PUT "https://storage.example.com/upload/soat-abc123.pdf" \
  --data-binary @soat-document.pdf

# Step 2: Create document record
curl -X POST "https://api.example.com/api/documentos" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "vehiculo_id": 123,
    "tipo_documento": "SOAT",
    "fecha_vencimiento": "2027-03-01",
    "numero_soat": "SOAT-2026-123456",
    "aseguradora_soat": "Seguros Bolívar",
    "valor_soat": 450000,
    "pdf_url": "https://storage.example.com/soat-abc123.pdf"
  }'

Validation

The API performs the following validations:
  • Required fields must be present
  • Date formats must be valid ISO 8601 (YYYY-MM-DD)
  • Vehicle ID must reference an existing vehicle
  • Document type must be one of the supported types

Auto-Generated Fields

These fields are automatically generated:
  • id - Auto-incremented primary key
  • created_at - Timestamp of creation
  • updated_at - Timestamp of last update

Build docs developers (and LLMs) love