Multiple subscription to webhook using same app

Solved
spriteNOice
Tourist
6 0 1

Is it possible to create multiple subscriptions to webhooks (e.g. 2 orders/create webhooks) using the same app? Or will it create conflict and not fire in one of the destinations?

0 Likes
SBD_
Shopify Staff
Shopify Staff
1071 143 189

Hey @spriteNOice 

Each app can only register one webhook per topic.

spriteNOice
Tourist
6 0 1

@SBD_ I was able to have 2 orders/create webhooks when trying to register a new one. Also confirmed both destinations are receiving the payload, why is it allowed to register a new webhook for the same topic if it exists already?

0 Likes
mikedasilva
Shopify Staff
Shopify Staff
32 2 2

This is an accepted solution.

hi @spriteNOice ,

I think @SBD_ just left out a detail on the uniqueness constraints. You can only have 1 subscription per topic + address + format combination. Therefore, you can actually have multiple for the same topic as long as the destination address is different. I think this is what you are looking to do and tested.

Cheers

mikedasilva | Developer @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

spriteNOice
Tourist
6 0 1

@mikedasilva Yes that’s it! Thank you guys for helping me out!

0 Likes
SBD_
Shopify Staff
Shopify Staff
1071 143 189

Whoops nice catch! Thanks @mikedasilva 

dianaclem
New Member
3 0 0

So, is it possibile to subscribe to the same topic, same app, with address that differs only for one parameter? 

For example

subscription1:

 

 

POST https://shop1.myshopify.com/admin/api/2021-01/webhooks.json
{
  "webhook": {
    "topic": "customer/create",
    "address": "https://ws.example.com/customerendpoint?access_token=AAAAAA",
    "format": "json"
  }
}

 

 

subscription2:

 

 

 

POST https://shop2.myshopify.com/admin/api/2021-01/webhooks.json
{
  "webhook": {
    "topic": "customer/create",
    "address": "https://ws.example.com/customerendpoint?access_token=BBBBBBB",
    "format": "json"
  }
}

 

 

 

We have a multi-tenant environment and the endpoint will be the same for all, so the request will be forwarded to the single tenant based on access_token value.

0 Likes
dianaclem
New Member
3 0 0

I made a test but it fails ahead because the access_token in the address param cause this error:

{
    "errors": {
        "address": [
            "is too long (maximum is 255 characters)"
        ]
    }
}

Is there a way to subscribe to an endpoint specifying an header value ("Authorization" header) to be passed back to the address when Shopify notify an event ?

0 Likes