API

Call external API's in your workflow

The "API" Utility Step allows your AirOps Workflows to communicate with external services via their APIs. This allows you to integrate and interact with data and functionalities that are outside of your Workflow.

Configuration

There are two types of request method that we support, read the API docs for your integration to find out the best method to use :

  • GET Requests:

    • This type of request is generally used to retrieve data from a service

  • POST Requests:

    • A POST request is used to push data to a service

    • This is typically used when you want to create or update data on the server

    • For instance, you may want to create a new record in a database or update a user's profile information

Reference Inputs or Outputs in the API Step

To dynamically set variables in your API and reference an input (defined in the "Start" step) or output variable (generated by any step), you will need to use Liquid syntax. Additionally, you will need to specify your Headers and Body values.

Headers

For passing in your header value, it is important that you format the information as JSON. We will always set our Content-Type as shown below, and you can include the API Key for any calls that require authorization:

{ 
    "authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}

Body

The body allows us to specify any additional parameters (i.e. variables or outputs) to be included in the API call. We use the same syntax as the header, where both our keys and values are wrapped in quotes. If we're passing in any inputs or step outputs, we use Liquid syntax while still wrapping with double-quotes, e.g.

{
  "properties": {
    "amount": "",
    "dealname": "{{ step_2.output.deal_name }}",
    "pipeline": "",
    "closedate": "{{ step_2.output.deal_close_date }}",
    "dealstage": "",
    "hubspot_owner_id": ""
  }
}

Examples

Let's put this all together with a couple of examples. If you have a user input defined as location at the start of your Workflow, you can include {{ location }} in the URL or body of your API step to make a request to a weather API:

GET https://api.weatherapi.com/v1/current.json?key=YOUR_API_KEY&query={{ location }}

Similarly, you can use outputs from other steps as variables. If you have a step that retrieves a user's ID, you can use the output of that step as a variable in the API step:

POST https://api.example.com/user/{{ step_1.output }}/profile

This enables you to create dynamic API requests that adjust based on the inputs and outputs in your workflow. As an example, you can reference the API Step shown in our "Sales Call Lead Qualifier" template shown below:

How to continue if the API step fails

By default, the API step will terminate the workflow if it fails. However, to continue the workflow if the step fails, simply click Continue at the bottom of the step.

The step will return the following keys:

  • output : this will be null

  • error :

    • message: the message returned from the step

    • code : the error code representing the error

How to retry if the API step fails

You can retry the API step up to 3 times by clicking on Advanced Settings

However, if the step still failed after 3 retries, you may:

  1. Select Continue instead of Terminate Workflow if the step fails

  2. Add a conditional where the condition checks if the error from the step exists e.g. step_1.error

  3. Add the step that you want to retry if there was an error

Need more control?

For advanced API requests, use our Python step with custom code, using the Code Step, which can make external requests.

Last updated