Contents
On this page

Update Voucher - Plugixa PDF Vouchers for WooCommerce

PATCH /plugixa-pdf-vouchers/v1/vouchers/{id}

Change the details of a voucher. Only the fields you send change. The balance never changes here: use Adjust Voucher Balance.

Needs a user with the plugixa_pdfv_edit capability (signed in with an Application Password, or the login cookie with an X-WP-Nonce header). Administrators and shop managers get it when the plugin is activated; see Staff access.

Request

PATCH https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95

Path parameters

Name Type Description
id integer The voucher’s id

Request body

Content type: application/json

Field Type Required Description
recipient_name string No Who it is for.
recipient_email string No A valid address, or empty.
from_name string No The sender.
message string No The personal message.
template_id integer No The PDF design, 0 for the store default.
expires_at string No YYYY-MM-DD (valid to the end of that day) or a date-time. Empty means never.
version integer No The version you last read. When it no longer matches, the save is refused with 409.

Moving the expiry date of an expired voucher into the future makes it active again. The balance written off when it expired is not put back: add it with Adjust Voucher Balance.

{
  "expires_at": "2027-06-30",
  "version": 2
}

Responses

200 OK. data is the voucher as saved, without its history.

{
  "success": true,
  "data": {
    "id": 95,
    "code": "PX-M9P2-FU55",
    "code_norm": "PXM9P2FU55",
    "kind": "mpv",
    "status": "active",
    "currency": "EUR",
    "initial_amount": 30,
    "balance": 30,
    "uses_allowed": 0,
    "uses_count": 0,
    "product_id": 0,
    "variation_id": 0,
    "order_id": 0,
    "order_item_id": 0,
    "allowed_product_ids": [],
    "allowed_category_ids": [],
    "buyer_user_id": 0,
    "buyer_email": "",
    "recipient_name": "Claire Morel",
    "recipient_email": "claire.morel@example.net",
    "from_name": "",
    "message": "Sorry for the wait during your last visit. Your next tea is on us.",
    "template_id": 1,
    "locale": "en_US",
    "vendor_id": 0,
    "source": "manual",
    "deliver_at": null,
    "delivered_at": "2026-11-07 16:51:19",
    "expires_at": "2027-06-30 23:59:59",
    "created_by": 1,
    "created_at": "2026-11-07 16:50:39",
    "updated_at": "2026-11-20 10:20:41",
    "version": 3,
    "batch": "",
    "recipient_phone": "",
    "meta": [],
    "is_expired": false,
    "order_url": "",
    "service": null
  }
}

The plugixa_pdfv_voucher_updated action runs after the save. See Hooks.

Errors

Status Code When
401 / 403 plugixa_pdfv_forbidden The caller lacks the capability.
404 plugixa_pdfv_not_found No voucher with that id.
422 plugixa_pdfv_invalid_email The recipient email address is not valid.
409 plugixa_pdfv_conflict version is stale: Somebody else changed this voucher while you were editing it. Reload and try again.

Plus the errors every endpoint can return.

Examples

curl -s -X PATCH "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"expires_at":"2027-06-30","version":2}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'PATCH',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'expires_at' => '2027-06-30',
        'version'    => 2,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers/95', {
  method: 'PATCH',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ expires_at: '2027-06-30', version: 2 }),
});
const { data } = await response.json();

Quick Links

Share