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.
- Go to WooCommerce, Settings, Advanced, Webhooks.
- Select Add webhook. The Webhook data form opens.
- Fill in the fields described in the table below.
- Select Save webhook.
- 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.
| Field | What it does |
|---|---|
| Name | A label for you. WooCommerce fills in a default such as “Webhook created on” plus the date, and you can change it. |
| Status | Active delivers the payload. Paused does not deliver. Disabled means delivery stopped because of failures. |
| Topic | When the webhook fires, for example Order created, Product deleted or Customer updated. Action and Custom topics are covered below. |
| Delivery URL | The URL that receives the payload. |
| Secret | Used 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.createdorproduct.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_hooksfilter, 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.
| Header | Meaning |
|---|---|
| X-WC-Webhook-Topic | The topic, for example order.created. |
| X-WC-Webhook-Resource and X-WC-Webhook-Event | The resource (order) and the event (created). |
| X-WC-Webhook-Signature | A base64 encoded HMAC-SHA256 hash of the payload, made with the webhook secret. |
| X-WC-Webhook-ID and X-WC-Webhook-Delivery-ID | The webhook and the individual delivery, useful for logging and for spotting repeats. |
| X-WC-Webhook-Source | The 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?
| Symptom | Likely cause | What to check |
|---|---|---|
| Nothing arrives | Webhook is Paused or Disabled, or Action Scheduler is not running | Status in the webhook list, then WooCommerce, Status, Scheduled Actions for pending woocommerce_deliver_webhook_async items |
| Webhook switched to Disabled | Repeated failed deliveries. By default WooCommerce disables a webhook after 5 failures, where anything other than a 2xx, 301 or 302 response counts as a failure | Fix the receiver, set the status back to Active, and raise the limit with the woocommerce_max_webhook_delivery_failures filter only if you must |
| Timeouts | The receiver does too much work before answering | Acknowledge first and process in a queue. A timeout counts as a failed delivery |
| Signature does not match | Wrong secret, a re-encoded body, or a proxy that alters the body | Hash the raw body with the exact secret saved in the webhook |
| Same event twice | Retries or repeated queue runs | Store the delivery ID and ignore repeats, so the handler is safe to run twice |
| No idea what happened | You are not reading the logs | WooCommerce, 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.



