1

I am creating a Shopify app using PHP. For starting I am following this skeleton and after some debugging I am able to setup it and install.

I need to register some web-hooks through my app installation but I can't find any reference for the same.

I need to register the webhooks like when some new customer register, order place etc. How can I register those webhooks through the app?

I know we can register the web-hooks form Shopify admin manually, but I need to register them through app.

1 Answer 1

2

Just make a POST request to the "/admin/webhooks.json" endpoint with following data:

{
  "webhook": {
    "topic": "orders\/create",
    "address": "http://www.example.com/create-order-webhook",
    "format": "json"
  }
}

this will register the webhook and fire the webhook to http://www.example.com/create-order-webhook address with order details whenever a new order is created.

you can get the number of registered webhooks:

GET /admin/webhooks/count.json
Hide Response
HTTP/1.1 200 OK
{
  "count": 2
}

Also note that you need to quickly respond with status of 200, so whatever task you need to do, do in background and also you may need to verify that webhook was fired from shopify only.

Sign up to request clarification or add additional context in comments.

7 Comments

thanks for your reply. Can you please tell me what should be the full end point for post request "/admin/webhooks.json"
https://{user-store-name.myshopify.com}/admin/webhooks/count.json you will need to pass the access token in heaaders for the shop: 'X-Shopify-Access-Token' = {shop_access_token} 'X-Shopify-Shop-Domain' = {shop-name}
thanks for the reply. But can you please tell me what parameters we need to send with this request for authorization .i have a customer hmac and i need to use that for the auth process. It will be great if you can provide me a complete request format.
@ Raj Kumar thanks it works i have also refereed to this link help.shopify.com/api/reference/webhook#index for more info
I am glad that I was helpful.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.