Contents
On this page
Import Codes - Plugixa PDF Vouchers for WooCommerce
POST /plugixa-pdf-vouchers/v1/bulk/import
Bring gift cards over from another system, like Import from CSV in Bulk codes and CSV import. Each row becomes a gift card with the balance given, not emailed. A bad row is skipped and never stops the others.
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/import
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
csv |
string |
Yes | The CSV text, up to 1 MB and 2000 rows. Comma or semicolon separated, an optional header row naming code, amount, expires_at, recipient_email, recipient_name (or voucher, balance, value, expiry, expires, email, name) in any order. Without a header, that order is used. |
amount is the balance the customer can still spend; a comma decimal works. An empty expiry means the voucher never expires. A code needs at least 4 letters or digits and at most 64 characters.
{
"csv": "code,amount,expires_at,recipient_email,recipient_name\nGIFT-2025-0001,50,2026-12-31,claire.morel@example.net,Claire Morel\nGIFT-2025-0002,22.50,,,\n"
}
Responses
200 OK, even when every row failed. No wrapper.
{
"batch": "import-261120-112040-p3vd",
"created": 2,
"failed": 0,
"errors": []
}
| Field | Type | Meaning |
|---|---|---|
batch |
string |
The batch name, empty when nothing was imported |
created |
integer |
Vouchers imported |
failed |
integer |
Rows skipped |
errors |
object[] |
Up to 100 skipped rows: line, code, message, for example The amount is not a number greater than zero. or That voucher code already exists. |
Errors
| Status | Code | When |
|---|---|---|
401 / 403 |
plugixa_pdfv_forbidden |
The caller lacks the capability. |
422 |
plugixa_pdfv_import_empty |
The file is empty. |
422 |
plugixa_pdfv_import_size |
The file is larger than 1 MB. Split it into smaller files. |
422 |
plugixa_pdfv_import_rows |
A file can hold at most 2000 vouchers. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/bulk/import" \
-u "$WP_USER:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"csv":"code,amount,expires_at,recipient_email,recipient_name\nGIFT-2025-0001,50,2026-12-31,claire.morel@example.net,Claire Morel\nGIFT-2025-0002,22.50,,,\n"}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/bulk/import');
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([
'csv' => 'code,amount,expires_at,recipient_email,recipient_name
GIFT-2025-0001,50,2026-12-31,claire.morel@example.net,Claire Morel
GIFT-2025-0002,22.50,,,
',
]),
]);
$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/import', {
method: 'POST',
headers: {
'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({ csv: 'code,amount,expires_at,recipient_email,recipient_name
GIFT-2025-0001,50,2026-12-31,claire.morel@example.net,Claire Morel
GIFT-2025-0002,22.50,,,
' }),
});
const { data } = await response.json();
Quick Links
Share