Creating an uninstall webhook for Sales SDK App

jayhack
Visitor
1 0 0

Hey all!

 

We have a public sales channel app and we need to delete merchant data when our client merchants remove our app from their shop.

 

My understanding is that the way to do this is to register a webhook, `app/uninstalled`, via the admin API. Two questions:

 

Is this to say that, every time a merchant installs our app, we have to register a separate webhook? i.e. we send a request to the following address:

Endpoint: https://client-merchant-id.myshopify.com/admin/api/2019-10/webhooks.json
Header: 'X-Shopify-Access-Token: ...'
Data:
{ "webhook": { "topic": "orders/create", "address": "https://whatever.hostname.com/", "format": "json" } }
Data: 
{
  "webhook": {
    "topic": "app/uninstalled",
    "address": "https://whatever.hostname.com/",
    "format": "json"
  }
}

 

If so, I'm getting the following order when making the request above:

Error code: 400
{u'errors': {u'webhook': u'Required parameter missing or invalid'}}

 

Thanks! Best -

Reply 1 (1)

hassain
Shopify Staff (Retired)
624 104 188

Hi @jayhack ,

 

I can verify that to programatically register a webhook for the topic of "app/uninstalled", for every merchant that installs your app you indeed have to make a POST request to the endpoint of https://{merchant-myshopify-domain}.myshopify.com/admin/api/2019-10/webhooks.json with the X-Shopify-Access-Token header and with the following JSON in the body of the request:

 

{
  "webhook": {
    "topic": "app/uninstalled",
    "address": "https://whatever.hostname.com",
    "format": "json"
  }
}

If you are finding that this still does not work for you and you are still seeing a 400 Error Status Response, please provide the value of the 'X-Request-ID' header from the 400 Error Status Response and I can help investigate why this programmatic webhook creation is not working for your sales channel.

 

To learn more visit the Shopify Help Center or the Community Blog.