How to return API status codes on flows with errors

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.

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”.

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:


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.


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.


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.