# How to catch errors within API Workflows?

**URL:** <https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078>\
**Category:** APIs\
**Created:** [November 6, 2019, 8:49am UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078 "2019-11-06T08:49:46Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolas\_dap](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/nicolas_dap/32/26345_2.png) [@nicolas\_dap](https://forum.bubble.io/u/nicolas_dap)\
**Post date:** [November 6, 2019, 8:49am UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/1 "2019-11-06T08:49:46Z")

</div>

hello

I do an API call to Stripe to check if a customer id exists (using [Retrieve a Customer](https://stripe.com/docs/api/customers/retrieve)).  
If there is an error “No customer found”, I must perform some actions to fix it. But with an error, the workflow stops.

How could we catch errors in the API Workflows ? how can I trigger another worflow only if an error occurs ?  
If we can’t, @emmanuel do you plan to let us deal with Errors ? Once configured for an API, all the Errors responses are formatted the same way, whatever the call we make.

---

<div class="post-metadata">

**Author:** ![lottemint.md](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/lottemint.md/32/26549_2.png) [@lottemint.md](https://forum.bubble.io/u/lottemint.md)\
**Post date:** [November 6, 2019, 10:17am UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/2 "2019-11-06T10:17:02Z")

</div>

It would be great if there will be a possibility to check a checkbox that will not throw errors. In this case, we’ll be able to get the errors from the previous steps.

That means an action’s script should be wrapped into the following:  
try { code }  
catch (e) { return { error: e.message } }

---

<div class="post-metadata">

**Author:** ![nicolas\_dap](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/nicolas_dap/32/26345_2.png) [@nicolas\_dap](https://forum.bubble.io/u/nicolas_dap)\
**Post date:** [November 6, 2019, 12:39pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/3 "2019-11-06T12:39:15Z")

</div>

That’s a good idea @emmanuel  
For instance, if the “id”'s value is empty, obviously, there is an error.

---

<div class="post-metadata">

**Author:** ![JohnMark](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/johnmark/32/42431_2.png) [@JohnMark](https://forum.bubble.io/u/JohnMark)\
**Post date:** [November 6, 2019, 1:26pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/4 "2019-11-06T13:26:25Z")

</div>

Hi @nicolas_dap

> [@nicolas\_dap](#):
>
> how can I trigger another worflow only if an error occurs ?

At the moment our option is to install a ‘timeout’ (scheduled wf) in order to validate if the operation was successful. In other words, if the validation operation takes 10 seconds, a scheduler at 30 seconds is executed to check if the operation has written the data correctly.

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 6, 2019, 1:37pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/5 "2019-11-06T13:37:22Z")

</div>

I haven’t delved too deeply into error handling as yet, so I’m curious about this as well, for future reference. Does the **An unhandled error occurs** event not fire for API calls?

---

<div class="post-metadata">

**Author:** ![Jici](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/jici/32/30722_2.png) [@Jici](https://forum.bubble.io/u/Jici)\
**Post date:** [November 6, 2019, 2:23pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/6 "2019-11-06T14:23:38Z")

</div>

I have created a ticket last week for this reason. They tell me that actually there’s no way to handle error. You cannot also set another step to see if an empty (example ID) on further step of the workflow because the workflow stop on the error. No timeline on a fix for that.

The only workaround I found is like @JohnMark Say.

---

<div class="post-metadata">

**Author:** ![nicolas\_dap](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/nicolas_dap/32/26345_2.png) [@nicolas\_dap](https://forum.bubble.io/u/nicolas_dap)\
**Post date:** [November 6, 2019, 2:29pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/7 "2019-11-06T14:29:03Z")

</div>

@JohnMark @Jici Thanks for the feedback.  
That’s a pretty big, and not that reliable, workaround.  
Anyway, hopefully that will come someday.

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 6, 2019, 4:16pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/8 "2019-11-06T16:16:53Z")

</div>

Can someone help me understand this issue a bit better? Is this referring specifically to **SCHEDULED** API workflows?

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 7, 2019, 3:32am UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/9 "2019-11-07T03:32:55Z")

</div>

Ok, I think I understand the issue now. [This thread](http://forum.bubble.io/t/error-handling-in-api-workflows/13218) from 2.5 years ago seems to be about the same thing.

While far from ideal, until the issue is officially addressed by Bubble, another approach might be to implement a “proxy relay” endpoint - i.e. a “middleman” endpoint which sits between Bubble and the “true” endpoint (Stripe in this case). For certain “critical” API workflows, it might be worth the effort.

I fiddled around and was able to implement a **no-code solution** to fetch a customer from Stripe with error handling using Integromat for the proxy endpoint…

 ![15%20PM](https://us1.discourse-cdn.com/bubble/original/3X/7/4/7405c4c3d6a5e205f11ca83994ea258be38bf111.png)

 ![28%20PM](https://us1.discourse-cdn.com/bubble/original/3X/2/c/2ca7ba9a30292c2c03a7952d1c697b90c1cea257.png)

 ![25%20PM](https://us1.discourse-cdn.com/bubble/original/3X/e/6/e6d655ab53c9587fdca6026d6ae929e45209427e.png)

It all works as intended. When the Bubble endpoint is hit, a new entry appears in the DB if a Stripe customer is found; and I get an email if Stripe returns a “No customer found” error.

Anyway, I can share more detail if interested, but I thought I’d pass it along.

---

<div class="post-metadata">

**Author:** ![gevestobs](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/gevestobs/32/19091_2.png) [@gevestobs](https://forum.bubble.io/u/gevestobs)\
**Post date:** [November 7, 2019, 3:47am UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/10 "2019-11-07T03:47:21Z")

</div>

This is the approach I currently use!

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 7, 2019, 3:31pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/11 "2019-11-07T15:31:05Z")

</div>

> [@sudsy](#):
>
> It all works as intended. When the Bubble endpoint is hit, a new entry appears in the DB if a Stripe customer is found; and I get an email if Stripe returns a “No customer found” error.

A quick follow-up… It’d probably be best to create a separate custom event for the “ **Send email** ” instead of just an action. That way, the error handling logic resides in its own workflow (for better app organization and SOC).

---

<div class="post-metadata">

**Author:** ![nicolas\_dap](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/nicolas_dap/32/26345_2.png) [@nicolas\_dap](https://forum.bubble.io/u/nicolas_dap)\
**Post date:** [November 8, 2019, 2:02pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/12 "2019-11-08T14:02:39Z")

</div>

Don’t even know if Bubble read this. If they do, how could we know ? If they don’t, does it worth going on reporting our user cases ?

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 8, 2019, 2:12pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/13 "2019-11-08T14:12:27Z")

</div>

I know it’s been brought up (many times) before, but it would sure be nice to see an official “roadmap”, or at least a list of requested features, and better yet, to be able to influence priority by upvoting. Unfortunately, Bubble doesn’t seem transparent in that regard. ☹

_(The forums are great for discussion, but I don’t even know how to formally submit a feature request - only bug reports.)_

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [November 9, 2019, 1:53pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/14 "2019-11-09T13:53:00Z")

</div>

I’m not sure there is a formal way to request a feature besides the forum post topic of “idea”…they when implemented label it as so.

There is also a running list on the forum of feature requests

> [@Bubble Editor Ideas and Suggestions](http://forum.bubble.io/t/bubble-editor-ideas-and-suggestions/68650/47):
>
> Great point, @robert! slight_smile +1 I adjusted the list so that #32 is now moving the “Create a new field…” and “Define another app text…” options to the top of their dropdowns. @boston85719 Totally agree! Would also be very helpful for group focus mobile menus that sometimes get cut off when the user’s phone height is too short. I’ve added your suggested as #33! slight_smile

Although it is not “official” as Bubble didn’t start it.

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 9, 2019, 2:49pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/15 "2019-11-09T14:49:16Z")

</div>

Yeah, I inquired about this, specifically, just yesterday. Here’s a synopsis of the exchange with Bubble Support…

> [@Me](#):
>
> How does one submit a feature request? Also, having done so, how would one keep abreast of its status - i.e. whether it’s being seriously considered and/or where it might fall in the priority queue?

> [@Bubble Support](#):
>
> At this time, emailing us is the best way to get a feature request in! We escalate feature requests in the same flow as bugs, and generally keep users posted on their progress in the same way.

> [@Me](#):
>
> Ok, thanks. Unfortunately, that makes it impossible for other users to see, comment on, and upvote existing requests.

> [@Bubble Support](#):
>
> This is something that we are continuing to consider as a team; we’ve seen a few of our users asking for this option on our forums, so a list of submitted feature requests is certainly something we are evaluating.

So, maybe if we inundate support, directly, with requests for a proper “feature/issue tracker”, they might take some action. 😉

---

<div class="post-metadata">

**Author:** ![boston85719](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/boston85719/32/77286_2.png) [@boston85719](https://forum.bubble.io/u/boston85719)\
**Post date:** [November 9, 2019, 3:47pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/16 "2019-11-09T15:47:57Z")

</div>

I know in the past they offered the option for users to fund the feature and pay for it to get done…not sure if they still do that or not

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [November 27, 2020, 8:58am UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/17 "2020-11-27T08:58:17Z")

</div>

> [@sudsy](#):
>
> It all works as intended. When the Bubble endpoint is hit, a new entry appears in the DB if a Stripe customer is found; and I get an email if Stripe returns a “No customer found” error.
> 
> Anyway, I can share more detail if interested, but I thought I’d pass it along.

A bit of thread archaeology here 🙂

Genius on getting Integromat to do the job.

What I think this lets me do is be able to get the HTML response back as something that the workflow can handle?

If I then pass that back to the caller of by Bubble API - I am thinking it will always result in a “real” 200 but the response (404, 422, 200 etc) would be in a returned parameter?

I don’t think I can specify the return code via the workflow?

---

<div class="post-metadata">

**Author:** ![sudsy](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/sudsy/32/114637_2.png) [@sudsy](https://forum.bubble.io/u/sudsy)\
**Post date:** [November 27, 2020, 2:54pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/18 "2020-11-27T14:54:59Z")

</div>

> [@NigelG](#):
>
> If I then pass that back to the caller of by Bubble API - I am thinking it will always result in a “real” 200 but the response (404, 422, 200 etc) would be in a returned parameter?

I had to refresh my memory, but it appears you can specify the return code in Integromat. I opted to return a 200 to Bubble and simply send back a custom string called “error” as the Stripe customer id; but it appears the original error code could indeed be sent back to Bubble as a param. Here’s how I set up the webhook response in Integromat for my quick test…

 ![integromat-bubble-error](https://us1.discourse-cdn.com/bubble/original/3X/b/4/b48b4652ba478ea63ac3f1ace1ab8c1031e09ba3.png)

## EDIT

I haven’t tried, but It appears one could also relay the original HTTP response code back to Bubble as the “Status”.

---

<div class="post-metadata">

**Author:** ![NigelG](https://avatars.discourse-cdn.com/v4/letter/n/ea5d25/32.png) [@NigelG](https://forum.bubble.io/u/NigelG)\
**Post date:** [November 28, 2020, 2:12pm UTC](https://forum.bubble.io/t/how-to-catch-errors-within-api-workflows/71078/19 "2020-11-28T14:12:58Z")

</div>

> [@sudsy](#):
>
> I haven’t tried, but It appears one could also relay the original HTTP response code back to Bubble as the “Status”.

Thanks 🙂

Yes, that works and you can send it back as a parameter too to do “stuff” in the workflow if you need.

Bubble moans if you have multiple “Return API” steps, so you can’t get too fancy.

A 200 and something in the JSON about the error is what I ended up with.

Integromat handles if all very well.
