API

A guide on how to use the API Action to make HTTP requests to external services and third-party APIs.

The API Action is a highly flexible tool that allows your workflow to communicate with almost any third-party service on the internet that offers a REST API. You can use it to fetch data, send information, or trigger actions in other systems.

Configuration

Configuring the API action involves specifying the details of the HTTP request you want to make.

Input Parameters

Parameter
Type
Description

URL

Text

The endpoint URL of the API you want to call. You can include variables here (e.g., https://api.example.com/users/{{user_id}}).

HTTP Method

Dropdown

The HTTP method to use for the request: GET, POST, PUT, PATCH, DELETE.

Headers

Key-Value

A set of key-value pairs for any HTTP headers required by the API, such as Authorization for API keys or Content-Type.

Query Parameters

Key-Value

A set of key-value pairs to be added to the URL as a query string (e.g., for filtering or pagination).

Request Body

JSON

For POST, PUT, and PATCH requests, this is where you provide the JSON payload to be sent to the API.

Security Note

When using API keys or other secrets, always store them in a secure Connection and reference them in the Authorization header. Do not paste secrets directly into the action configuration fields.

Example: Fetching User Data

Let's say you want to get data from a public user API like https://jsonplaceholder.typicode.com/users/1.

  • URL: https://jsonplaceholder.typicode.com/users/1

  • HTTP Method: GET

  • Headers: (Leave blank for this public API)

  • Query Parameters: (Leave blank)

  • Request Body: (Leave blank for a GET request)

Output

The output of the API Action contains the response from the external service.

Output Parameters

Parameter
Type
Description

status_code

Number

The HTTP status code of the response (e.g., 200 for success, 404 for not found).

headers

JSON

A JSON object containing the response headers from the API.

body

JSON/Text

The body of the response from the API. If the response is JSON, it will be parsed automatically. Otherwise, it will be treated as plain text.

Example Output

For the example request above, the {{api_action.body}} might look like this:

{
  "id": 1,
  "name": "Leanne Graham",
  "username": "Bret",
  "email": "[email protected]",
  "address": {
    "street": "Kulas Light",
    "suite": "Apt. 556",
    "city": "Gwenborough",
    "zipcode": "92998-3874",
    "geo": {
      "lat": "-37.3159",
      "lng": "81.1496"
    }
  },
  "phone": "1-770-736-8031 x56442",
  "website": "hildegard.org",
  "company": {
    "name": "Romaguera-Crona",
    "catchPhrase": "Multi-layered client-server neural-net",
    "bs": "harness real-time e-markets"
  }
}

Last updated

Was this helpful?