Contents
On this page

Save Coupon - Plugixa Stream

POST /plugixa-stream/v1/admin/coupons

Create a promo code, or replace the one with the same code. Its uses so far are kept. A use counts when an order is paid, not when checkout opens.

Needs a user with the plugixa_stream_manage_settings capability (signed in with an Application Password or the login cookie). Administrators hold it; other roles only when you grant it.

Request

POST https://your-site.example/wp-json/plugixa-stream/v1/admin/coupons

Request body

Content type: application/json

Field Type Required Description
code string Yes 3 to 40 letters, digits, - or _. Stored in capitals.
type string No percent (the default) or fixed.
value integer Yes 1 to 100 for percent; an amount above 0, in minor units, for fixed.
applies string No pack, vip or all (the default).
max_uses integer No 0 (the default) for no limit.
once_per_account boolean No Defaults to true.
expires string No Last day it works, Y-m-d, in the site’s time zone. Empty for never.
{
  "code": "SPRING20",
  "type": "percent",
  "value": 20,
  "applies": "all",
  "max_uses": 100,
  "expires": "2026-12-31"
}

Responses

200 OK. data is every coupon.

{
  "success": true,
  "data": [
    {
      "code": "SPRING20",
      "type": "percent",
      "value": 20,
      "applies": "all",
      "max_uses": 100,
      "uses": 12,
      "once_per_account": true,
      "expires": "2026-12-31"
    }
  ]
}
Field Type Meaning
data[].code string 3 to 40 letters, digits, - or _, in capitals
data[].type string percent or fixed
data[].value integer A percentage, or an amount in minor units
data[].applies string pack, vip or all
data[].max_uses integer 0 for no limit
data[].uses integer Paid orders that used it
data[].once_per_account boolean One use per account
data[].expires string Last day, Y-m-d, or empty

Errors

Status Code When
401 / 403 plugixa_stream_forbidden The caller lacks the capability.
422 plugixa_stream_invalid The code is not 3 to 40 allowed characters, or the value is out of range.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-stream/v1/admin/coupons" \
  -u "$WP_USER:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"code":"SPRING20","type":"percent","value":20,"applies":"all","max_uses":100,"expires":"2026-12-31"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-stream/v1/admin/coupons');
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([
        'code'     => 'SPRING20',
        'type'     => 'percent',
        'value'    => 20,
        'applies'  => 'all',
        'max_uses' => 100,
        'expires'  => '2026-12-31',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-stream/v1/admin/coupons', {
  method: 'POST',
  headers: {
    'Authorization': `Basic ${btoa(`${process.env.WP_USER}:${process.env.WP_APP_PASSWORD}`)}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ code: 'SPRING20', type: 'percent', value: 20, applies: 'all', max_uses: 100, expires: '2026-12-31' }),
});
const { data } = await response.json();

Quick Links

Share