Skip to main content
DELETE
/
vehiculo
/
{id}
Delete Vehicle
curl --request DELETE \
  --url https://api.example.com/vehiculo/{id}
{
  "success": false,
  "message": "No se encontró el vehículo con ID 999",
  "timestamp": "2024-03-20T11:15:00Z"
}

Endpoint

method
string
default:"DELETE"
DELETE
endpoint
string
/vehiculo/

Description

Performs a logical deletion (soft delete) of a vehicle. The vehicle record is not physically removed from the database but is marked as deleted. This preserves data integrity and allows for potential recovery.
Soft Delete: The vehicle is marked as deleted (Eliminado = true) but remains in the database. This allows for audit trails and potential data recovery.

Path Parameters

id_vehiculo
integer
required
Unique identifier of the vehicle to deleteExample: 1

Validations

Important Validations
  • Vehicle must exist and be active (not already deleted)
  • Vehicle must not have active missions associated with it
  • If there are active missions, deletion will be blocked with a 409 Conflict error

Business Rules

1

Check Existence

Verifies the vehicle exists and is currently active
2

Check Active Missions

Validates that the vehicle has no active missions
3

Mark as Deleted

Sets the Eliminado flag to true
4

Preserve Data

All vehicle data remains in the database for audit purposes

Response

success
boolean
Indicates if the operation was successful
message
string
Success message: “Vehículo eliminado exitosamente”
data
object
The deleted vehicle object with Eliminado flag set to true
timestamp
string
Response timestamp

Example Request

DELETE /vehiculo/1

Example Response

{
  "success": true,
  "message": "Vehículo eliminado exitosamente",
  "data": {
    "Id": 1,
    "Placa": "P503067",
    "Marca": "TOYOTA",
    "Modelo": "HILUX",
    "Anio": 2020,
    "Color": "BLANCO",
    "NumeroMotor": "1GRFE123456",
    "NumeroChasis": "JT123456789012345",
    "NumeroVin": "JT123456789012345",
    "CapacidadPasajeros": 5,
    "CapacidadCombustibleGalones": 80.0,
    "KilometrajeActual": 18000,
    "FechaUltimaRevision": "2024-03-15",
    "FechaProximoMantenimiento": "2024-09-15",
    "FechaTarjetaCirculacion": "2023-12-01",
    "NumeroPolizaSeguro": "POL123456789",
    "FechaVencimientoSeguro": "2025-12-01",
    "Observaciones": "Mantenimiento realizado en marzo 2024",
    "Eliminado": true,
    "FechaHoraCreacion": "2024-01-15T10:30:00Z",
    "FechaHoraActualizacion": "2024-03-20T11:15:00Z",
    "IdClaseVehiculo": 1,
    "NombreClaseVehiculo": "Pick-up",
    "IdEstadoVehiculo": 1,
    "NombreEstadoVehiculo": "Activo",
    "IdTipoCombustible": 1,
    "NombreTipoCombustible": "Diesel",
    "IdMotoristaPorDefecto": 10,
    "NombreMotoristaPorDefecto": "Juan Pérez",
    "IdDepartamentoAsignado": 2,
    "NombreDepartamentoAsignado": "Logística"
  },
  "timestamp": "2024-03-20T11:15:00Z"
}

Error Responses

{
  "success": false,
  "message": "No se encontró el vehículo con ID 999",
  "timestamp": "2024-03-20T11:15:00Z"
}

Soft Delete Benefits

Data Preservation

All vehicle data remains in the database for historical records

Audit Trail

Maintains complete audit trail of vehicle lifecycle

Recovery

Enables potential recovery of accidentally deleted vehicles

Referential Integrity

Preserves relationships with other records (missions, maintenance, etc.)

Reactivation

If you need to reactivate a deleted vehicle, you can create a new vehicle with the same plate using the POST /vehiculo endpoint. The system will automatically reactivate the existing deleted record instead of creating a duplicate.

When Deletion is Blocked

Deletion is prevented when:
  1. Active Missions: The vehicle has one or more active missions assigned
  2. Already Deleted: The vehicle is already marked as deleted
  3. Not Found: The vehicle ID doesn’t exist in the system
In these cases, appropriate error responses are returned with specific status codes and messages.

Build docs developers (and LLMs) love