WooCommerce Webhooks: Complete Setup & Troubleshooting Guide

10 minutes
WooCommerce Webhooks: Complete Setup & Troubleshooting Guide

To create a webhook in WooCommerce, go to WooCommerce, Settings, Advanced, Webhooks, select Add webhook, choose a topic such as Order created, enter the delivery URL that should receive the data, set a secret and save with the status Active. WooCommerce then sends an HTTP POST to that URL whenever the event happens. The part that decides whether it works in production is not the form, but the receiving end: it must verify the signature and answer quickly.

In short: create the webhook in the admin, with the REST API or with WP-CLI. Always set a secret and check the signature on the raw request body. Return a 2xx response fast and do the real work in a queue. After repeated failed deliveries WooCommerce disables the webhook, so add an alert and know how to re-enable it. This is a technical guide, so test on staging first.

What is a WooCommerce webhook?

A webhook is a message your store pushes to another system when something happens, for example when an order is created or a product is updated. The REST API works the other way round: an external system asks the store for data when it needs it. Most integrations use both. Webhooks announce that something changed, and the REST API fetches whatever extra data the receiver needs.

Typical uses are sending new orders to a CRM or fulfilment system, syncing stock with an ERP, triggering notifications, and feeding analytics. Webhooks have been part of WooCommerce since version 2.2.

What do you need before you start?

  • Administrator access to the store, or an API user with the right permissions.
  • A delivery URL on the public internet that the store can reach. A localhost address will not work from a hosted store, and HTTPS is strongly advised for order data.
  • A secret, which is a long random string shared only between the store and the receiver.
  • A receiver that answers quickly and can tolerate the same event arriving more than once.
  • A working background queue. WooCommerce delivers webhooks through Action Scheduler by default, so if scheduled actions do not run, webhooks do not go out.

How do you create a webhook in the WooCommerce admin?

The steps below follow the official WooCommerce developer documentation. Before WooCommerce 3.4 the screen lived under Settings, API.

  1. Go to WooCommerce, Settings, Advanced, Webhooks.
  2. Select Add webhook. The Webhook data form opens.
  3. Fill in the fields described in the table below.
  4. Select Save webhook.
  5. Check the result. The first time a webhook is saved with the Active status, WooCommerce sends a ping to the delivery URL, so your receiver should accept that request.
FieldWhat it does
NameA label for you. WooCommerce fills in a default such as “Webhook created on” plus the date, and you can change it.
StatusActive delivers the payload. Paused does not deliver. Disabled means delivery stopped because of failures.
TopicWhen the webhook fires, for example Order created, Product deleted or Customer updated. Action and Custom topics are covered below.
Delivery URLThe URL that receives the payload.
SecretUsed to sign each delivery. If you leave it empty, it defaults to the current API user’s consumer secret, so set your own.

Which topics can you use?

Predefined topics cover resources such as orders, products, customers and coupons, with events such as created, updated and deleted. Pick the narrowest topic that does the job, because each webhook has one topic and one delivery URL, and a broad topic produces traffic you then have to discard.

  • Predefined topics, for example order.created or product.updated.
  • Action, which ties the webhook to a WooCommerce action. An Action Event field appears, for example woocommerce_add_to_cart. For action topics the payload carries the action name and its first argument only.
  • Custom, for advanced use. New topics are added with the woocommerce_webhook_topic_hooks filter, which is a development task.

How do you create a webhook with the REST API or WP-CLI?

If you manage several stores or want webhooks in your deployment scripts, create them from code. The REST API endpoint is POST /wp-json/wc/v3/webhooks, and WP-CLI has a wc webhook command that requires a topic, a secret and a delivery URL. Use a dedicated API user with the minimum permissions, and keep the secret out of version control.

# REST API: create a webhook (authenticate with a WooCommerce API key)
curl -X POST https://example.com/wp-json/wc/v3/webhooks \
  -u consumer_key:consumer_secret \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Order created to CRM",
    "topic": "order.created",
    "delivery_url": "https://crm.example.com/hooks/woocommerce",
    "secret": "replace-with-a-long-random-string"
  }'

# WP-CLI: the same webhook
wp wc webhook create --user=1 \
  --name="Order created to CRM" \
  --topic=order.created \
  --delivery_url="https://crm.example.com/hooks/woocommerce" \
  --secret="replace-with-a-long-random-string"

What does WooCommerce actually send?

Each delivery is an HTTP POST with a JSON body. For created and updated events the body is the same resource you would get from the REST API. For deleted events it is just the resource ID. Identifying details travel in headers.

HeaderMeaning
X-WC-Webhook-TopicThe topic, for example order.created.
X-WC-Webhook-Resource and X-WC-Webhook-EventThe resource (order) and the event (created).
X-WC-Webhook-SignatureA base64 encoded HMAC-SHA256 hash of the payload, made with the webhook secret.
X-WC-Webhook-ID and X-WC-Webhook-Delivery-IDThe webhook and the individual delivery, useful for logging and for spotting repeats.
X-WC-Webhook-SourceThe URL of the store that sent the request.

By default WooCommerce does not send the request inside the page load. It queues a woocommerce_deliver_webhook_async action in Action Scheduler, and the request has a timeout of 60 seconds that the woocommerce_webhook_http_args filter can change. A slow receiver therefore ties up background processing on the store, so keep the endpoint fast.

How do you verify the signature on the receiving end?

Anyone who finds your delivery URL can post fake orders to it, so verify every request. A third-party guide describes the check: compute an HMAC-SHA256 of the raw request body with your secret, base64 encode it and compare it to the signature header. Use the raw body exactly as received, not a re-encoded copy, and compare with a constant-time function. The example is PHP, but the logic is the same in any language.

// Receiver: verify the signature on the raw body, then answer quickly.
$raw   = file_get_contents( 'php://input' );
$topic = $_SERVER['HTTP_X_WC_WEBHOOK_TOPIC'] ?? '';
$sig   = $_SERVER['HTTP_X_WC_WEBHOOK_SIGNATURE'] ?? '';

// The ping sent when a webhook is first activated has no topic header.
if ( '' === $topic ) {
	http_response_code( 200 );
	exit;
}

$expected = base64_encode( hash_hmac( 'sha256', $raw, WEBHOOK_SECRET, true ) );

if ( '' === $sig || ! hash_equals( $expected, $sig ) ) {
	http_response_code( 401 );
	exit;
}

// Store the payload in a queue for background work, then acknowledge.
// my_queue_push( $topic, $raw );
http_response_code( 200 );

The same guide reports that the activation ping carries no topic header and no signature, which is why the example lets it through. Test this on your own setup, because behaviour can differ between versions.

How do you change the payload?

Add data your receiver needs with the woocommerce_webhook_payload filter, which receives the payload, the resource type, the resource ID and the webhook ID. Keep payloads small and let the receiver call the REST API for anything large. Custom code like this belongs in a small plugin, not in a theme, see best practices for custom WordPress development.

// Store side: add a field to the order payload of every webhook.
add_filter( 'woocommerce_webhook_payload', 'wlc_add_fulfilment_ref', 10, 4 );

function wlc_add_fulfilment_ref( $payload, $resource, $resource_id, $webhook_id ) {
	if ( 'order' !== $resource || ! is_array( $payload ) || ! is_numeric( $resource_id ) ) {
		return $payload;
	}

	$order = wc_get_order( (int) $resource_id );

	if ( $order ) {
		$payload['fulfilment_ref'] = (string) $order->get_meta( '_fulfilment_ref' );
	}

	return $payload;
}

// Store side: get told when WooCommerce disables a webhook.
add_action( 'woocommerce_webhook_disabled_due_delivery_failures', 'wlc_alert_webhook_disabled' );

function wlc_alert_webhook_disabled( $webhook_id ) {
	wp_mail(
		get_option( 'admin_email' ),
		'WooCommerce webhook disabled',
		'Webhook ID ' . (int) $webhook_id . ' was disabled after repeated delivery failures.'
	);
}

Why is a webhook not firing, or disabled?

SymptomLikely causeWhat to check
Nothing arrivesWebhook is Paused or Disabled, or Action Scheduler is not runningStatus in the webhook list, then WooCommerce, Status, Scheduled Actions for pending woocommerce_deliver_webhook_async items
Webhook switched to DisabledRepeated failed deliveries. By default WooCommerce disables a webhook after 5 failures, where anything other than a 2xx, 301 or 302 response counts as a failureFix the receiver, set the status back to Active, and raise the limit with the woocommerce_max_webhook_delivery_failures filter only if you must
TimeoutsThe receiver does too much work before answeringAcknowledge first and process in a queue. A timeout counts as a failed delivery
Signature does not matchWrong secret, a re-encoded body, or a proxy that alters the bodyHash the raw body with the exact secret saved in the webhook
Same event twiceRetries or repeated queue runsStore the delivery ID and ignore repeats, so the handler is safe to run twice
No idea what happenedYou are not reading the logsWooCommerce, Status, Logs, delivery and server responses

To see what a webhook sends before your own receiver exists, point it at a temporary endpoint such as webhook.site and trigger the event on a staging store. Never send real customer data to a third-party test endpoint.

How do you monitor webhooks in production?

WooCommerce core does not alert you when it disables a webhook, so add your own check. The alert hook in the example above is a start, and a scheduled check of webhook statuses is a second layer. It is also worth knowing that a failed delivery is not retried and not resent, according to a third-party production guide, so plan to reconcile missed events from the REST API after an outage, for instance by fetching orders changed since your last successful delivery.

If webhooks drive money or stock, treat them as part of the integration, with logging, alerts and a recovery procedure. That is the kind of work covered by WordPress development and ongoing care, and slow endpoints are a performance topic. For the data behind the orders, see which database WooCommerce uses.

Frequently asked questions

What is the difference between webhooks and the REST API?

Webhooks push a notification when an event happens. The REST API answers when you ask. Use webhooks to learn that something changed and the REST API to fetch details or catch up after an outage.

Why is my WooCommerce webhook not firing?

The usual causes are a Paused or Disabled status, scheduled actions that are not running, a topic that does not match the event you triggered, or a delivery URL the store cannot reach. Check the status, the Scheduled Actions screen and the logs, in that order.

Can I put a username and password in the delivery URL?

Avoid it. The URL is stored as plain text and can show up in logs and exports. Use HTTPS and verify the signature instead, and keep any credentials the receiver needs on the receiving side.

Do webhooks slow down my store?

Not on the page load by default, because delivery is queued. A slow or failing receiver can still hold up background processing, so keep it fast and monitor failures.

Can I resend a failed delivery?

Not from the admin, as far as current guides report. Fetch the missed data from the REST API once the receiver is healthy, and design the handler so that repeats do no harm.

Can I trigger a webhook from any WordPress action?

You can tie a webhook to a WooCommerce action through the Action topic, and add fully custom topics through a filter. The payload for an action topic carries only the first argument of the hook, so for richer data use a predefined topic or add data with the payload filter.

Pwel Zmyslowski

Paweł Zmysłowski

CEO WLC.team

At White Label Coders responsible for the sales process and sales team, still involved in the analytical and advisory roles in case of more complex projects.

Author page

Is your WordPress “working, but slow”?

MORE ARTICLES

Read also

  • How can I streamline the content approval process?
    16 minutes

    How can I streamline the content approval process?

    Streamlining your content approval process means setting up WordPress workflows that reduce review layers, automate notifications, and establish clear responsibilities. The most effective approaches combine WordPress user roles, editorial workflow plugins, standardised Gutenberg blocks, and centralised data management to remove bottlenecks. Together with agile methods and better communication protocols, they let content teams publish faster…

    Read

  • Why do my comparison tables cause layout shift?
    11 minutes

    Why do my comparison tables cause layout shift?

    Comparison tables often cause layout shift because parts of them load without reserved space, so content jumps around as the page renders. This happens when images lack dimensions, dynamic data loads without placeholders, or custom fonts reflow text after the first paint. Layout shift hurts user experience and your Core Web Vitals, which feed into…

    Read

  • How do you implement multiple payment gateways in iGaming platforms?
    11 minutes

    How do you implement multiple payment gateways in iGaming platforms?

    Implementing multiple payment gateways in iGaming platforms involves integrating several payment processors to offer diverse payment options, ensure regulatory compliance, and maximise transaction success rates. This approach requires careful technical planning, strong security measures, and intelligent routing systems. The process typically involves API integrations, database management, and thorough testing to create smooth payment experiences for…

    Read