WC_API – The WooCommerce API Callback

You are here:

The WooCommerce API allows plugins make a callback to a special URL that will then load the specified class (if it exists) and run an action. This is also useful for gateways that are not initialized.

You can view the WC_API class in our docs.

Callback URL

To trigger the WooCommerce API, you need to use a special URL. Before WooCommerce 2.0, you could use:


In WooCommerce 2.0+,  you can still use that or use our endpoint:


When this URL is called, WooCommerce:

  1. Initializes the CALLBACK class, if it exists
  2. Triggers an action based on the callback: woocommerce_api_callback. Note: CALLBACK will be sanitized and lower case.
  3. Exit WordPress.

Hooking into the callback

Add an action to hook into the callback hook. For example:

add_action( 'woocommerce_api_callback', 'callback_handler' );

WooCommerce will exit after that action, but you can still redirect the user elsewhere from your handler if you wish.

Was this article helpful?
Dislike 0
Views: 31