Overview
The Vehicles API provides endpoints for complete CRUD operations on vehicle records, including integration with an external license plate API for automated data retrieval.Key Features
- Complete CRUD Operations: Create, read, update, and delete vehicle records
- External API Integration: Automatically populate vehicle data from external license plate API
- Advanced Filtering: Filter vehicles by plate, brand, model, class, and state
- Pagination Support: Efficient data retrieval with paginated responses
- Soft Delete: Logical deletion preserves data integrity
Available Endpoints
Create Vehicle
Create a new vehicle with complete data
Create by Plate
Create vehicle using external plate API
Query Plate
Query external plate API for vehicle information
List Vehicles
List vehicles with pagination and filters
Get Vehicle
Get a specific vehicle by ID
Update Vehicle
Update an existing vehicle
Delete Vehicle
Delete a vehicle (soft delete)
Common Validations
License Plate
License Plate
- Required field
- Must be unique across all active vehicles
- Automatically converted to uppercase
- Spaces are removed
- If a deleted vehicle with the same plate exists, it will be reactivated
Vehicle Class
Vehicle Class
- Required field
- Must exist in the system catalog
- Must be active
Vehicle State
Vehicle State
- Required field
- Must exist in the system catalog
- Must be active
Foreign Keys
Foreign Keys
- Optional fields (Fuel Type, Default Driver, Assigned Department)
- If provided, they must exist in their respective catalogs
- Must be active
External API Integration
The system integrates with an external license plate API to automatically retrieve vehicle information:- Authentication: The system authenticates with the external API
- Data Retrieval: Vehicle data is fetched by license plate
- Owner Verification: Verifies the owner belongs to the institution (configurable via
PLACA_API_PROPIETARIO_FILTRO) - Auto-mapping: Automatically finds vehicle class in the catalog
- Data Population: Auto-fills brand, model, year, color, engine, chassis, VIN, circulation card date, and insurance policy
Response Format
All endpoints return responses in the following format:Error Handling
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid input data |
| 403 | Forbidden - Owner doesn’t belong to institution |
| 404 | Not Found - Resource doesn’t exist |
| 409 | Conflict - Duplicate plate or active missions |
| 500 | Internal Server Error |
| 502/503/504 | External API errors |