Topics covering webhook creation & management, event handling, Pub/Sub, and Eventbridge, in Shopify apps.
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?
Solved! Go to the solution
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.
Hey @spriteNOice
Each app can only register one webhook per topic.
Scott | Developer Advocate @ Shopify
@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?
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.
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.
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 ?
Have you ever fixed the issue of having a too-long address? I am facing the same issue by also using an access token
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?
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...