Contents
Create Coupon - Plugixa Car Parking
POST /plugixa-car-parking/v1/coupons
Create a discount coupon that customers can enter when they book.
The signed-in user needs the plugixa_carparking_create capability (create records).
Note.
valid_togiven as a bare date means midnight at the start of that day, so the coupon stops working as the day begins. To keep it valid all day, send a time:2027-02-28 23:59.
Request
POST https://your-site.example/wp-json/plugixa-car-parking/v1/coupons
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
code |
string |
Yes | What the customer types. Plain text, at most 60 characters. Must not be used by another coupon, including one in the trash. |
type |
string |
No | percent (the default) or fixed. |
amount |
number |
No | Percentage off for percent, at most 100. Amount off for fixed; a fixed discount never takes more than the subtotal. Not negative. Defaults to 0. |
min_amount |
number |
No | Minimum subtotal for the coupon to apply. Empty or null means none. |
usage_limit |
integer |
No | Redemptions allowed in total. Empty, null or 0 means no limit. |
usage_limit_per_user |
integer |
No | Redemptions allowed per signed-in customer. Empty, null or 0 means no limit. Guests are not counted. |
valid_from |
string |
No | YYYY-MM-DD, optionally followed by a time (YYYY-MM-DD HH:MM or HH:MM:SS, a T also works), in the site’s time zone. Empty means valid at once. |
valid_to |
string |
No | Same format. Must not be before valid_from. Empty means no end. |
applies_to |
object |
No | {"locations": [ids], "space_types": [ids]}. Limits the coupon to those locations and space types; an empty or missing list means no limit. The ids are not checked. |
status |
string |
No | active (the default) or inactive. Only an active coupon is accepted at booking. |
period_type |
string |
No | Stored as given, both by default. Nothing in 1.2.0 reads it. |
{
"code": "WINTER10",
"type": "percent",
"amount": 10,
"min_amount": 20,
"usage_limit": 100,
"usage_limit_per_user": 1,
"valid_from": "2026-12-01",
"valid_to": "2027-02-28 23:59",
"applies_to": { "locations": [4] }
}
Responses
201 Created. data is the new coupon.
{
"success": true,
"data": {
"id": 5,
"code": "WINTER10",
"type": "percent",
"amount": 10,
"usage_limit": 100,
"used_count": 0,
"usage_limit_per_user": 1,
"min_amount": 20,
"valid_from": "2026-12-01 00:00:00",
"valid_to": "2027-02-28 23:59:00",
"applies_to": { "locations": [4] },
"period_type": "both",
"status": "active",
"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 new coupon’s id |
data.amount |
number |
Percentage or amount off |
data.used_count |
integer |
Redemptions so far: 0 for a new coupon |
data.valid_from, data.valid_to |
string|null |
Stored as YYYY-MM-DD HH:MM:SS, site time zone |
data.applies_to |
object|null |
The ids as stored |
data.created_at |
string |
UTC datetime |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_carparking_missing_code |
code is missing or blank. |
409 |
plugixa_carparking_duplicate_code |
Another coupon uses code. When that coupon is in the trash, message says so: restore it, or purge it to free the code. |
422 |
plugixa_carparking_invalid_choice |
type or status is not one of its values. |
422 |
plugixa_carparking_invalid_percent |
type is percent and amount is above 100. |
422 |
plugixa_carparking_invalid_range |
valid_to is before valid_from. |
422 |
plugixa_carparking_invalid_date |
valid_from or valid_to is not a real date in the format above. |
422 |
plugixa_carparking_not_a_number |
A number field is not a number. |
422 |
plugixa_carparking_negative_number |
A number field is negative. |
422 |
plugixa_carparking_number_too_large |
A number field is above 99999999. |
422 |
plugixa_carparking_too_long |
code or period_type is longer than its column holds. |
500 |
plugixa_carparking_insert_failed |
The database refused the row. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-car-parking/v1/coupons" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"code":"WINTER10","type":"percent","amount":10,"min_amount":20,"usage_limit":100,"usage_limit_per_user":1,"valid_from":"2026-12-01","valid_to":"2027-02-28 23:59","applies_to":{"locations":[4]}}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/coupons');
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([
'code' => 'WINTER10',
'type' => 'percent',
'amount' => 10,
'min_amount' => 20,
'usage_limit' => 100,
'usage_limit_per_user' => 1,
'valid_from' => '2026-12-01',
'valid_to' => '2027-02-28 23:59',
'applies_to' => ['locations' => [4]],
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-car-parking/v1/coupons', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({
code: 'WINTER10',
type: 'percent',
amount: 10,
min_amount: 20,
usage_limit: 100,
usage_limit_per_user: 1,
valid_from: '2026-12-01',
valid_to: '2027-02-28 23:59',
applies_to: { locations: [4] },
}),
});
const { data } = await response.json();
Quick Links
Share