DEV Community

Max Katz for Okta Workflows

Posted on • Originally published at maxkatz.net on

How to Call an API When It’s Not Available From an Existing Card (Connection)?

Okta Workflows how-to guides are questions and answers from weekly community office hours, MacAdmins Workflows Slack channel, and other places.

Read all the other how-to guides ⤵️

On to the question.

How to call an API when it’s not available from an existing card (connection)?

You will learn about three ways to call in API:

  • Using an available Workflows app connection
  • Using a Workflows app connection with a custom API endpoint
  • Calling custom API endpoint (when no card is available)

Using an available Workflows app connection

Workflows has over 50 out-of-the-box connections to various external services:

Workflows app connections

Workflows app connections

and each connection supports a number of actions. This is a partial list of actions supported by the Google Calendar card:

Google Calendar app actions

Google Calendar app actions

Behind the scenes each action is an API call to Google Calendar. What’s nice of course, the Google Calendar card does the API call setup automatically. It knows the API endpoint, the headers, the (query) parameters and anything else needed. Here is an example searching for events using Google Calendar – Search card:

Searching a calendar with Google Calendar – Search Events card

Searching a calendar with Google Calendar – Search Events card

Leveraging a Workflows app connection with a custom API endpoint

Looking at another app connection, Shopify, it has the following actions:

Shopify connection actions

Shopify connection actions

When you need to create a new customer, you use the Shopify – Create Customer card:

Creating a new customer with Shopify app connection

Creating a new customer with Shopify app connection

Now you want to list the customers you have. When you look at the app actions, no such action is available. You can use the Custom API Connection card to call a Shopify API endpoint and leverage an existing connection to Shopify.

Shopify – Custom API Action card

Shopify – Custom API Action card

Using the Shopify – Custom API Action card, you enter the Relative URL. You you don’t need to enter the host or the authentication information as it leverages the existing connection to Shopify. You can enter Query or additional Headers if a particular endpoint requires that.

Testing the Customer API Action card with /admin/api/2022-01/customers.json endpoint results in listing four customers:

Retrieving a list of customers using Shopify – Custom API Action card

Retrieving a list of customers using Shopify – Custom API Action card

You can confirm this by calling the /admin/api/2022-07/customers/count.json endpoint to return the count of customers:

Retrieving a count of customers using Shopify – Custom API Action card

Retrieving a count of customers using Shopify – Custom API Action card

Calling a custom API endpoint

You want to use ShipEngine API to validate physical addresses. Workflows doesn’t have a connector for ShipEngine. For such cases you can use the API Connector card which allows to call any external API.

When using the API Connector card, you need to enter all the information to call a particular API endpoint. Usually you would go to API’s documentation to learn how to setup a call.

Using API Connector – Post card for ShipEngine’s Validate an Address endpoint you need to provide:

  • URL
  • Headers (for API key)
  • Body (a list of addresses to validate)

Calling ShipEngine API with API Connector card

Calling ShipEngine API with API Connector card

When the API call is successful, the result says an address was verified and also returns a matched address:

Address validation with ShipEngine API

Address validation with ShipEngine API

One tip I want to share. If you use ShipEngine’s API often and in different flows, you can setup a connection which holds the authentication information for a particular API. With ShipEngine API, put the API-Key header there:

Creating a new connection

Creating a new connection

You no longer need to provide the API key in Headers :

API Connector with pre-set connection

iAPI Connector with pre-set connection

This guide showed how to use a Custom API Action card and API Connection card to call APIs when they (APIs) are not available as part of the out-of-the-box connector.


📺 Short how-to Workflows videos to help you become a better automation builder.

🔮 A collection of helpful Workflows tips.

Top comments (0)