# How to return API status codes on flows with errors

**URL:** <https://community.synatic.com/t/how-to-return-api-status-codes-on-flows-with-errors/180>\
**Category:** API Builder/Gateway\
**Tags:** calculator, helper-functions, api\
**Created:** [February 2, 2022, 9:52am UTC](https://community.synatic.com/t/how-to-return-api-status-codes-on-flows-with-errors/180 "2022-02-02T09:52:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![navessa](https://yyz2.discourse-cdn.com/flex032/user_avatar/community.synatic.com/navessa/32/58_2.png) [@navessa](https://community.synatic.com/u/navessa)\
**Post date:** [February 2, 2022, 9:52am UTC](https://community.synatic.com/t/how-to-return-api-status-codes-on-flows-with-errors/180/1 "2022-02-02T09:52:05Z")

</div>

Illustrated in the image below is an example of a flow with the Record Generator as the source step and a Buffer as the destination step.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/1ef97d602e2d5680c653112bacbe14a66565e0ec.png)

First enable the “break on error” option in the **details** of a flow as shown in the below image. This means that if an error occurs, it will fail the flow, rather than list it as “completed with errors”.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/04bd4636088aba86d7357d75f78ae08f232c5c94.png)

On any step in a flow, there is an option to “ **Pass Errors** ” as shown in the image below. This means it will not stop at that step, but rather continue the flow – however storing the error in a an object called “passedError” on the input. This option can sometimes be found when clicking on **Advanced Mode** and scrolling to the bottom of the step. See images below:

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/704541305671c5c5c94b15f511936696902b244f.png)

In this example, the error occurred on the calculator step as per the image below. It can be on a destination step if errors are expected to occur there.

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/2614ed2ac2d5da6a859e6ecc9aef12c8442ebbf2.png)

Illustrated in the below image, the “passedError” is referenced in a calculator step to force an API error if there is a value in the passedError object.

![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/9c707c147ce3a9d83b728d23384bf203a2677eb1.png)

Copy and paste the below code in the calculator step:

let inputRecord={};  
if (!!input.passedError)  
{throw new APIError(400,“Test”)}  
return inputRecord;

When calling the API end point from **Postman** (through the **API Builder** ), the status code is received back as 400 with the set message indicating a failure as highlighted in the below image.

 ![image](https://canada1.discourse-cdn.com/flex032/uploads/synatic/original/1X/dd744ac0f942f25f968d090b7edd9cb0802d2d80.png)
