Okta Workflows How-To: Handling an External API Call Error

Okta Workflows is a no-code platform for automating identity processes. The Workflows team holds weekly office hours where they answer builder questions.

This blog post is based on a question asked during office hours: How to handle an external API call error in Workflows?

Getting started

When calling an external API results in an error, you want to gracefully handle the error and continue the flow execution. One way to handle an error is to use Error Handling – If Error card. It’s similar to try/catch logic.

The card has two sections: Try and If Error.

In the Try section you place the API Connector card followed by any other logic. In this example there is a single Assign card to create a success message. You can add other cards as well. The message is then mapped to the If Error card’s output.

Workflows If Error

In the If/Else section there is a default error message followed by any other logic. In this example, it’s again a single Assign card which holds the error message. The message is then mapped to the If Error card’s output.

If Error card – error section

Tip: Learn how to create outputs for an If/Else card.

 After the If Error card, you can add additional logic. Here is an example of sending a success or an error message to a Compose card.

Sending success or error message to Compose card

Now you can test the flow. The flow uses a service called mock.codes. mock.codes provides an easy way to reference and test HTTP responses.

Running the flow with HTTP response 200 (https://mock.codes/200) results in success:

Success outcome

Running the flow with HTTP response 500 (https://mock.codes/500) that results in Internal Server Error:

Error outcome

The flow chart can help visualize the flow logic at a high-level:

If-error flow chart

Get your Workflows questions answered

Have a question about Okta Workflows? Not sure how to build a flow? Join the weekly community office hours to get help.