Skip to main content
POST
/
api
/
vehicles
curl -X POST "http://localhost:8080/api/vehicles" \
  -H "Content-Type: application/json" \
  -d '{
    "brand": "BMW",
    "model": "X5",
    "hp": 335,
    "autonomy": 650,
    "averageconsumption": 8.5,
    "description": "Luxury SUV with advanced features",
    "price": 65000.00,
    "year": 2024,
    "fuelType": "diesel",
    "mileage": 15000,
    "extras": "Navigation, Leather seats, Sunroof",
    "doors": 5,
    "vehicleType": "SUV",
    "offers": "Yes"
  }'
{
  "id": 42,
  "reference": "BMW2024A1B2",
  "brand": "BMW",
  "model": "X5",
  "hp": 335,
  "autonomy": 650,
  "averageconsumption": 8.5,
  "description": "Luxury SUV with advanced features",
  "price": 65000.00,
  "year": 2024,
  "fuelType": "diesel",
  "mileage": 15000,
  "extras": "Navigation, Leather seats, Sunroof",
  "createdAt": "2024-03-01T15:30:00",
  "updatedAt": "2024-03-01T15:30:00",
  "doors": 5,
  "vehicleType": "SUV",
  "offers": "Yes",
  "images": []
}
Creates a new vehicle. The reference field is auto-generated if not provided, following the format: {BRAND}{YEAR}{RANDOM} (e.g., BMW2024A1B2). The ID is auto-assigned and any provided ID will be ignored.

Request Body

brand
string
required
Vehicle brand name
model
string
required
Vehicle model name
reference
string
Unique reference code. If not provided or blank, it will be auto-generated using the format: {BRAND}{YEAR}{RANDOM}
hp
integer
Horsepower
autonomy
integer
Autonomy/range in kilometers
averageconsumption
double
Average fuel consumption
description
string
Vehicle description
price
decimal
Vehicle price
year
integer
Manufacturing year (used in auto-generated reference)
fuelType
string
Fuel type (e.g., gasoline, diesel, electric, hybrid)
mileage
long
Mileage in kilometers
extras
string
Additional features and extras
doors
integer
Number of doors
vehicleType
string
Type of vehicle (e.g., sedan, suv, truck, motorcycle)
offers
string
Special offers status (e.g., “Yes” or “No”)
images
array
Array of vehicle images

Response

Returns the created Vehicle object with auto-generated ID and reference.
id
long
Auto-generated unique identifier
reference
string
Auto-generated or provided reference code
brand
string
Vehicle brand name
model
string
Vehicle model name
hp
integer
Horsepower
autonomy
integer
Autonomy/range in kilometers
averageconsumption
double
Average fuel consumption
description
string
Vehicle description
price
decimal
Vehicle price
year
integer
Manufacturing year
fuelType
string
Fuel type
mileage
long
Mileage in kilometers
extras
string
Additional features and extras
createdAt
datetime
Timestamp when created
updatedAt
datetime
Timestamp when last updated
doors
integer
Number of doors
vehicleType
string
Type of vehicle
offers
string
Special offers status
images
array
Array of vehicle images
curl -X POST "http://localhost:8080/api/vehicles" \
  -H "Content-Type: application/json" \
  -d '{
    "brand": "BMW",
    "model": "X5",
    "hp": 335,
    "autonomy": 650,
    "averageconsumption": 8.5,
    "description": "Luxury SUV with advanced features",
    "price": 65000.00,
    "year": 2024,
    "fuelType": "diesel",
    "mileage": 15000,
    "extras": "Navigation, Leather seats, Sunroof",
    "doors": 5,
    "vehicleType": "SUV",
    "offers": "Yes"
  }'
{
  "id": 42,
  "reference": "BMW2024A1B2",
  "brand": "BMW",
  "model": "X5",
  "hp": 335,
  "autonomy": 650,
  "averageconsumption": 8.5,
  "description": "Luxury SUV with advanced features",
  "price": 65000.00,
  "year": 2024,
  "fuelType": "diesel",
  "mileage": 15000,
  "extras": "Navigation, Leather seats, Sunroof",
  "createdAt": "2024-03-01T15:30:00",
  "updatedAt": "2024-03-01T15:30:00",
  "doors": 5,
  "vehicleType": "SUV",
  "offers": "Yes",
  "images": []
}

Build docs developers (and LLMs) love