I’m building a PHP-based Shopify application and need to clean up database entries when merchants remove my app from their stores. I discovered this webhook configuration code but I’m unsure about the implementation details and how to properly set it up to execute during app removal.
$uninstall_webhook = [
'webhook' => [
'topic' => 'app/uninstalled',
'address' => 'https://mysite.com/app/cleanup_merchant_data.php?store=' . $store_domain,
'format' => 'json',
],
];
$response = $api_client('POST /admin/webhooks.json', $uninstall_webhook);
Can someone explain where this webhook registration should be placed in my app structure and how the cleanup process gets triggered automatically?