What's your biggest current challenge? Have your say in Community Polls along the right column.
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.

Multiple subscription to webhook using same app

Solved

Multiple subscription to webhook using same app

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?

Accepted Solution (1)
mikedasilva
Shopify Staff (Retired)
61 7 13

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

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

View solution in original post

Replies 10 (10)

SBD_
Shopify Staff
1831 273 421

Hey @spriteNOice 

Each app can only register one webhook per topic.

Scott | Developer Advocate @ Shopify 

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?

mikedasilva
Shopify Staff (Retired)
61 7 13

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

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

spriteNOice
Tourist
6 0 1

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

SBD_
Shopify Staff
1831 273 421

Whoops nice catch! Thanks @mikedasilva 

Scott | Developer Advocate @ Shopify 

dianaclem
Tourist
3 0 1

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.

dianaclem
Tourist
3 0 1

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 ?

noah_haub
Shopify Partner
25 2 5

Have you ever fixed the issue of having a too-long address? I am facing the same issue by also using an access token

NihilVitae
Shopify Partner
4 0 2

I'm wondering--would there ever be reason to register more than one? I guess what I'm getting at is this: were multiple webhooks registered to the same topic, wouldn't their output be idempotent?

nlevos
Shopify Partner
11 0 7

What if your server is down and does not receive the webhook? Having a second server with a different address will resolve the downtime issues...

• Creator of Ecomsolo (app to save time + automate reports and data exports, add and manage multiple stores, and more)
• Guy who likes to help people