Docs

Webhook Support

8 min readUpdated November 3, 2026

WP Smart Consent can send every consent event to any URL that accepts an HTTP request. Use it for platforms without a built-in integration, for your own systems, and for automation tools such as Zapier, Make and n8n.

You can add as many webhooks as you like. Each one is independent, with its own URL, fields, authentication and filters.

Before you start#

  • A public http or https URL to receive the requests. Addresses on your local network and loopback addresses are refused, and the port must be 80, 443 or 8080.
  • WP-Cron, or Action Scheduler (included with WooCommerce), to send queued deliveries. If your site sets DISABLE_WP_CRON, make sure a real server cron calls wp-cron.php.

Adding a webhook#

  1. Go to WP Smart Consent → Webhooks and click Add webhook.
  2. On the General tab, turn on Enabled, give it a Name and paste the URL. New webhooks start disabled.
  3. Optional: enter a Secret key so you can verify requests.
  4. On the Fields tab, choose which fields to send and their JSON keys.
  5. On the Advanced tab, set the method, content type, authentication and filters if needed.
  6. Click Save.
  7. Click Send test and check the result.
Webhooks tab with two webhooks, Zapier — new subscriber and Google Sheets log (via Make), both Active, above the Recent deliveries table

General#

A webhook's General tab with Enabled on, the Name "Zapier — new subscriber", the URL, and a saved Secret key
SettingWhat it does
EnabledTurns this webhook on or off without deleting it.
NameA label shown in the webhook list and the delivery log.
URLThe endpoint that receives a request on each consent event. The request uses the Method set on the Advanced tab (POST by default).
Secret keyOptional. When set, every request is signed in the X-WPSC-Signature-256 header, plus the older X-WPSC-Signature. See Verifying requests. Once saved, it shows as Secret saved — paste to replace.

Fields#

A webhook's Fields tab mapping WPSC fields such as Email, First name and Last name to JSON keys, with Active switches

Each row maps a WPSC field to a JSON key, with an Active switch. A new webhook sends email, first_name and last_name. Phone, Company, Country, Order total and Source URL are listed but off. Use Add field for any other field: Consent date, or a custom field you added on the Data fields tab (Form input, Order meta, ACF field, User meta, Cookie or PHP hook).

A field is only included when it has a value. For example:

  • Order total comes from the order on every checkout: WooCommerce, FluentCart, SureCart, Easy Digital Downloads and GiveWP. A contact form has none.
  • Source URL is the page the visitor submitted from, when the browser sent it.
  • Consent date is the time of the consent event, in your site’s time zone (ISO 8601).
  • Extra fields you mapped in a form’s own WP Smart Consent settings (for example in HappyForms, Ninja Forms or Formidable Forms) reach webhooks under the key you gave them. To pick one in the WPSC field list here, add a field with the same key on the Data fields tab, with the source Form input.

Advanced#

A webhook's Advanced tab with Method, Content type, Authentication, Custom headers with a masked X-Api-Key value, the Also send when NOT consented switch, and the Only these sources checkboxes
SettingDefaultWhat it does
MethodPOSTPOST, PUT or PATCH.
Content typeJSONJSON (application/json) or Form (application/x-www-form-urlencoded).
AuthenticationNoneBearer token: paste the token. Basic auth: paste user:password (or an already base64-encoded value). Saved values are masked.
Custom headersEmptyOne per line, as Header-Name: value. Saved values are masked, for example X-Api-Key: ••••••••5b4a. Saving without changes keeps the originals. Host, Content-Length, Transfer-Encoding, Connection, Expect and the X-WPSC-* headers can’t be overridden.
Also send when NOT consentedOffAlso sends consent.declined events. These come from checkouts that report declined consent: WooCommerce, FluentCart, SureCart, Easy Digital Downloads and GiveWP. Forms only send consented submissions.
Only these sourcesAllTick checkouts and form plugins to limit this webhook to them. WooCommerce covers both the Checkout Block and the classic checkout. Leave everything unticked to send from every source.

Testing a webhook#

Click Send test at the bottom of a webhook. A sample payload is sent straight away, using the webhook’s current settings even if they aren’t saved yet, and even if the webhook is disabled. A saved secret or auth token is used if you haven’t replaced it.

The result appears next to the button, for example ✓ HTTP 200 in 123 ms or ✗ HTTP 401, and in Recent deliveries with a test badge.

The test payload has "event": "consent.test", "source": "test", the email test@example.com and sample values for the other fields (Test, Contact, +10000000000, Example Co, US, and so on).

Delivery and retries#

Deliveries are queued and sent in the background, so a slow or unavailable endpoint never slows down checkout or a form submission.

  • Each request has a 10-second timeout and doesn’t follow redirects.
  • A delivery succeeds when the endpoint returns any 2xx status.
  • Network errors, timeouts, HTTP 429 and 5xx responses are retried: up to 3 attempts in total, 1 minute and then 5 minutes apart.
  • Other 4xx responses, such as 400, 401 and 404, aren’t retried, because sending the same request again wouldn’t help. Check the URL, authentication and payload instead.
  • A URL that’s invalid or refused (private network, wrong port) isn’t retried either. The attempt is logged once as URL rejected.
  • If a webhook is disabled or deleted, its queued deliveries are dropped.
  • A queued delivery that can’t be sent within 2 days is dropped, so stale consent events are never sent.

The queue uses Action Scheduler when it’s available, and WP-Cron otherwise. The queue only holds a reference. The contact data is kept in a temporary entry and deleted once the delivery is done.

Recent deliveries#

Recent deliveries, below the webhook list, shows the last 50 attempts, tests included:

Recent deliveries table listing granted, declined and test events for two webhooks, with OK 200 results and two HTTP 503 results on attempt 2A failed attempt that’s retried appears again with the next attempt number.

ColumnWhat it shows
Time (UTC)When the attempt was made
WebhookThe webhook’s name, with a test badge for tests
Eventconsent.granted, consent.declined or consent.test
EmailThe contact’s email address
ResultOK and the status code, or the error
Attempt1, 2 or 3
TimeResponse time in milliseconds

Use Refresh to update the list and Clear to empty it. The log contains email addresses, so clear it when you no longer need it.

The payload#

With the JSON content type, the body contains the fields you mapped plus these event keys:

{
  "email": "jane@example.com",
  "first_name": "Jane",
  "last_name": "Doe",
  "wpsc_consented": true,
  "event": "consent.granted",
  "source": "woo_block",
  "timestamp": "2026-11-03T17:04:12+00:00",
  "site_url": "https://www.example.com"
}
KeyWhat it is
wpsc_consentedtrue when the visitor consented, false for declined events.
eventconsent.granted, consent.declined or consent.test.
sourceWhere the consent came from (see below).
timestampEvent time in ISO 8601 format, UTC.
site_urlYour site’s home URL.

Source values: woo_block (WooCommerce Checkout Block), woo_shc (WooCommerce classic checkout), fluentcart, surecart, edd, givewp, the form plugin’s slug (wpforms, gravityforms, fluentforms, everestforms, formidable, forminator, metform, quillforms, sureforms, cf7, ninjaforms, happyforms, bricks), or the slug of an integration added through the Developer API.

With the form content type, the same keys are sent URL-encoded, and true/false become 1/0.

Request headers#

HeaderWhat it is
Content-Typeapplication/json or application/x-www-form-urlencoded
User-AgentWPSmartConsent/1.5.3 (+https://your-site)
X-WPSC-EventSame as event in the payload
X-WPSC-WebhookThe webhook’s ID
X-WPSC-DeliveryA unique ID for this request. A retry gets a new ID.
X-WPSC-TimestampUnix time the request was signed. Only with a secret key.
X-WPSC-Signature-256t=<timestamp>,v1=<signature>. Only with a secret key.
X-WPSC-SignatureLegacy signature. Only with a secret key.
AuthorizationBearer … or Basic …, if you set authentication

Your custom headers are added on top of these.

Verifying requests#

When a secret key is set, check X-WPSC-Signature-256 to confirm that a request came from your site, wasn’t changed, and isn’t an old request being replayed:

  1. Split the header into t (timestamp) and v1 (signature).
  2. Compute HMAC-SHA256( t + "." + raw_request_body, secret ) as lowercase hex.
  3. Compare it with v1 using a constant-time comparison.
  4. Reject the request if t is more than 5 minutes from the current time.

Always use the raw request body exactly as received, before any JSON parsing.

PHP

$body   = file_get_contents( 'php://input' );
$header = $_SERVER['HTTP_X_WPSC_SIGNATURE_256'] ?? '';
parse_str( str_replace( ',', '&', $header ), $sig ); // ['t' => ..., 'v1' => ...]

$expected = hash_hmac( 'sha256', ( $sig['t'] ?? '' ) . '.' . $body, 'YOUR_SECRET' );

if ( ! hash_equals( $expected, $sig['v1'] ?? '' ) || abs( time() - (int) ( $sig['t'] ?? 0 ) ) > 300 ) {
    http_response_code( 401 );
    exit;
}

Node.js (Express)

const crypto = require('crypto');

app.post('/consent', express.raw({ type: '*/*' }), (req, res) => {
  const parts = Object.fromEntries(
    (req.get('X-WPSC-Signature-256') || '').split(',').map(p => p.split('='))
  );
  const expected = crypto.createHmac('sha256', 'YOUR_SECRET')
    .update(`${parts.t}.${req.body}`).digest('hex');

  const valid = parts.v1 && expected.length === parts.v1.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1)) &&
    Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;

  if (!valid) return res.sendStatus(401);
  res.sendStatus(200);
});
Code
const crypto = require('crypto');

app.post('/consent', express.raw({ type: '*/*' }), (req, res) => {
  const parts = Object.fromEntries(
    (req.get('X-WPSC-Signature-256') || '').split(',').map(p => p.split('='))
  );
  const expected = crypto.createHmac('sha256', 'YOUR_SECRET')
    .update(`${parts.t}.${req.body}`).digest('hex');

  const valid = parts.v1 && expected.length === parts.v1.length &&
    crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1)) &&
    Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;

  if (!valid) return res.sendStatus(401);
  res.sendStatus(200);
});

Legacy header. X-WPSC-Signature is HMAC-SHA256( raw_request_body, secret ). It’s still sent so existing receivers keep working, but it doesn’t protect against replays. Use X-WPSC-Signature-256 for new integrations.

Duplicates. A retry is a new request with a new X-WPSC-Delivery ID. If your endpoint timed out after processing a request, it may receive the same event again, so make your receiver safe to run twice, for example by checking the email and timestamp.

Using webhooks with automation platforms#

Point the URL at an incoming-webhook trigger in Zapier, Make or n8n, click Send test so the platform learns the fields, then map them to actions. Because each webhook is independent, you can send the same event to several platforms at once.

Troubleshooting#

Result or problemCause and fix
Enter a URL first.Add a URL before clicking Send test.
URL rejected (must be a public http/https address)The URL is invalid, on a private or local network, or uses a port other than 80, 443 or 8080.
✗ HTTP 401 or HTTP 403Authentication failed. Check the token, user:password or custom headers.
✗ HTTP 404The URL is wrong, or the automation’s trigger isn’t active.
✗ HTTP 3xxThe endpoint redirects. Redirects aren’t followed. Use the final URL.
Timeouts or cURL error messagesThe endpoint didn’t answer within 10 seconds, or can’t be reached from your server. These are retried twice.
HTTP 503 or another 5xx, then a higher Attempt numberThe endpoint was temporarily unavailable. The delivery is retried automatically, up to 3 attempts.
Tests work but real events never arriveCheck Enabled, Only these sources, and that the event is a consent (declined events need Also send when NOT consented). Check that WP-Cron runs.
A mapped field is missing from the payloadThe source didn’t provide a value for it, for example Order total on a form, or an empty custom field. Fields without a value are left out.
Signature doesn’t matchUse the raw body, before parsing, and the exact secret. With the form content type, sign the URL-encoded body as received.

Failed attempts are also written to the debug log as [WP Smart Consent] Webhook "…" attempt N failed: … when WP_DEBUG is on.

For developers#

HookUse
wpsc_webhook_data_before_send( $payload, $billing_data, $webhook )Change the payload.
wpsc_webhook_headers( $headers, $payload, $webhook )Change the headers.
wpsc_webhook_timeout( 10, $webhook )Change the timeout in seconds.
wpsc_webhook_async( true, $webhook )Return false to send immediately during the request instead of queuing.
wpsc_webhook_url_allowed( true, $url )Have the final say on whether a URL may be contacted.

Administrator-only REST routes: POST /wp-json/wpsc/v1/webhooks/test (send a test), GET /wp-json/wpsc/v1/webhooks/log and DELETE /wp-json/wpsc/v1/webhooks/log. See the Developer API.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only