Contents
On this page

Create Agent - Plugixa Chat

POST /plugixa-chat/v1/agents

Add a person visitors can reach, with their channel and opening hours.

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

Request body

Content type: application/json

Field Type Required Description
name string Yes Shown to visitors. Up to 191 characters.
slug string Yes A channel from the channel catalogue that opens a link, such as whatsapp or phone. A channel that opens a panel, such as contact_form, is refused.
value string Yes The number, handle or address on that channel. Up to 500 characters.
role string No The line under the name, such as “Sales”.
message string No The pre-filled message, for channels that support one. Up to 500 characters.
photo object No An uploaded image ({"type":"upload","id":15}, which must be an image in the media library) or a library icon. Anything else is dropped.
hours array No When this person is shown, as weekday:start-end strings in minutes since midnight on the site’s clock, 0 for Sunday. "1:540-1080" is Monday 09:00 to 18:00. Up to 28 windows. Empty means always.
widget_id integer No The widget they belong to. 0 (the default) shows them on every widget.
is_active boolean No Whether they are shown. Left out, the agent is saved switched off.
sort_order integer No Position in the list. Defaults to 0.
{
  "name": "Sara",
  "role": "Sales",
  "slug": "whatsapp",
  "value": "+15550001234",
  "message": "Hi Sara, I have a question",
  "hours": [
    "1:540-1080",
    "2:540-1080"
  ],
  "widget_id": 0,
  "is_active": true
}

Responses

201 Created. data is the new agent.

{
  "success": true,
  "data": {
    "id": 4,
    "name": "Sara",
    "role": "Sales",
    "photo": null,
    "slug": "whatsapp",
    "value": "+15550001234",
    "message": "Hi Sara, I have a question",
    "hours": [
      "1:540-1080",
      "2:540-1080"
    ],
    "widget_id": 0,
    "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"
  }
}
Field Type Meaning
data.id integer The agent’s id
data.name string The name visitors see
data.role string The line under the name
data.photo object|null The photo, or null
data.slug string The channel this person answers on
data.value string Their number, handle or address on that channel
data.hours array Opening hours as weekday:start-end, see the request body
data.widget_id integer The widget they belong to, 0 for every widget
data.is_active boolean Whether they are shown
data.created_at string UTC datetime
data.deleted_at string|null null unless the agent is in the trash

Errors

Status Code When
400 plugixa_chat_agent_name name is missing or blank.
400 plugixa_chat_agent_channel slug is not a channel that opens a link.
400 plugixa_chat_agent_value value is missing or blank.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-chat/v1/agents" \
  -u "admin:$WP_APP_PASSWORD" \
  -H "Content-Type: application/json" \
  -d '{"name":"Sara","role":"Sales","slug":"whatsapp","value":"+15550001234","message":"Hi Sara, I have a question","hours":["1:540-1080","2:540-1080"],"widget_id":0,"is_active":true}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chat/v1/agents');
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'      => 'Sara',
        'role'      => 'Sales',
        'slug'      => 'whatsapp',
        'value'     => '+15550001234',
        'message'   => 'Hi Sara, I have a question',
        'hours'     => ['1:540-1080', '2:540-1080'],
        'widget_id' => 0,
        'is_active' => true,
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-chat/v1/agents', {
  method: 'POST',
  headers: {
    'Authorization': 'Basic ' + btoa(`admin:${process.env.WP_APP_PASSWORD}`),
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ name: 'Sara', role: 'Sales', slug: 'whatsapp', value: '+15550001234', message: 'Hi Sara, I have a question', hours: ['1:540-1080', '2:540-1080'], widget_id: 0, is_active: true }),
});
const { data } = await response.json();

Quick Links

Share