Best answer

Check zap draft or final (live)?

  • 14 August 2023
  • 4 replies
  • 63 views

Hello. I created integration for my app. It works very well. Zapier does create separate webhooks for the draft version of a Zap and the final (live) version. In bundle data zap_id is different for both of draft and live versions. 

When zapier sends me request to given url how can I detect that is it live or draft? Because I only need to store webhook of live version. In bundle data I can’t find something to solve this.

 

Thanks in advance! 

icon

Best answer by connorz 15 August 2023, 15:18

View original

This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

4 replies

Userlevel 3
Badge +6

Hi @ismayil ,

Excellent question!

There are a few options that come to mind. 

First, if you’ve not already done so, it might help to add a Perform List function to the trigger. When a Perform List function exists, in the draft/Zap editor, Zapier should fetch existing records to use as samples instead of claiming a temporary subscription:

https://platform.zapier.com/build/resthooks#performlist

Second, bundle.meta includes an isLoadingSample property, which can be used to check if the request originated from a test in the Zap editor:

https://github.com/zapier/zapier-platform/blob/main/packages/cli/README.md#bundlemeta

Thank you for the answer @connorz. But unfortunately none of them doesn’t help.  isLoadingSample  is always true. In bundle data there is  live  key in json, it is also always true. Why does Zapier give different webhook url for draft and live versions? 

Userlevel 3
Badge +6

Hi @ismayil ,

Regarding the creation of multiple webhook URLs, there are a few things worth noting:

  • A REST hook subscription should only be created in the Zap editor when the trigger does NOT have a Perform List function.
  • If a Perform List function has been created, instead of invoking the Perform Subscribe to create new subscription, the Zap editor should invoke the Perform List function to fetch samples.
  • Defining a static sample is also recommended so the Zap editor can offer the user a generic sample when none are returned by the Perform List.
  • If no Perform List function exists, the Zap editor will invoke the Perform Subscribe, creating a new subscription with its own webhook URL.
  • The subscription created in the Zap editor is temporary and should be deleted automatically via the Unsubscribe function, usually within a few hours.

Overall, the webhook subscriptions created by the Zap editor and by turning the Zap on are different because the one created in the editor is temporary. Whether the user activates the Zap or not, the subscription created in the editor will be garbage collected within a few hours whereas, if the user has turned the Zap on, the webhook created during the activation process will persist as long as the Zap stays on.

 

@connorz I got it. I did and it works as I expected 🎉 Thank you for your help