Contents
Create Coupon - Plugixa Car Wash
POST /plugixa-carwash/v1/coupons
Create a coupon.
Needs the Coupons app on, and the plugixa_carwash_create capability.
Request
POST https://your-site.example/wp-json/plugixa-carwash/v1/coupons
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
code |
string |
Yes | 3 to 40 letters, digits, dashes or underscores. Stored in upper case. Unique among coupons not in the trash. |
description |
string |
No | At most 190 characters. Defaults to empty. |
type |
string |
No | percent or fixed. Defaults to percent. |
value |
number |
Yes | 0.01 to 1000000, and at most 100 for a percentage. |
min_total |
number |
No | The booking subtotal it needs. Defaults to 0. |
max_uses |
integer |
No | 0 for unlimited. Defaults to 0. |
starts_on |
string |
No | Y-m-d. Anything else is stored as no date. |
ends_on |
string |
No | Y-m-d, not before starts_on. |
package_ids |
array |
No | Package ids it is limited to. Defaults to []. |
status |
string |
No | published or unpublished. Defaults to published. |
A coupon’s days are the site’s days. A percentage comes off the booking subtotal; a fixed amount is capped at the subtotal.
{
"code": "spring10",
"description": "Spring promotion",
"type": "percent",
"value": 10,
"starts_on": "2026-11-01",
"ends_on": "2026-11-30"
}
Responses
201 Created. data is the new coupon.
{
"success": true,
"data": {
"id": 9,
"code": "SPRING10",
"description": "Spring promotion",
"type": "percent",
"value": 10.0,
"min_total": 0.0,
"max_uses": 0,
"used_count": "3",
"starts_on": "2026-11-01",
"ends_on": "2026-11-30",
"package_ids": [],
"status": "published",
"created_by": 1,
"modified_by": 1,
"created_at": "2026-11-10 08:15:00",
"modified_at": "2026-11-12 09:30:00",
"deleted_at": null
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The coupon’s id |
data.code |
string |
Upper case |
data.type |
string |
percent or fixed |
data.value |
number |
Percent, or an amount in the booking’s currency |
data.min_total |
number |
Smallest booking it applies to |
data.max_uses |
integer |
0 means unlimited |
data.used_count |
string |
Bookings made with it so far. A number, sent as a string |
data.starts_on |
string|null |
First day it works, Y-m-d |
data.ends_on |
string|null |
Last day it works, Y-m-d |
data.package_ids |
array |
Packages it is limited to. Empty means every booking |
data.created_at |
string |
UTC datetime |
data.modified_at |
string |
UTC datetime of the last change. Send it back on an update to be warned about a conflicting edit |
data.deleted_at |
string|null |
null unless the record is in the trash |
Errors
| Status | Code | When |
|---|---|---|
422 |
plugixa_carwash_missing_code |
code is missing or empty. |
422 |
plugixa_carwash_missing_value |
value is missing or empty. |
422 |
plugixa_carwash_too_small_{field} / too_large_{field} |
A number is outside its range. The code names the field. |
422 |
plugixa_carwash_invalid_{field} |
A choice field has a value that is not one of its choices. The code names the field. |
422 |
plugixa_carwash_invalid_coupon |
A badly formed code, a percentage above 100, or an end before the start. The message says which. |
409 |
plugixa_carwash_duplicate_code |
Another coupon already uses this code. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-carwash/v1/coupons" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"code":"spring10","description":"Spring promotion","type":"percent","value":10,"starts_on":"2026-11-01","ends_on":"2026-11-30"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-carwash/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' => 'spring10',
'description' => 'Spring promotion',
'type' => 'percent',
'value' => 10,
'starts_on' => '2026-11-01',
'ends_on' => '2026-11-30',
]),
]);
$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-carwash/v1/coupons', {
method: 'POST',
headers: {
'Authorization': `Basic ${auth}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
code: 'spring10',
description: 'Spring promotion',
type: 'percent',
value: 10,
starts_on: '2026-11-01',
ends_on: '2026-11-30',
}),
});
const { data } = await response.json();
Quick Links
Share