DevelopersPro

Webhook payload and signature verification

The exact JSON Promptor Pro sends for each new lead, the sha256= signature header and how to verify it, plus retry and timeout behaviour.

Promptor Pro can send each new lead to your own endpoint as a webhook. This page is for developers building that endpoint: the headers and JSON body Promptor sends, how the signature is built and verified, and how deliveries and retries work. To set up webhooks in the admin, see Send leads to other tools with webhooks.

Webhooks are part of Promptor Pro. Compare plans.

What Promptor sends

PropertyValue
EventLead Created: fires when a visitor submits the lead or quote form in the chat. It is the only event you can turn on in 2.1.0.
MethodPOST to the Webhook URL you enter (HTTP or HTTPS; HTTPS strongly recommended)
BodyJSON, UTF-8, sent as-is (no form encoding)
SignatureHMAC-SHA256 of the raw body, hex-encoded, in X-Promptor-Signature as sha256=<hex>
SecretThe Secret Key shown on the Webhooks page, used exactly as shown
SuccessAny HTTP status from 200 to 299
TimeoutRequest Timeout: 5 to 30 seconds (default 10)
AttemptsRetry Attempts: 1 to 5 deliveries in total (default 3)
TLSVerify SSL/TLS certificates is on by default; turn it off only for local development

Payloads contain personal data such as names, email addresses, phone numbers and message content. Treat your endpoint and its logs accordingly (see Privacy, GDPR and the data Promptor stores).

Headers

HeaderExampleNotes
Content-Typeapplication/json
X-Promptor-Eventlead_createdThe event name, same as event in the body
X-Promptor-Signaturesha256=5d41402abc4b2a76…sha256= followed by 64 lowercase hex characters
X-Promptor-Delivery128Only on retries (attempt 2 and later). The ID of the delivery log row, the same on every retry of one delivery
User-AgentPromptor-Webhook/1.0

Payload

Every payload has the same envelope:

FieldTypeContents
eventstringlead_created
versionstringPayload format version, currently 1.0
timestampintegerWhen the payload was built, as a Unix timestamp in seconds (UTC)
dataobjectThe event's data (below)

lead_created

{
  "event": "lead_created",
  "version": "1.0",
  "timestamp": 1762678800,
  "data": {
    "lead_id": 42,
    "name": "Jane Doe",
    "email": "jane@example.com",
    "phone": "+44 20 7946 0000",
    "message": "We need a new kitchen before March. Budget around 15k.",
    "services": ["Kitchen Renovation", "Interior Design"],
    "products": []
  }
}
FieldTypeContents
lead_idintegerID of the lead in the promptor_submissions table, as shown on the Submissions screen
namestringName entered in the form (max 100 characters)
emailstringEmail address entered in the form
phonestringPhone number, or an empty string when the visitor left it empty
messagestringThe notes field of the form (max 5,000 characters), or an empty string
servicesarray of stringsTitles of the services the visitor ticked. Can be empty
productsarray of stringsReserved for products. The chat's form does not send products in 2.1.0, so expect an empty array

Values are sanitized as WordPress text before sending. Slashes and non-ASCII characters are not escaped, so https:// and ü appear as they are.

The lead score is not in this payload: Promptor builds the webhook before Pro's lead scoring runs. If you need the score, use the promptor_lead_scored action in PHP (see Hooks and filters), or look the lead up later.

Promptor's code also contains payload formats for lead_qualified and lead_scored events. In 2.1.0 the Webhooks screen offers only Lead Created and saving the settings keeps the other two off, so your endpoint receives only lead_created.

Change the payload or headers

If your code runs in WordPress, three filters let you adjust what is sent:

FilterArgumentsUse
promptor_webhook_payload$payload, $event, $dataAdd or remove fields. Runs before the body is encoded and signed, so your fields are covered by the signature.
promptor_webhook_headers$headers, $eventAdd headers, for example an API key your endpoint expects.
promptor_webhook_event_enabled$enabled, $eventReturn false to skip sending an event.
add_filter( 'promptor_webhook_payload', function ( $payload, $event ) {
    if ( 'lead_created' === $event ) {
        $payload['data']['site'] = home_url();
    }
    return $payload;
}, 10, 2 );

Verify the signature

Promptor computes hash_hmac( 'sha256', $raw_body, $secret ), hex-encodes it in lowercase and sends sha256= plus that hex string. To verify a request:

  1. Read the raw request body exactly as received, before any JSON parsing.
  2. Compute HMAC-SHA256 of that body with your secret key, as lowercase hex.
  3. Put sha256= in front of it.
  4. Compare the result with the X-Promptor-Signature header using a constant-time comparison.
  5. Reject the request with HTTP 401 if they don't match.

Always use the raw body. Parsing the JSON and serialising it again changes spacing, escaping or key order, and the signature no longer matches.

The key is the full Secret Key string from the Webhooks page, character for character. Promptor generates it once, when webhook settings are first created, as a random 64-character string that can contain symbols. If your key shows a prefix (for example whsec_), the prefix is part of the key. Store it in an environment variable, quoted, never in your code.

The Secret Key field is read-only and the 2.1.0 screen has no button to generate a new one.

Node.js (Express)

const express = require('express');
const crypto = require('crypto');

const app = express();
const SECRET = process.env.PROMPTOR_WEBHOOK_SECRET;

// Keep the raw body: verify before parsing.
app.post('/webhooks/promptor', express.raw({ type: 'application/json' }), (req, res) => {
  const received = String(req.get('X-Promptor-Signature') || '');

  const expected =
    'sha256=' +
    crypto.createHmac('sha256', SECRET).update(req.body).digest('hex');

  const a = Buffer.from(received, 'utf8');
  const b = Buffer.from(expected, 'utf8');

  if (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {
    return res.status(401).send('Invalid signature');
  }

  const payload = JSON.parse(req.body.toString('utf8'));
  // Respond quickly; do slow work in a queue.
  res.status(200).send('OK');

  // handleLead(payload.data);
});

app.listen(3000);

PHP

<?php
$secret = getenv( 'PROMPTOR_WEBHOOK_SECRET' );

$raw_body = file_get_contents( 'php://input' );
$received = $_SERVER['HTTP_X_PROMPTOR_SIGNATURE'] ?? '';
$expected = 'sha256=' . hash_hmac( 'sha256', $raw_body, $secret );

if ( ! hash_equals( $expected, $received ) ) {
    http_response_code( 401 );
    exit( 'Invalid signature' );
}

$payload = json_decode( $raw_body, true );

http_response_code( 200 );
echo 'OK';
// Process $payload['data'] here, or queue it.

hash_equals() and crypto.timingSafeEqual() compare in constant time, so an attacker cannot guess the signature from response timing. Never compare signatures with == or ===.

The payload has a timestamp, but it is not part of the signature header. If you want to reject old requests, check timestamp after the signature is verified.

Delivery and retries

Promptor does not send the webhook while the visitor waits. When a lead is saved, it schedules the delivery as a WP-Cron event, which runs on the next request to your site.

  • Success: a 2xx response. The delivery is logged as successful and nothing else happens.
  • Retried: connection errors, timeouts (no answer within Request Timeout) and 5xx responses.
  • Not retried: 4xx responses (and any other non-2xx status below 500). Promptor treats them as a problem with the request and logs the failure.
  • Number of tries: Retry Attempts counts every delivery, including the first. With the default of 3, Promptor tries once and retries up to twice.
  • Delay: about 4 seconds after the first failure and about 8 seconds after each later one. Retries are WP-Cron events too, so on a quiet site they run when the next visit arrives after that delay.

Because both the first delivery and retries run through WP-Cron, webhooks depend on it. If you set DISABLE_WP_CRON in wp-config.php, make sure a real server cron calls wp-cron.php regularly, or deliveries wait.

Make your handler idempotent. A slow 2xx after a timeout can lead to the same lead arriving twice. Use data.lead_id to ignore a lead you have already processed. On retries, X-Promptor-Delivery identifies the delivery as well.

Pause, logs and testing

  • Temporarily pause deliveries stops sending. Events created while paused are written to the delivery log with the status paused and are not sent later when you resume.
  • Each delivery is logged in the {prefix}promptor_webhook_logs table (event, lead ID, URL, HTTP status, up to 2 KB of the response body, attempt number, status success, failed or paused, error message). By default the stored payload keeps only event, version and timestamp; the lead's data is stored only if you tick Store full payload data in delivery logs. Version 2.1.0 has no screen that lists these logs, so read them from the database if you need them.
  • The Webhooks screen has no "send test" button. To see a real delivery, point Webhook URL at a request inspection service (for example webhook.site) or a Zapier Catch Hook, submit a test lead in the chat with test details such as jane@example.com, then put your real URL back. Never send real customers' details to a public request bin. See Connect Promptor to Zapier or Make.

Prefer PHP?

If your code runs on the same WordPress site, you don't need a webhook. promptor_lead_created fires right after a lead is saved, and promptor_after_insert_submission fires with the saved row. See Hooks and filters.

Still need help?

Our support team answers every ticket. Tell us your WordPress version, Promptor version and what you see.

Read the FAQSee what changed in each version

Open a support ticket

All help topics