Contents
On this page

Submit Lead - Plugixa Chat

POST /plugixa-chat/v1/leads/submit

Store a contact form message as a lead, exactly as the widget’s form does, and send the new-lead e-mail when the settings ask for one.

Public: no login. The request needs the page token for lead (see Public routes) and is limited to 5 per visitor every five minutes.

A caught submission looks like a real one. When the trap field is filled or elapsed is under 3000, the answer is the same 201, but nothing is stored and nobody is notified.

Request

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

Request body

Content type: application/json

Field Type Required Description
widget integer Yes An active widget with a switched-on Contact form channel.
fields object Yes name, email, phone and message, and with Pro the custom fields f1, f2 and so on. Only the fields the form shows are read; the ones it marks required must be filled.
consent boolean No Must be true when the form shows a consent box.
subscribe boolean No The newsletter box. Kept only when the form offers it.
website string No The trap field. Must be empty.
elapsed integer Yes Milliseconds since the form was opened. Under 3000 is treated as a program.
page string No The page address. Kept only when it is on this site.
turnstile string No The Cloudflare Turnstile token. Required when Turnstile is on.
token string No The page token, when it is not sent in the X-Plugixa-Chat-Token header.

email must be a valid address and phone a number with its country code. The message is cut at 5000 characters, phone at 64 and the other fields at 191.

{
  "widget": 2,
  "fields": {
    "name": "Jane Doe",
    "email": "jane@example.com",
    "message": "Do you ship to Canada?"
  },
  "consent": true,
  "subscribe": false,
  "website": "",
  "elapsed": 8400,
  "page": "https://your-site.example/shop/"
}

Responses

201 Created. The message was received.

{
  "success": true,
  "data": {
    "received": true
  }
}
Field Type Meaning
data.received boolean Always true

Webhooks PRO and CRM connections PRO fire for a stored lead.

Errors

Status Code When
404 plugixa_chat_no_form The widget is not active, is in the trash, or has no switched-on contact form.
400 plugixa_chat_invalid_lead A field is missing or invalid. data.fields holds a message per field, keyed by field name or consent.
400 plugixa_chat_turnstile_failed Turnstile is on and its check was missing or failed.
500 plugixa_chat_lead_not_saved The lead could not be written.
403 plugixa_chat_missing_token No page token was sent.
403 plugixa_chat_stale_token The token has expired. Fetch a fresh one from Get Context.
403 plugixa_chat_bad_origin The Origin or Referer header names another site.
429 plugixa_chat_rate_limited This visitor has used its 5 submissions for the current five minutes.

Plus the errors every endpoint can return.

Examples

curl -s -X POST "https://your-site.example/wp-json/plugixa-chat/v1/leads/submit" \
  -H "X-Plugixa-Chat-Token: $PLUGIXA_CHAT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"widget":2,"fields":{"name":"Jane Doe","email":"jane@example.com","message":"Do you ship to Canada?"},"consent":true,"subscribe":false,"website":"","elapsed":8400,"page":"https://your-site.example/shop/"}'
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-chat/v1/leads/submit');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST  => 'POST',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'X-Plugixa-Chat-Token: ' . getenv('PLUGIXA_CHAT_TOKEN'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS     => json_encode([
        'widget'    => 2,
        'fields'    => [
            'name'    => 'Jane Doe',
            'email'   => 'jane@example.com',
            'message' => 'Do you ship to Canada?',
        ],
        'consent'   => true,
        'subscribe' => false,
        'website'   => '',
        'elapsed'   => 8400,
        'page'      => 'https://your-site.example/shop/',
    ]),
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-chat/v1/leads/submit', {
  method: 'POST',
  headers: {
    'X-Plugixa-Chat-Token': process.env.PLUGIXA_CHAT_TOKEN,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ widget: 2, fields: { name: 'Jane Doe', email: 'jane@example.com', message: 'Do you ship to Canada?' }, consent: true, subscribe: false, website: '', elapsed: 8400, page: 'https://your-site.example/shop/' }),
});
const { data } = await response.json();

Quick Links

Share