Contents
On this page

Create Widget - Plugixa Chat

POST /plugixa-chat/v1/widgets

Create a widget, with its appearance, channels and targeting rules in one request.

The signed-in user needs the plugixa_chat_create capability. Administrators have it.

Note. name is only checked when you send it. A request that leaves it out creates a widget with an empty name.

Request

POST https://your-site.example/wp-json/plugixa-chat/v1/widgets

Request body

Content type: application/json

Field Type Required Description
name string Yes Shown only in the admin. Sending it blank is refused.
status string No active or inactive. Anything else, or leaving it out, gives inactive.
sort_order integer No Position among the widgets. Defaults to 0.
appearance object No The launcher’s look. See Appearance. Missing keys take their defaults.
channels array No The channel rows, in display order. See Channels.
rules array No The targeting rules, in evaluation order. See Rules.

A widget is created with a complete appearance even when you send none. Saving clears the plugin’s cached widget data, so the next page served picks up the change (a full-page cache may need purging too).

Appearance

Every key is optional. A value out of range is brought into range, and an unknown value falls back to the default.

Key Type Default Description
position string right left or right
layout string vertical vertical or horizontal
animation string none none, bounce, pulse, shake, spin, fade, float, sheen, blink or wobble
trigger string click How the menu opens: click, hover or open
size integer 56 Launcher size in pixels, 44 to 96
offset_x, offset_y integer 24 Distance from the screen edge in pixels, 0 to 400
color string #0f766e #rrggbb. #rgb is expanded
icon_color string #ffffff #rrggbb. #rgb is expanded
cta string The greeting bubble. HTML, reduced to a short list of allowed tags
label string The launcher’s label text
icon object|null null A custom launcher icon: an uploaded image ({"type":"upload","id":15}, which must be an image in the media library) or a library icon. Anything else is dropped
badge integer 0 The unread badge’s number, 0 (off) to 9
show_delay integer 0 Seconds before the launcher appears, 0 (off) to 600
show_scroll integer 0 Percentage of the page scrolled before it appears, 0 (off) to 100
show_exit boolean false Show it when the visitor moves to leave the page

Channels

Each row of channels:

Key Type Description
slug string A channel from the channel catalogue. An unknown slug drops the row
value string The number, handle or address. Up to 500 characters. A value starting javascript:, data: or vbscript: drops the row
label string The row’s own text
message string The pre-filled message or subject, for channels that support one. {title} and the other merge tags are filled in on the page
is_active boolean Whether the row shows. Left out, the row is switched off
devices string all (default), desktop or mobile
color string #rrggbb. Defaults to the channel’s brand colour
new_tab boolean Open the link in a new tab
hover string Tooltip text, up to 100 characters
qr boolean Show a code to scan on a computer. Kept only for channels that support it
icon object|null A custom icon, as for appearance.icon
settings object A panel channel’s own settings, such as the contact form’s fields. Ignored for other channels

Rules

Each row of rules:

Key Type Description
kind string template, url, post, post_type, term, device, logged_in, referrer, visits, role, ab, and with Pro schedule, country and language. An unknown kind drops the row
mode string show (default) or hide
operator string in (default), not_in, contains, starts, ends, exact or regex
values array Strings. Blank strings are removed, and a rule left with no values is dropped

Rows that are dropped are left out silently: compare the response with what you sent. ab is written by Pro’s A/B tests; do not write it yourself.

{
  "name": "Main widget",
  "status": "active",
  "appearance": {
    "position": "right",
    "size": 56,
    "color": "#0f766e"
  },
  "channels": [
    {
      "slug": "whatsapp",
      "value": "+15550001234",
      "message": "Hi! I'm on {title}",
      "is_active": true
    }
  ],
  "rules": [
    {
      "kind": "url",
      "mode": "hide",
      "operator": "contains",
      "values": [
        "/checkout"
      ]
    }
  ]
}

Responses

201 Created. data is the new widget.

{
  "success": true,
  "data": {
    "id": 2,
    "name": "Main widget",
    "status": "active",
    "appearance": {
      "position": "right",
      "layout": "vertical",
      "animation": "none",
      "trigger": "click",
      "size": 56,
      "offset_x": 24,
      "offset_y": 24,
      "color": "#0f766e",
      "icon_color": "#ffffff",
      "cta": "",
      "label": "",
      "icon": null,
      "badge": 0,
      "show_delay": 0,
      "show_scroll": 0,
      "show_exit": false
    },
    "sort_order": 0,
    "deleted_at": null,
    "created_at": "2026-11-12 09:30:00",
    "modified_at": "2026-11-12 09:30:00",
    "created_by": "1",
    "modified_by": "1",
    "channels": [
      {
        "id": 31,
        "widget_id": 2,
        "slug": "whatsapp",
        "label": "",
        "value": "+15550001234",
        "message": "Hi! I'm on {title}",
        "is_active": true,
        "sort_order": 0,
        "deleted_at": null,
        "created_at": "2026-11-12 09:30:00",
        "modified_at": "2026-11-12 09:30:00",
        "created_by": "1",
        "modified_by": "1",
        "color": "#25d366",
        "new_tab": false,
        "devices": "all",
        "icon": null,
        "hover": "",
        "qr": false,
        "settings": []
      }
    ],
    "rules": [
      {
        "id": 8,
        "widget_id": 2,
        "kind": "url",
        "mode": "hide",
        "operator": "contains",
        "value": "[\"\\/checkout\"]",
        "sort_order": "0",
        "deleted_at": null,
        "created_at": "2026-11-12 09:30:00",
        "modified_at": "2026-11-12 09:30:00",
        "created_by": "1",
        "modified_by": "1",
        "values": [
          "/checkout"
        ]
      }
    ],
    "channel_count": 1
  }
}
Field Type Meaning
data.id integer The widget’s id
data.name string Its name, shown only in the admin
data.status string active or inactive
data.channels array Every channel row, switched on or not, in display order
data.rules[].values array The rule’s values, as a list of strings. value holds the same list as a JSON string
data.channel_count integer How many channel rows the widget has

Errors

Status Code When
400 plugixa_chat_widget_name_required name was sent blank.
409 plugixa_chat_widget_limit The site already has as many widgets as the plugixa_chat_max_widgets filter allows.
500 plugixa_chat_widget_not_created The widget could not be written.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-chat/v1/widgets" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Main widget","status":"active","appearance":{"position":"right","size":56,"color":"#0f766e"},"channels":[{"slug":"whatsapp","value":"+15550001234","message":"Hi! I'm on {title}","is_active":true}],"rules":[{"kind":"url","mode":"hide","operator":"contains","values":["/checkout"]}]}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chat/v1/widgets');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_USERPWD        => 'admin:' . getenv('WP_APP_PASSWORD'),
    CURLOPT_HTTPHEADER     => [
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'name'       => 'Main widget',
        'status'     => 'active',
        'appearance' => [
            'position' => 'right',
            'size'     => 56,
            'color'    => '#0f766e',
        ],
        'channels'   => [
            [
                'slug'      => 'whatsapp',
                'value'     => '+15550001234',
                'message'   => 'Hi! I\'m on {title}',
                'is_active' => true,
            ],
        ],
        'rules'      => [
            [
                'kind'     => 'url',
                'mode'     => 'hide',
                'operator' => 'contains',
                'values'   => ['/checkout'],
            ],
        ],
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-chat/v1/widgets', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Main widget', status: 'active', appearance: { position: 'right', size: 56, color: '#0f766e' }, channels: [{ slug: 'whatsapp', value: '+15550001234', message: 'Hi! I\'m on {title}', is_active: true }], rules: [{ kind: 'url', mode: 'hide', operator: 'contains', values: ['/checkout'] }] }),
});
const { data } = await response.json();

Quick Links

Share