Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Need help on REST API call for webhook

Need help on REST API call for webhook

bprakash
Visitor
1 0 0

I need help to understand REST API Call to get all webhooks and create a new webhook.

I am able to setup webhook through UI, but I need a mechanism to setup webhook through a REST API call.

I am following the below page for the REST API: https://help.shopify.com/en/api/reference/events/webhook

I am able to pull all orders by REST API. For that, I have already created a PRIVATE API.

PRIVATE APP which gives me username and password in Base64 format.

Sample: https://{username}:{password}@dev-meritage.myshopify.com/admin/api/2019-04/orders.json
I am getting the proper results from the above REST API CALL.

 

But when I call the below URL, I don't get any webhook information: https://{username}:{password}@dev-meritage.myshopify.com/admin/api/2019-04/webhooks.json

I want to know the significance of "shared secret" present under the PRIVATE APP.

 

Reply 1 (1)

Zameer
Shopify Staff
297 31 90

Hey there,

 

If you're creating the webhooks via the shop admin, they won't appear in your API GET request.

 

This is because webhook subscriptions are scoped only to the app that they're registered to. So those made in the admin, are only visible in the admin. If you want to create some via the API, you can do so with the following request, which is also shown in the documentation you linked:

POST /admin/api/2019-04/webhooks.json
{ "webhook": { "topic": "orders/create", "address": "https://whatever.hostname.com/", "format": "json" } }

 

The webhooks created this way using your API key and secret will then be returned when you query the `/admin/webhooks.json` endpoint. 

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