Contents
Create Extra - Plugixa Car Rental
POST /plugixa-car-rental/v1/extras
Create an extra.
Needs the Extras app on. The user needs the plugixa_car_rental_create capability.
Request
POST https://your-site.example/wp-json/plugixa-car-rental/v1/extras
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Must not be blank. |
price |
number |
No | Not negative. Rounded to 2 decimals. Defaults to 0. |
price_type |
string |
No | per_day (the default) or per_rental. |
max_total |
number |
No | For a per-day extra, the most it costs for one rental. 0 (the default) for no cap. When set, at least price. |
max_quantity |
integer |
No | 1 to 20. Defaults to 1. |
description |
string |
No | Plain text. |
sort_order |
integer |
No | Position in lists, lowest first. Defaults to 0. May be negative. |
status |
string |
No | published (the default) or unpublished. |
{
"name": "Child seat",
"description": "For children from 9 to 18 kg.",
"price": 8,
"price_type": "per_day",
"max_total": 40,
"max_quantity": 2
}
Responses
201 Created. data is the new extra.
{
"success": true,
"data": {
"id": 3,
"name": "Child seat",
"description": "For children from 9 to 18 kg.",
"price": 8.0,
"price_type": "per_day",
"max_total": 40.0,
"max_quantity": 2,
"sort_order": 0,
"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
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The extra’s id. Send it in a booking’s extras |
data.name |
string |
The name customers see |
data.price |
number |
Price per day or per rental |
data.price_type |
string |
per_day or per_rental |
data.max_total |
number |
Most a per-day extra costs for one rental, 0 for no cap |
data.max_quantity |
integer |
Most a booking may take, 1 to 20 |
data.status |
string |
published or unpublished. Only a published extra is offered |
data.description |
string|null |
Plain text |
data.sort_order |
integer |
Position in lists, lowest first |
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_invalid |
name is blank, price or max_total is negative, max_quantity is outside 1 to 20, or max_total is below price. data.field names the field. |
422 |
plugixa_car_rental_invalid_choice |
status or price_type is not one of its values. data.allowed lists them. |
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/extras" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Child seat","description":"For children from 9 to 18 kg.","price":8,"price_type":"per_day","max_total":40,"max_quantity":2}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-rental/v1/extras');
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([
'name' => 'Child seat',
'description' => 'For children from 9 to 18 kg.',
'price' => 8,
'price_type' => 'per_day',
'max_total' => 40,
'max_quantity' => 2,
]),
]);
$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/extras', {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
name: 'Child seat',
description: 'For children from 9 to 18 kg.',
price: 8,
price_type: 'per_day',
max_total: 40,
max_quantity: 2,
}),
});
const { data } = await response.json();
Quick Links
Share