Contents
Create A/B Test - Plugixa Chat
POST /plugixa-chat/v1/experiments
Create a test comparing two widgets. It is saved as a draft; nothing changes on the site until you start it.
Needs Plugixa Chat Pro. The signed-in user needs the plugixa_chat_create capability. Administrators have it.
Request
POST https://your-site.example/wp-json/plugixa-chat/v1/experiments
Request body
Content type: application/json
| Field | Type | Required | Description |
|---|---|---|---|
name |
string |
Yes | Up to 191 characters. |
widget_a |
integer |
Yes | An existing widget, not in the trash. |
widget_b |
integer |
Yes | Another existing widget. |
split |
integer |
No | Percentage of visitors shown widget A, 10 to 90. Defaults to 50. |
{
"name": "Green button or blue button",
"widget_a": 2,
"widget_b": 5,
"split": 50
}
Responses
201 Created. data is the new test.
{
"success": true,
"data": {
"id": 7,
"name": "Green button or blue button",
"widget_a": 2,
"widget_b": 5,
"split": 50,
"status": "draft",
"started_at": null,
"ended_at": null,
"winner_id": 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"
}
}
| Field | Type | Meaning |
|---|---|---|
data.id |
integer |
The test’s id |
data.widget_a, data.widget_b |
integer |
The two widgets compared |
data.split |
integer |
Percentage of visitors shown widget A. The rest see B |
data.status |
string |
draft, running or ended |
data.started_at |
string|null |
UTC datetime it started, null for a draft |
data.ended_at |
string|null |
UTC datetime it ended, null until then |
data.winner_id |
integer |
The widget kept when it ended, 0 until then |
Errors
| Status | Code | When |
|---|---|---|
400 |
plugixa_chat_test_name |
name is missing or blank. |
400 |
plugixa_chat_test_widgets |
A widget is missing, does not exist or is in the trash. |
400 |
plugixa_chat_test_same |
widget_a and widget_b are the same widget. |
409 |
plugixa_chat_test_busy |
One of the widgets is already in a running test. |
Plus the errors every endpoint can return.
Examples
curl -s -X POST "https://your-site.example/wp-json/plugixa-chat/v1/experiments" \
-u "admin:$WP_APP_PASSWORD" \
-H "Content-Type: application/json" \
-d '{"name":"Green button or blue button","widget_a":2,"widget_b":5,"split":50}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chat/v1/experiments');
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' => 'Green button or blue button',
'widget_a' => 2,
'widget_b' => 5,
'split' => 50,
]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-chat/v1/experiments', {
method: 'POST',
headers: {
'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
'Content-Type': 'application/json',
},
body: JSON.stringify({ name: 'Green button or blue button', widget_a: 2, widget_b: 5, split: 50 }),
});
const { data } = await response.json();
Quick Links
Share