Contents
On this page

Create Vehicle Unit - Plugixa Car Rental

POST /plugixa-car-rental/v1/vehicle-units

Create a car.

The user needs the plugixa_car_rental_create capability.

Request

POST https://your-site.example/wp-json/plugixa-car-rental/v1/vehicle-units

Request body

Content type: application/json

Field Type Required Description
vehicle_model_id integer Yes An existing vehicle model.
plate string Yes Upper-cased, spaces collapsed. Must not be the plate of another car in the fleet: plates are compared on letters and digits only, so AB-123-CD and ab 123 cd are the same.
vin string No 17 letters and digits, without I, O or Q. Spaces are removed and it is upper-cased. Must not be another car’s.
color string No Colour.
odometer integer No Reading, not negative. Defaults to 0.
home_location_id integer No The location the car is based at, or 0 for none. A car with a home location is only given to bookings picked up there; one without is given to any desk.
notes string No Staff notes, plain text.
status string No published (the default) or unpublished.
{
  "vehicle_model_id": 4,
  "plate": "AB-123-CD",
  "vin": "VF3MCYHZRNS123456",
  "color": "Grey",
  "odometer": 18250,
  "home_location_id": 1
}

Responses

201 Created. data is the new car.

{
  "success": true,
  "data": {
    "id": 9,
    "vehicle_model_id": 4,
    "plate": "AB-123-CD",
    "plate_key": "AB123CD",
    "vin": "VF3MCYHZRNS123456",
    "color": "Grey",
    "odometer": 18250,
    "home_location_id": 1,
    "notes": "",
    "status": "published",
    "created_by": 1,
    "modified_by": 1,
    "created_at": "2026-11-12 09:30:00",
    "modified_at": "2026-11-12 09:30:00",
    "deleted_at": null,
    "vehicle_model_name": "Peugeot 3008",
    "home_location_name": "Paris Gare de Lyon"
  }
}
Field Type Meaning
data.id integer The car’s id
data.vehicle_model_id integer The model this car is
data.vehicle_model_name string|null That model’s name
data.plate string Licence plate, upper case, single spaces
data.status string published or unpublished. Only a published car is given to bookings
data.home_location_id integer|null The desk it is based at, or null for any desk
data.home_location_name string|null That location’s name
data.odometer integer Last known reading
data.plate_key string The plate with only letters and digits, used to find duplicates
data.vin string Vehicle identification number, or empty
data.color string Colour
data.notes string|null Staff notes
data.created_at string UTC datetime the record was created
data.modified_at string UTC datetime of the last change. Send it back on an update to be warned of a conflicting edit
data.deleted_at string|null null unless the record is in the trash

Errors

Status Code When
422 plugixa_car_rental_unknown_reference vehicle_model_id is missing or not a vehicle model, or home_location_id is not a location. data.field names it.
422 plugixa_car_rental_missing_plate plate is missing or blank.
422 plugixa_car_rental_invalid_vin vin is not 17 letters and digits without I, O or Q.
409 plugixa_car_rental_duplicate_plate Another car in the fleet has this plate.
409 plugixa_car_rental_duplicate_vin Another car in the fleet has this VIN.
422 plugixa_car_rental_invalid_choice status is not published or unpublished. data.allowed lists the accepted values.
422 plugixa_car_rental_not_a_number A number field was sent as something else. data.field names it.
422 plugixa_car_rental_negative_number A number field that cannot be negative is. data.field names it.
422 plugixa_car_rental_too_long A text field is longer than its column. data.field names it and data.max gives the limit.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-car-rental/v1/vehicle-units" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"vehicle_model_id":4,"plate":"AB-123-CD","vin":"VF3MCYHZRNS123456","color":"Grey","odometer":18250,"home_location_id":1}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-rental/v1/vehicle-units');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'vehicle_model_id' => 4,
        'plate'            => 'AB-123-CD',
        'vin'              => 'VF3MCYHZRNS123456',
        'color'            => 'Grey',
        'odometer'         => 18250,
        'home_location_id' => 1,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const auth = Buffer.from(`admin:${process.env.WP_APP_PASSWORD}`).toString('base64');
const response = await fetch('https://your-site.example/wp-json/plugixa-car-rental/v1/vehicle-units', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    vehicle_model_id: 4,
    plate: 'AB-123-CD',
    vin: 'VF3MCYHZRNS123456',
    color: 'Grey',
    odometer: 18250,
    home_location_id: 1,
  }),
});
const { data } = await response.json();

Quick Links

Share