Contents
On this page

Create Voucher - Plugixa PDF Vouchers for WooCommerce

POST /plugixa-pdf-vouchers/v1/vouchers

Make a voucher outside an order, for a prize, a goodwill gesture or a sale at the counter, like Create voucher on the Vouchers screen. Its history starts with an issue line and its source is manual.

Needs a user with the plugixa_pdfv_create 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

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

Request body

Content type: application/json

Field Type Required Description
amount number Yes The value, more than 0, in the store currency.
kind string No mpv gift card (default) or spv product voucher.
recipient_name string No Who it is for.
recipient_email string No Must be a valid address when given.
from_name string No The sender printed on the PDF.
message string No The personal message.
code string No Your own code, for a card you already printed. Empty generates one from the code pattern in Settings.
expires_at string No YYYY-MM-DD (valid to the end of that day) or a date-time. An empty string means never. Leave it out for the store default.
template_id integer No The PDF design, 0 for the store default.
uses_allowed integer No For a product voucher, how many uses, 0 for no limit.
note string No Saved on the issue line of the history.
send boolean No true emails the voucher to recipient_email at once.
{
  "amount": 50,
  "recipient_name": "Inès Lambert",
  "recipient_email": "ines.lambert@example.net",
  "from_name": "Maison Willow",
  "message": "Thank you for your patience.",
  "note": "Goodwill, delayed order",
  "send": true
}

Responses

201 Created. data is the new voucher.

{
  "success": true,
  "data": {
    "id": 96,
    "code": "PX-7KQ4-M2ZD",
    "code_norm": "PX7KQ4M2ZD",
    "kind": "mpv",
    "status": "active",
    "currency": "EUR",
    "initial_amount": 50,
    "balance": 50,
    "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": "Inès Lambert",
    "recipient_email": "ines.lambert@example.net",
    "from_name": "Maison Willow",
    "message": "Thank you for your patience.",
    "template_id": 0,
    "locale": "en_US",
    "vendor_id": 0,
    "source": "manual",
    "deliver_at": null,
    "delivered_at": null,
    "expires_at": "2027-11-20 10:14:02",
    "created_by": 1,
    "created_at": "2026-11-20 10:14:02",
    "updated_at": "2026-11-20 10:14:02",
    "version": 1,
    "batch": "",
    "recipient_phone": "",
    "meta": [],
    "is_expired": false,
    "order_url": "",
    "service": null
  }
}

Fields as in List Vouchers. With send, the email goes out during the request; read its result in the voucher’s deliveries with Get Voucher.

Errors

Status Code When
401 / 403 plugixa_pdfv_forbidden The caller lacks the capability.
422 plugixa_pdfv_invalid_email The recipient email address is not valid.
422 plugixa_pdfv_create_failed The value is not more than 0, or the code you gave is taken: That voucher code already exists.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"amount":50,"recipient_name":"Inès Lambert","recipient_email":"ines.lambert@example.net","from_name":"Maison Willow","message":"Thank you for your patience.","note":"Goodwill, delayed order","send":true}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/vouchers');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => getenv('WP_USER') . ':' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => ['Content-Type: application/json'],
    CURLOPT_POSTFIELDS     => json_encode([
        'amount'          => 50,
        'recipient_name'  => 'Inès Lambert',
        'recipient_email' => 'ines.lambert@example.net',
        'from_name'       => 'Maison Willow',
        'message'         => 'Thank you for your patience.',
        'note'            => 'Goodwill, delayed order',
        'send'            => true,
    ]),
]);
$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', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ amount: 50, recipient_name: 'Inès Lambert', recipient_email: 'ines.lambert@example.net', from_name: 'Maison Willow', message: 'Thank you for your patience.', note: 'Goodwill, delayed order', send: true }),
});
const { data } = await response.json();

Quick Links

Share