mr4nd
mr4nd

Reputation: 141

How to delete Shopify Webhooks made thru Shopify API?

I'm having trouble deleting Webhooks that I created thru the Shopify API. To create the webhook, I used this code in RoR:

webhook = ShopifyAPI::Webhook.create(format: "json", topic: "orders/create", address: "some address")

I'm able to send a GET request and retrieve all the webhooks that were created. But when I send the DELETE request with the respective ID, the response is "404 Not Found - errors: Not found". I'm sending the DELETE request using Firefox's RESTClient, and the format is like this:

DELETE https://api_key:shared-secret@hostname/admin/webhooks/1855159.json

Maybe it's not working because the webhooks were created via the API. Is there another way to delete the webhooks? Thanks in advance!

Upvotes: 6

Views: 4442

Answers (4)

georgekpc
georgekpc

Reputation: 248

You should retrieve your webhooks first and then delete them.

@webhooks = ShopifyAPI::Webhook.find(:all, :params => {:limit => 10})
@webhooks.each {|webhook| webhook.destroy }

Upvotes: 0

Rash
Rash

Reputation: 896

DELETE/admin/webhooks/4759306.json

Delete a webhook

Remove an existing webhook from a shop

DELETE /admin/webhooks/#{id}.json

Upvotes: 4

Samuel
Samuel

Reputation: 38346

That is how you delete a webhook created by your application. Webhook 1855159 was created by the shop and not created by an application and can only be deleted by the shop's admin.

Upvotes: 2

Sumit Garg
Sumit Garg

Reputation: 726

I think when you remove the app from admin panel, the webhooks created by that app are automatically removed

Upvotes: 2

Related Questions