Contents
On this page
Create Pricing Rule - Plugixa Car Parking
POST /plugixa-car-parking/v1/pricing-rules
Create a pricing rule: it raises, lowers or replaces the rate per billing unit or the booking fee when a booking matches its conditions. See Pricing rules.
Needs Plugixa Car Parking Pro. The WordPress user needs the plugixa_carparking_create capability (create records).
Note. Over the API a new rule defaults to
alter_typesetwith anamountof0, active, with no conditions. A rule created with only anametherefore sets the price to zero on every booking. The admin screen starts from different defaults, so always sendalter_type,amountand the conditions you mean.
Request
POST https://your-site.example/wp-json/plugixa-car-parking/v1/pricing-rules
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Must not be blank. |
alter_type |
string |
No | set (replace the price with amount), inc_value, dec_value, inc_percent or dec_percent. Defaults to set. |
amount |
number |
No | Zero or more. Defaults to 0. |
price_source |
string |
No | rate or initial. Defaults to rate. |
priority |
integer |
No | May be negative. Defaults to 0. |
status |
string |
No | active or inactive. Defaults to active. |
billing_type |
string|null |
No | minute, hour, day, week or month to limit the rule to bookings priced in that unit. null or empty: every unit. |
conditions |
object |
No | When the rule applies, as in the table below. A key you leave out is empty. Omitted: the rule applies to every booking. |
Conditions
Every condition narrows the rule; a rule matches when all of them hold. Dates, weekdays and times are tested against the entry.
| Key | Type | Description |
|---|---|---|
date_from |
string |
YYYY-MM-DD. The entry must be on or after this day. Empty: no start. |
date_to |
string |
YYYY-MM-DD, on or after date_from. The entry must be on or before this day. Empty: no end. |
weekdays |
integer[] |
Days the entry may fall on, 0 (Sunday) to 6 (Saturday). Empty: any day. |
time_from |
string |
HH:MM (seconds are accepted and dropped). The entry time must be at or after it. Empty: open. |
time_to |
string |
HH:MM. The entry time must be at or before it. An end earlier than the start wraps midnight (22:00 to 06:00). |
duration_min |
number|null |
Shortest stay in hours, zero or more. null: no minimum. |
duration_max |
number|null |
Longest stay in hours, not below duration_min. null: no maximum. |
location_ids |
integer[] |
Only at these locations. Empty: every location. |
space_type_ids |
integer[] |
Only for these space types. Empty: every space type. |
customer_group_ids |
integer[] |
Only for signed-in customers in one of these customer groups. Never applies to a guest. |
Ids and weekdays may be sent as numbers or strings of digits; they are stored as numbers. A value that cannot be used is refused rather than emptied, because emptying a condition would widen the rule. Every matching rule is applied in priority order, each to the price the one before it left, and a price never goes below zero. Pricing rules run before coupons, tax and deposits.
{
"name": "Weekend surcharge",
"priority": 10,
"alter_type": "inc_percent",
"amount": 15,
"price_source": "rate",
"conditions": {
"weekdays": [0, 6],
"location_ids": [2]
}
}
Responses
201 Created. data is the new pricing rule.
{
"success": true,
"data": {
"id": 6,
"name": "Weekend surcharge",
"priority": 10,
"status": "active",
"conditions": {
"date_from": "",
"date_to": "",
"weekdays": [0, 6],
"time_from": "",
"time_to": "",
"duration_min": null,
"duration_max": null,
"location_ids": [2],
"space_type_ids": [],
"customer_group_ids": []
},
"price_source": "rate",
"alter_type": "inc_percent",
"amount": 15.0,
"billing_type": null,
"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 rule’s id |
data.name |
string |
Shown to the customer beside the price it changed |
data.priority |
integer |
Matching rules are applied lowest first |
data.status |
string |
active or inactive |
data.alter_type |
string |
set, inc_value, dec_value, inc_percent or dec_percent |
data.amount |
number |
The amount or percentage the change uses |
data.price_source |
string |
rate (the price per billing unit) or initial (the fee charged once per booking) |
data.billing_type |
string|null |
The one billing unit the rule is limited to, or null for every unit |
data.conditions |
object |
When the rule applies. Every key is always present; see the conditions table on Create Pricing Rule |
data.created_at |
string |
UTC datetime |
data.modified_at |
string |
UTC datetime of the last change. Send it back on an update to have the change refused if somebody else saved first |
data.deleted_at |
string|null |
null unless the record is in the trash |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_carparking_missing_name |
name is missing or blank. |
422 |
plugixa_carparking_invalid_choice |
status, price_source, alter_type or billing_type is not one of the accepted values. data.allowed lists them. |
422 |
plugixa_carparking_not_a_number |
amount or priority is not a number. Use a dot for decimals. |
422 |
plugixa_carparking_number_too_large |
A number is larger than 99999999. |
422 |
plugixa_carparking_negative_number |
amount is negative. |
422 |
plugixa_carparking_invalid_condition |
A condition cannot be used: a date that does not exist, date_to before date_from, a weekday outside 0 to 6, a time not in HH:MM, a negative stay, duration_max below duration_min, or a list that holds something other than ids. data.field names it, for example conditions.date_to. |
422 |
plugixa_carparking_too_long |
A text field is longer than its column holds. data.field names it and data.max gives the limit. |
500 |
plugixa_carparking_insert_failed |
The database refused the new row. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-car-parking/v1/pricing-rules" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Weekend surcharge","priority":10,"alter_type":"inc_percent","amount":15,"price_source":"rate","conditions":{"weekdays":[0,6],"location_ids":[2]}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/pricing-rules');
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' => 'Weekend surcharge',
'priority' => 10,
'alter_type' => 'inc_percent',
'amount' => 15,
'price_source' => 'rate',
'conditions' => [
'weekdays' => [0, 6],
'location_ids' => [2],
],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-car-parking/v1/pricing-rules', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Weekend surcharge', priority: 10, alter_type: 'inc_percent', amount: 15, price_source: 'rate', conditions: { weekdays: [0, 6], location_ids: [2] } }),
});
const { data } = await response.json();
Quick Links
Share