Hello Everyone!
I have developed a custom app for a Shopify store that, during installation, creates specific pages within the store. Upon uninstallation, I need to remove (clean up) these pages.
I am aware of the app/uninstalled webhook, which is triggered after the app is uninstalled. However, by the time this webhook executes, the access token is already invalid, preventing me from deleting the pages.
Is there any webhook, callback, or recommended approach that allows these pages to be deleted before the access token becomes invalid? If so, how should it be implemented? Or is this operation not supported within Shopify’s current framework?
Any suggestions or workarounds would be appreciated.
I think the developer forums will give you better answers: https://community.shopify.dev/ 
alternative for queuing cleanups in advance of token invalidation store a background job that runs on uninstall, not on token loss or annotate any app created resource with a meta field so store owners can remove it from admin or add the cleanup instruction ui in your app before uninstall. Goodluck. Hope this helps.
HI @Anantharaj_S ,
You can solve this issue by utilizing a “delayed” cleanup strategy. Here’s a potential solution:
Step 1: When your app is installed, create a custom flag or record in your database that indicates which pages need to be deleted upon uninstallation.
Step 2: When the app is uninstalled, you can use the app/uninstalled webhook to trigger a background job that attempts to delete the pages immediately.
Step 3: To overcome the access token issue, try using a long-lived access token or refresh the token before performing the cleanup process. Alternatively, you can create an “in-app” system that performs the page deletions via a separate admin request after the uninstall event.
Unfortunately, Shopify doesn’t support deleting resources post-uninstallation if the access token is already invalid, so it’s a workaround based on session management.
Let me know if you need further assistance!
Best,
Felix