Contents
On this page
Update Coupon - Plugixa Car Parking
PUT /plugixa-car-parking/v1/coupons/{id}
Change some or all of a coupon’s fields. PATCH does exactly the same.
The signed-in user needs the plugixa_carparking_edit capability (change records).
Note. This is a merge, not a replace: only the fields you send change. To clear
min_amount, a limit or a date, send it empty ornull.used_countcannot be set: it only grows as the coupon is redeemed.
Request
PUT https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5
Path parameters
| Name | Type | Description |
|---|---|---|
id |
integer |
The coupon’s id |
Request body
Content type: application/json
Every field of Create Coupon, all optional, with the same rules:
| Field | Type | Required | Description |
|---|---|---|---|
code |
string |
No | Must not be blank, and not used by another coupon, including one in the trash. |
type |
string |
No | percent or fixed. |
amount |
number |
No | Empty means 0. With percent, at most 100: checked against the stored type when only amount is sent. |
min_amount |
number |
No | Empty or null clears it. |
usage_limit |
integer |
No | Empty or null clears it. |
usage_limit_per_user |
integer |
No | Empty or null clears it. |
valid_from |
string |
No | YYYY-MM-DD, optionally with a time, site time zone. Empty or null clears it. |
valid_to |
string |
No | Same format. Must not be before valid_from, the stored one when you send only valid_to. A bare date ends the coupon at the start of that day. |
applies_to |
object |
No | Replaces the whole object: {"locations": [ids], "space_types": [ids]}. |
status |
string |
No | active or inactive. |
period_type |
string |
No | Stored, not used in 1.2.0. An empty value is ignored. |
modified_at |
string |
No | The modified_at you read. When it no longer matches the stored one, the update is refused with 409. Leave it out to skip the check. |
{
"valid_to": "2027-03-31 23:59",
"usage_limit": 200
}
Responses
200 OK. data is the updated coupon.
{
"success": true,
"data": {
"id": 5,
"code": "WINTER10",
"type": "percent",
"amount": 10,
"usage_limit": 200,
"used_count": 12,
"usage_limit_per_user": 1,
"min_amount": 20,
"valid_from": "2026-12-01 00:00:00",
"valid_to": "2027-03-31 23:59:00",
"applies_to": { "locations": [4], "space_types": [] },
"period_type": "both",
"status": "active",
"created_by": 1,
"modified_by": 1,
"created_at": "2026-11-12 09:30:00",
"modified_at": "2026-11-12 10:15:00",
"deleted_at": null
}
}
| Field | Type | Meaning |
|---|---|---|
data.usage_limit |
integer|null |
Redemptions allowed in total |
data.used_count |
integer |
Redemptions so far, unchanged by an update |
data.valid_to |
string|null |
End of validity, site time zone |
data.modified_at |
string |
UTC datetime of this change |
Errors
| Status | Code | When |
|---|---|---|
404 |
plugixa_carparking_not_found |
No coupon with that id, or it is in the trash. |
409 |
plugixa_carparking_conflict |
modified_at was sent and somebody changed the coupon since. |
409 |
plugixa_carparking_duplicate_code |
Another coupon, live or in the trash, uses code. |
422 |
plugixa_carparking_missing_code |
code was sent blank. |
422 |
plugixa_carparking_invalid_choice |
type or status is not one of its values. |
422 |
plugixa_carparking_invalid_percent |
The coupon would be a percentage above 100. |
422 |
plugixa_carparking_invalid_range |
valid_to would be before valid_from. |
422 |
plugixa_carparking_invalid_date |
A date is not real or not 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. |
Plus the errors every endpoint can return.
Examples
curl -s -X PUT "https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"valid_to":"2027-03-31 23:59","usage_limit":200}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-car-parking/v1/coupons/5');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'PUT',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_USERPWD => 'admin:' . getenv('WP_APP_PASSWORD'),
CURLOPT_HTTPHEADER => ['Content-Type: application/json'],
CURLOPT_POSTFIELDS => json_encode([
'valid_to' => '2027-03-31 23:59',
'usage_limit' => 200,
]),
]);
$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/5', {
method: 'PUT',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ valid_to: '2027-03-31 23:59', usage_limit: 200 }),
});
const { data } = await response.json();
Quick Links
Share