Contents
On this page

Update Coupon - Plugixa Car Wash

PUT /plugixa-carwash/v1/coupons/{id}

Change some or all of a coupon’s fields. PATCH does the same as PUT.

Needs the Coupons app on, and the plugixa_carwash_edit capability.

Only what you send changes. A field you leave out keeps its value, so you can send a single field. A field you send is checked exactly as on create.

Request

PUT https://your-site.example/wp-json/plugixa-carwash/v1/coupons/9

Path parameters

Name Type Description
id integer The coupon’s id

Request body

Content type: application/json

Field Type Required Description
code string No 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.
type string No percent or fixed.
value number No 0.01 to 1000000, and at most 100 for a percentage.
min_total number No The booking subtotal it needs.
max_uses integer No 0 for unlimited.
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.
status string No published or unpublished.
modified_at string No The modified_at you last read. When the coupon has changed since, the update is refused with 409.
{
  "max_uses": 100,
  "modified_at": "2026-11-12 09:30:00"
}

Responses

200 OK. data is the updated 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
404 plugixa_carwash_not_found No coupon with that id, or it is in the trash.
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.
409 plugixa_carwash_conflict You sent modified_at and somebody saved the coupon since. data.expected and data.current hold both values.

Plus the errors every endpoint can return.

Examples

curl -s -X PUT "https://your-site.example/wp-json/plugixa-carwash/v1/coupons/9" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"max_uses":100,"modified_at":"2026-11-12 09:30:00"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-carwash/v1/coupons/9');
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([
        'max_uses'    => 100,
        'modified_at' => '2026-11-12 09:30:00',
    ]),
]);
$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/9', {
  method: 'PUT',
  headers: {
    'Authorization': `Basic ${auth}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ max_uses: 100, modified_at: '2026-11-12 09:30:00' }),
});
const { data } = await response.json();

Quick Links

Share