Contents
On this page
Generate Codes - Plugixa PDF Vouchers for WooCommerce
POST /plugixa-pdf-vouchers/v1/bulk/generate
Make many vouchers of the same value in one go, for a promotion, a printed booklet or a partner, like Generate codes in Bulk codes and CSV import. They are not emailed. Download the codes with Export Batch.
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.
Note. Pro only: on the free plugin this route answers
404rest_no_route.
Request
POST https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/bulk/generate
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
count |
integer |
Yes | 1 to 500. |
amount |
number |
Yes | The value of each voucher, more than 0. |
kind |
string |
No | mpv (default) or spv. |
pattern |
string |
No | A code pattern, at least 7 #. Empty uses the pattern in the settings. |
expires_at |
string |
No | YYYY-MM-DD. Leave it out for the store default; empty for never. |
template_id |
integer |
No | The PDF design, 0 for the default. |
note |
string |
No | Saved in each voucher’s history. |
{
"count": 100,
"amount": 25,
"pattern": "SUMMER-#######",
"expires_at": "2027-09-30",
"note": "Summer partner booklet"
}
Responses
201 Created when at least one voucher was made, otherwise 422. This route answers without the usual wrapper.
{
"batch": "bulk-261120-111502-k7qm",
"created": 100,
"errors": []
}
| Field | Type | Meaning |
|---|---|---|
batch |
string |
The batch name, for List Vouchers batch and Export Batch |
created |
integer |
Vouchers made |
errors |
object[] |
Up to 50 failures: line and message |
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_pdfv_forbidden |
The caller lacks the capability. |
422 |
plugixa_pdfv_bulk_count |
count is outside 1 to 500: Choose between 1 and 500 vouchers. |
422 |
plugixa_pdfv_bulk_amount |
The amount must be greater than zero. |
422 |
plugixa_pdfv_bulk_pattern |
The pattern has fewer than 7 # or other characters than capital letters, digits, # and dashes. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/bulk/generate" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"count":100,"amount":25,"pattern":"SUMMER-#######","expires_at":"2027-09-30","note":"Summer partner booklet"}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/bulk/generate');
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([
'count' => 100,
'amount' => 25,
'pattern' => 'SUMMER-#######',
'expires_at' => '2027-09-30',
'note' => 'Summer partner booklet',
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/bulk/generate', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ count: 100, amount: 25, pattern: 'SUMMER-#######', expires_at: '2027-09-30', note: 'Summer partner booklet' }),
});
const { data } = await response.json();
Quick Links
Share