How to Create a WooCommerce Webhook

What's a Webhook?

A webhook is an event notification sent to a URL of your choice. You can configure them so that an event on one site triggers an action on another site.

They help integrate with third-party services and other external APIs that support them.

Webhooks were introduced in WooCommerce v 2.2 and can trigger events each time you add, edit or delete orders, products, coupons, or customers. It is also possible to use webhooks with WooCommerce actions (for example, you can create a webhook to be used every time a product is added to the shopping cart with the action woocommerce_add_to_cart). Webhooks make it easier for third-party apps to integrate with WooCommerce. 

How to Create a Webhook in WooCommerce 

  • Navigate to WooCommerce > Settings > API > Webhooks
  • Click Add Webhook

    woocommerce-webhooks.webp
  • Enter your settings:
    • Name: A webhook is created with the name "Webhook created on [date and time of creation]" this is standard. However, you have the option to change the name to something else.
    • Status: Here, you can set the Webhooks status. The options available are "Active" (delivers payload), "Paused" (does not deliver), or "Disabled" (does not deliver due to delivery failures).
    • Topic: Indicate when the webhook will be triggered. We have several options like "Order Created, "Product Deleted," "Customer Updated," "Action," and "Custom."
    • Action Event: This option is available when the Topic is selected as "Action." Users should add a WooCommerce action name, such as woocommerce_add_to_cart, when customers add products to the shopping cart.
    • Custom Topic: This option is for advanced users only. It's possible to introduce new customized topics with the help of the woocommerce_webhook_topic_hooks filter.
    • Delivery URL: URL where the webhook payload is delivered.
    • Secret: A Secret Key is used to generate a hash of the delivered webhook and provided in the request headers. This will default to the current API user's consumer secret if not provided.
  • Save Webhook:
    • A ping to the delivery URL will be sent the first time your webhook is saved with the Activated status.

How to Edit and Delete a Webhook in WooCommerce

Webhooks are listed the same way as posts or products. You can edit or delete them using the Edit and Trash links.

webhooks-list.webp
 

Using Webhook Logs

WooCommerce saves logs of all events triggering a webhook. Logs may be reviewed to see deliveries and the response from the server, making it simpler to integrate and debug. 

  • Select a webhook and click edit.
  • Logs are at the bottom of the page.

    http__docs.woocommerce.com_wp-content_uploads_2015_01_woocommerce-webhook-log.png
Note: This information can also be found on Help Source directly from WooCommerce.