Contents
On this page

Create PDF Design - Plugixa PDF Vouchers for WooCommerce

POST /plugixa-pdf-vouchers/v1/templates

Add a design, like Add design on the PDF designs screen.

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/templates

Request body

Content type: application/json

Field Type Required Description
name string Yes on create The design’s name.
preset string No The layout. Unknown values are ignored. Defaults to classic.
paper string No A4, A5 or LETTER.
orientation string No L (default) or P.
is_default boolean No Make it the store default.
settings object No Any of the settings of Get PDF Design. Missing ones keep their value, or the layout’s starting value. A colour that is not hex is ignored.
layout object No Pro: the elements of a drag-and-drop design, checked and cleaned before it is stored.
{
  "name": "Birthday pink",
  "preset": "classic",
  "paper": "A5",
  "orientation": "L",
  "settings": {
    "title": "Happy Birthday",
    "accent": "#d6336c",
    "show_qr": true
  }
}

Responses

201 Created. data is the new design, fields as in Get PDF Design.

Errors

Status Code When
401 / 403 plugixa_pdfv_forbidden The caller lacks the capability.
422 plugixa_pdfv_name_required No name: Give the design a name.
500 plugixa_pdfv_create_failed The design could not be saved.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Birthday pink","preset":"classic","paper":"A5","orientation":"L","settings":{"title":"Happy Birthday","accent":"#d6336c","show_qr":true}}'
<?php
$ch = curl_init('https://your-store.example/wp-json/plugixa-pdf-vouchers/v1/templates');
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([
        'name'        => 'Birthday pink',
        'preset'      => 'classic',
        'paper'       => 'A5',
        'orientation' => 'L',
        'settings'    => [
            'title'   => 'Happy Birthday',
            'accent'  => '#d6336c',
            'show_qr' => 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/templates', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Birthday pink', preset: 'classic', paper: 'A5', orientation: 'L', settings: { title: 'Happy Birthday', accent: '#d6336c', show_qr: true } }),
});
const { data } = await response.json();

Quick Links

Share