API Call

Action ID: api_call

Description

Call an API with custom headers, body, and request method. This node allows you to make HTTP requests to external APIs with full control over the request configuration.

Input Parameters

Name
Type
Required
Default
Description

url

string

-

The URL to call.

method

dropdown

-

The method to call the API. Available options: GET, POST, PUT, PATCH, DELETE

headers

object

-

-

The headers to send in the API call in JSON format.

body

object

-

-

The body to send in the API call.

timeout

integer

-

30

The timeout in seconds for the API call. Range: 1 to 599

response_type

dropdown

-

json

The response type of the API call. Available options: json, string

View JSON Schema
{
  "description": "Input for API call node.",
  "properties": {
    "url": {
      "title": "Url to call",
      "type": "string",
      "description": "The URL to call."
    },
    "method": {
      "title": "Method",
      "type": "string",
      "enum": [
        "GET",
        "POST",
        "PUT",
        "PATCH",
        "DELETE"
      ],
      "description": "The method to call the API."
    },
    "headers": {
      "default": null,
      "title": "Headers",
      "type": "object",
      "description": "The headers to send in the API call in JSON format."
    },
    "body": {
      "default": null,
      "title": "Body",
      "type": "object",
      "description": "The body to send in the API call."
    },
    "timeout": {
      "default": 30,
      "minimum": 1,
      "exclusiveMaximum": 600,
      "title": "Timeout",
      "type": "integer",
      "description": "The timeout in seconds for the API call."
    },
    "response_type": {
      "default": "json",
      "enum": [
        "json",
        "string"
      ],
      "title": "Response Type",
      "type": "string",
      "description": "The response type of the API call."
    }
  },
  "required": [
    "url",
    "method"
  ],
  "title": "ApiCallNodeInput",
  "type": "object"
}

Output Parameters

Name
Type
Description

status_code

integer

The status code of the API call

response_body

object or string

The response body of the API call

View JSON Schema
{
  "description": "Node output for API call node.",
  "properties": {
    "status_code": {
      "title": "Status Code",
      "type": "integer",
      "description": "The status code of the API call."
    },
    "response_body": {
      "title": "Response Body",
      "description": "The response body of the API call."
    }
  },
  "required": [
    "status_code",
    "response_body"
  ],
  "title": "ApiCallNodeOutput",
  "type": "object"
}

How It Works

This node constructs an HTTP request with your specified method, URL, headers, and body, then sends it to the target API endpoint. It waits for the API to respond within the timeout period and captures the response status code and body. The response is returned as either JSON (parsed) or raw string text based on your response_type setting.

Usage Examples

Example 1: Simple GET Request

Input:

url: "https://api.example.com/users/123"
method: "GET"
response_type: "json"

Output:

status_code: 200
response_body: {
  "id": 123,
  "name": "John Doe",
  "email": "[email protected]"
}

Example 2: POST Request with Body and Headers

Input:

url: "https://api.example.com/users"
method: "POST"
headers: {
  "Content-Type": "application/json",
  "Authorization": "Bearer token123"
}
body: {
  "name": "Jane Smith",
  "email": "[email protected]",
  "role": "admin"
}
response_type: "json"

Output:

status_code: 201
response_body: {
  "id": 456,
  "name": "Jane Smith",
  "email": "[email protected]",
  "created_at": "2024-01-15T10:30:00Z"
}

Example 3: DELETE Request with Authentication

Input:

url: "https://api.example.com/users/123"
method: "DELETE"
headers: {
  "Authorization": "Bearer token123"
}
timeout: 15
response_type: "json"

Output:

status_code: 204
response_body: {}

Common Use Cases

  • Third-Party Integrations: Connect to external APIs like payment processors, shipping providers, or email services

  • Data Retrieval: Fetch data from remote sources like weather APIs, databases, or content management systems

  • Creating Resources: Send data to APIs to create new records in external systems

  • Data Updates: Update information in external systems or databases through API calls

  • Webhook Notifications: Send data to webhook URLs to notify external systems about workflow events

  • API Aggregation: Combine data from multiple APIs in a single workflow

Error Handling

Error Type
Cause
Solution

Connection Timeout

API didn't respond within the timeout period

Increase timeout value or check if the API server is reachable

Invalid URL

URL format is incorrect or malformed

Verify the URL format starts with http:// or https://

Authentication Failed

Invalid or missing credentials in headers

Check your Authorization header and API key validity

Rate Limit

Too many requests sent to the API

Implement delays between calls or check API rate limit documentation

Malformed Body

JSON body has syntax errors

Validate JSON structure and ensure all required fields are present

Network Error

Cannot connect to the host or DNS resolution failed

Verify the domain is correct and the API endpoint is accessible

Notes

  • HTTP Methods: Choose the appropriate HTTP method based on the API's requirements. GET is commonly used for fetching data, POST for creating resources, PUT for updating, and DELETE for removing.

  • Headers: Include necessary headers such as Authorization, Content-Type, or custom headers required by the API.

  • Response Format: Select "json" for APIs that return JSON objects or arrays. Use "string" for plain text responses.

  • Timeout: Set an appropriate timeout based on the expected response time. The default 30 seconds works for most APIs.

  • Error Handling: Check the status_code in the response to handle errors. HTTP status codes 200-299 indicate success, while 400+ indicate errors.

  • Security: Never include sensitive credentials directly in the URL; use headers like Authorization instead.

Last updated

Was this helpful?