Skip to content

Webhook System

The OC Magento Bridge plugin sends signed HTTP POST requests to Magento whenever WordPress content changes. Magento uses these webhooks to purge only the affected cache entries, keeping cached content fresh without full cache flushes.

WordPress HookEvent SentObject Type
save_postpost_created or post_updatedpost or page
delete_postpost_deletedpost or page
wp_update_nav_menumenu_updatednav_menu
edited_termterm_updatedcategory or post_tag
delete_termterm_deletedcategory or post_tag

Post revisions and autosaves do not trigger webhooks.

{
"event": "post_updated",
"object_type": "post",
"object_id": 42,
"slug": "my-post-slug",
"timestamp": 1700000000
}

Each webhook is signed using the API key as the HMAC secret. The signature is sent in the X-OC-Bridge-Signature header:

X-OC-Bridge-Signature: abc123def456...

On the Magento side, Controller/Webhook/CachePurge.php verifies the signature by computing the HMAC-SHA256 of the raw request body using the stored API key and comparing with hash_equals().

The Magento webhook controller listens at:

POST /wordpress/webhook/cachepurge

Enter this URL in the WordPress plugin settings as the Magento Webhook URL.

Webhooks are sent using wp_remote_post() with blocking: false. This means the webhook is dispatched asynchronously - WordPress does not wait for Magento’s response before continuing. The webhook timeout is 10 seconds.

After verifying the webhook signature, Magento maps the object_type to cache tags and purges them:

object_typeCache Tags Purged
postWORDPRESS_POST, WORDPRESS_POST_{object_id}
pageWORDPRESS_POST, WORDPRESS_POST_{object_id}
categoryWORDPRESS_CATEGORY
post_tagWORDPRESS_TAG
nav_menuWORDPRESS_MENU