Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.
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 12

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 9 (9)

SBD_
Shopify Staff
1779 263 383

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 12

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
1779 263 383

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?