Need help on REST API call for webhook

New Member
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.

 

0 Likes
Highlighted
Shopify Staff
Shopify Staff
296 32 59

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. 

0 Likes