Contents
On this page

End A/B Test - Plugixa Chat

POST /plugixa-chat/v1/experiments/{id}/end

End a running test and keep one of the two widgets.

Needs Plugixa Chat Pro. The signed-in user needs the plugixa_chat_edit capability. Administrators have it.

Ending switches the other widget off. The widget you do not keep is set to inactive. The one you keep is left as it is.

Request

POST https://your-site.example/wp-json/plugixa-chat/v1/experiments/7/end

Path parameters

Name Type Description
id integer The test’s id

Request body

Content type: application/json

Field Type Required Description
keep string Yes a or b: the widget to keep. It may also be sent as a query parameter.
{
  "keep": "b"
}

Responses

200 OK. data is the ended test.

{
  "success": true,
  "data": {
    "id": 7,
    "name": "Green button or blue button",
    "widget_a": 2,
    "widget_b": 5,
    "split": 50,
    "status": "ended",
    "started_at": "2026-11-12 09:40:00",
    "ended_at": "2026-11-19 09:40:00",
    "winner_id": 5,
    "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.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 rest_missing_callback_param keep is missing.
400 rest_invalid_param keep is not a or b.
404 plugixa_chat_test_missing No test has this id, or it is in the trash.
409 plugixa_chat_test_not_running The test is not running.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-chat/v1/experiments/7/end" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"keep":"b"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chat/v1/experiments/7/end');
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([
        'keep' => 'b',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-chat/v1/experiments/7/end', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ keep: 'b' }),
});
const { data } = await response.json();

Quick Links

Share