Best answer

Subscription endpoint hit twice when creating Zap


Badge

Hi,

I’ve set up an instant trigger and now I’m building a zap to test it all. I’ve noticed that when I create a zap and I need to test the trigger, it hits my subscription endpoint. If I skip the test (that part of the functionality hasn’t been built yet) and then finish creating the zap, it hits my subscription endpoint again. This would be fine but from what I can tell it never hits the unsubscribe for the first one.

Is this working correctly?

icon

Best answer by connorz 12 June 2023, 17:48

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.

6 replies

Userlevel 7
Badge +14

Hi @sb89 

Good question.

We’d need more specifics and examples to better understand the issue.

Please provide detailed screenshots to give us more context, thanks.

Userlevel 3
Badge +6

Hey @sb89 ,

Excellent question!

From your description, without seeing the trigger, it sounds like the trigger might not have a `performList` function defined:

https://platform.zapier.com/cli_tutorials/resthooks#step-4-write-the-performlist-function

When an instant (REST hook) trigger does not have a `performList` function, as you mentioned, the Zap Editor will call the `performSubscribe` function and establish a temporary subscription so a real, live sample can be received. That subscription should be garbage-collected within a few hours using the `performUnsubscribe`. I understand this is not ideal as there’s a chance that, for a few hours, two subscriptions will exist (although only one, the one created when turning the Zap on, should be able to trigger the Zap during that time).

When a `performList` exists, however, instead of subscribing, the Zap editor should make a request, usually a GET, for records to use as samples. Of course, depending on the trigger, your API might not have a matching endpoint available. 

Apologies if I’m off track and you’ve already implemented a `performList`. Feel free to reach out to our Platform Support team if we can help take a closer look: https://developer.zapier.com/contact

 

Badge

 

 

At this point it has hit my subscription endpoint:

(The bottom guid is my ID for this particular subscription)

 

I click test trigger and then skip (I don’t have the infrastructure in place yet to send data to the trigger, this is purely to test that I’m subscribing and unsubscribing correctly).

I create the zap:

 

I finish creating my zap:

 

As soon as it has been created, my subscription endpoint is hit again:

 

Badge

Hey @sb89 ,

Excellent question!

From your description, without seeing the trigger, it sounds like the trigger might not have a `performList` function defined:

https://platform.zapier.com/cli_tutorials/resthooks#step-4-write-the-performlist-function

When an instant (REST hook) trigger does not have a `performList` function, as you mentioned, the Zap Editor will call the `performSubscribe` function and establish a temporary subscription so a real, live sample can be received. That subscription should be garbage-collected within a few hours using the `performUnsubscribe`. I understand this is not ideal as there’s a chance that, for a few hours, two subscriptions will exist (although only one, the one created when turning the Zap on, should be able to trigger the Zap during that time).

When a `performList` exists, however, instead of subscribing, the Zap editor should make a request, usually a GET, for records to use as samples. Of course, depending on the trigger, your API might not have a matching endpoint available. 

Apologies if I’m off track and you’ve already implemented a `performList`. Feel free to reach out to our Platform Support team if we can help take a closer look: https://developer.zapier.com/contact

 

 

You might be onto something, let me have a look.

Badge

Hey @Zip Zorpler,

You were correct, this was my issue.

So my trigger doesn’t have a matching endpoint to retrieve this data, it’s data that is created only when triggered.

I tested with the following ‘performList’:

 

which works. Before I commit to this I just wanted to ask if there are any best practices for this scenario.

 

Thanks!

Userlevel 3
Badge +6

Hey @sb89 ,

Great find!

If there’s no endpoint to support a performList, that’s totally okay. In that case, letting the performSubscribe create a temporary subscription in the the Zap editor is probably the best path forward as that will allow users to pull in real samples. That temporary subscription should get revoked within a few hours.

Beyond that, as far as best practices go, my only other suggestion (which you may already have implemented) would be to ensure that a fallback sample has been defined for the trigger and that it includes the properties that would be received in live webhook payloads. That will allow users to skip the test and make valid mappings in later steps.