# REST API Node

The Rest API node in Nected Workflow allows you to make HTTP requests to external APIs, enabling you to integrate data and functionality from various web services into your workflow. This node supports GET, POST, PUT, PATCH, and DELETE methods, allowing you to perform a wide range of operations on external APIs.&#x20;

By configuring the Rest API node, you can specify the API endpoint URL, request method, headers, and parameters. You can also set the request body for POST, PUT, and PATCH methods. The node supports both JSON and XML request and response formats.&#x20;

Once the API request is made, the response data is stored in the node's output, which can be accessed by subsequent nodes in the workflow. This allows you to process and manipulate the data retrieved from the external API as needed.

![wa\_restAPI.png](https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FlAa73dV1XNLcm6HiYzcy%2Fwa_restAPI.png?alt=media\&token=eccf702a-06b9-439f-a3ec-e3804b6891c4)

## **How to Add a REST API Node to a Workflow?**

1. In the **Workflow Editor**, click **+ Add Node**.
2. From the node type dropdown, select **REST API**. \
   ![](https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FkOL0Wkyj79pGXQnBKeKm%2Fimage.png?alt=media\&token=67b833ef-3fbb-4d83-889c-3efbe2922cd8)
3. In the REST API configuration popup:
   * Choose an existing API connector from the dropdown list, \
     ![](https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2F1t5ES0EIXhfSUWMUZFth%2Fimage.png?alt=media\&token=b032029c-da42-4064-8bdc-d47e65ea878a)or,
   * Click **+ RESTAPI** to create a new one.

If you’re creating a new connector:

* You’ll be redirected to the **Connectors** page with the [REST API](https://docs.nected.ai/nected-docs/integrations/integrations-libraries/rest-api) modal opened.
* Provide the required connection details (name, base URL, authentication, etc.).
* Click **Test Connection**.
* Then publish the connector in **Staging**, followed by **Production**.
* Return to the workflow editor, click **Refresh ↻**, and your new connector will now appear in the list.

Now inside the REST API Node, you'll be able to see **three tabs**. Here’s what you can configure in each:

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2Fs04pR70JDzqtvV7EdYwX%2Fimage.png?alt=media&#x26;token=fc2fccec-0061-4e40-9f30-dd8ce118c90b" alt="" width="375"><figcaption></figcaption></figure>

## **Input Params Tab**

This tab lets you configure how the node makes the actual HTTP request.

| Field                    | Description                                                                                                                                                                                                                                                                                   |
| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Integration Dropdown** | Select from existing REST API connectors. Click the ✎ icon to edit, or **+Create Connector** to add a new one (redirects to the Connectors page).                                                                                                                                             |
| **Method**               | Choose from `GET`, `POST`, `PUT`, `PATCH`, or `DELETE`. Method selection determines if body/content configuration is needed.                                                                                                                                                                  |
| **Base URL**             | Inherited from the connector. It’s the root address of the API (e.g., `https://api.airtable.com/v0/`).                                                                                                                                                                                        |
| **Authentication**       | Configured during connector creation. Shown here but **not editable** from this tab.                                                                                                                                                                                                          |
| **URL Path**             | Path appended to the base URL for targeting specific resources. You can use dynamic tokens like `{{workflow.input.customer_id}}` for runtime values.                                                                                                                                          |
| **Headers**              | Predefined headers from the connector are auto-populated and locked. You can **add more custom headers** as key-value pairs. Examples: `Content-Type: application/json`, `x-api-key: abc123`.                                                                                                 |
| **Query Parameters**     | Similar to headers—preset values from the connector are pre-filled and immutable. You can **add extra query params** dynamically as needed.                                                                                                                                                   |
| **Content Type**         | Only appears for `POST`, `PUT`, or `PATCH` methods. Select the payload format from options like JSON, XML, FORM, FORM URL Encoded, TEXT, HTML, or JavaScript.                                                                                                                                 |
| **Request Body**         | Appears for payload-based methods. Use the editor to write the request body in the selected content type. You can use workflow tokens to dynamically inject values. While the API will receive the body as intended (e.g., XML), the UI will display the response in JSON for ease of review. |
| **Allow-list IPs**       | Expand this section to view and copy Nected’s IP address (`43.205.43.45`) for API server allow-listing. This is required in cloud deployments where APIs have IP whitelisting enabled.                                                                                                        |

### Content Types and Request Body Configuration

The Content Type determines how your request body data is formatted and interpreted by the receiving API. Choose the content type that matches what your target API expects.

{% tabs %}
{% tab title="JSON" %}
Most modern REST APIs expect JSON format. This is the most common choice for structured data.

**Request Body Example:**

```json
{
  "customer_id": "{{.customInput.customer_id}}",
  "email": "{{.customInput.customer_email}}",
  "order_details": {
    "product_id": "{{.customInput.product_id}}",
    "quantity": {{.customInput.quantity}},
    "total_amount": {{.customInput.total_amount}},
    "currency": "USD"
  },
  "metadata": {
    "source": "nected_rule",
    "timestamp": "{{.customInput.current_timestamp}}"
  }
}
```

{% endtab %}

{% tab title="XML" %}
Legacy systems or SOAP-based APIs often require XML format.

**Request Body Example:**

```xml
<?xml version="1.0" encoding="UTF-8"?>
<customer>
    <id>{{.customInput.customer_id}}</id>
    <email>{{.customInput.customer_email}}</email>
    <order>
        <product_id>{{.customInput.product_id}}</product_id>
        <quantity>{{.customInput.quantity}}</quantity>
        <total_amount>{{.customInput.total_amount}}</total_amount>
    </order>
    <metadata>
        <source>nected_rule</source>
        <timestamp>{{.customInput.current_timestamp}}</timestamp>
    </metadata>
</customer>
```

{% endtab %}

{% tab title="FORM" %}
Traditional web forms or APIs that expect form-encoded data.

**Request Body Example:**

```
customer_id={{.customInput.customer_id}}&email={{.customInput.customer_email}}&product_id={{.customInput.product_id}}&quantity={{.customInput.quantity}}&total_amount={{.customInput.total_amount}}&source=nected_rule

```

**Token Usage Tips:**

* Values are automatically URL-encoded
* Use `&` to separate key-value pairs
* No quotes needed around token values
  {% endtab %}

{% tab title="FORM URL Encoded " %}
File uploads or complex form submissions with multiple data types.

**Request Body Example:**

```
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="customer_id"

{{.customInput.customer_id}}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="email"

{{.customInput.customer_email}}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="order_data"

{"product_id": "{{.customInput.product_id}}", "quantity": {{.customInput.quantity}}}
------WebKitFormBoundary7MA4YWxkTrZu0gW--
```

{% endtab %}

{% tab title="TEXT" %}
Simple text data or custom formats that don't fit other categories.

**Request Body Example:**

```
Customer ID: {{.customInput.customer_id}}
Email: {{.customInput.customer_email}}
Product: {{.customInput.product_name}}
Quantity: {{.customInput.quantity}}
Order Total: ${{.customInput.total_amount}}
Processing Date: {{.customInput.current_date}}
```

{% endtab %}

{% tab title="HTML" %}
When sending HTML content, such as email templates or web content.

**Request Body Example:**

```html
<!DOCTYPE html>
<html>
<head>
    <title>Order Confirmation</title>
</head>
<body>
    <h1>Hello {{.customInput.customer_name}}!</h1>
    <p>Your order #{{.customInput.order_id}} has been confirmed.</p>
    <div>
        <strong>Product:</strong> {{.customInput.product_name}}<br>
        <strong>Quantity:</strong> {{.customInput.quantity}}<br>
        <strong>Total:</strong> ${{.customInput.total_amount}}
    </div>
    <p>Thank you for your purchase!</p>
</body>
</html>
```

{% endtab %}

{% tab title="JavaScript" %}
Rarely used, mainly for APIs that execute JavaScript code or JSONP callbacks.

**Request Body Example:**

```jsx
function processOrder() {
    var customerId = "{{.customInput.customer_id}}";
    var email = "{{.customInput.customer_email}}";
    var orderData = {
        productId: "{{.customInput.product_id}}",
        quantity: {{.customInput.quantity}},
        total: {{.customInput.total_amount}}
    };
    return orderData;
}
processOrder();
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Tip:** You can use **tokens** inside the **URL path** along with the **value fields** of both **Headers** and **Query Parameters** to make your HTTP requests dynamic. Just start typing with `{}` and a list of available tokens will appear—these can include workflow inputs, outputs from previous nodes, or other dynamic values. This allows your API calls to adapt at runtime based on real-time data.
{% endhint %}

## **Test Results Tab**

This tab lets you test the API configuration:

* Click **Test API** to execute the configured request using test inputs.
* The API response (or any error) will be displayed in JSON format.
* You can inspect the structure of the response to ensure correct integration before saving the node.

## **Settings Tab:**

In the settings tab, you can adjust the timeout time for the Rest API.

### **Timeout after:**

The "Timeout after" option allows you to set a time limit for the node's operation. If the node takes longer than the specified time, it will automatically stop running.

### Continue on error:

If you turn this setting on, then even if the workflow node gets any error, the workflow will continue to execute the next node with the error.

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FTCXVpAt6Sf3xLW1uhVNf%2Fimage.png?alt=media&#x26;token=65fe909e-1204-48cb-bceb-5a81087de3c8" alt=""><figcaption></figcaption></figure>

Let's take an example:

Let's say we have these 3 nodes in our workflow:

<figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2FEQf55ClcTmlnoAWsK34L%2Fimage.png?alt=media&#x26;token=584653b3-4ad6-4cf8-bd3b-b45eb49dc73e" alt="" width="188"><figcaption></figcaption></figure>

The first one is a Formula node, the second one is a Rule node and the third one is a database node.

**Continue on error** can be toggled on or off for each node in the workflow. When this setting is activated, it allows the workflow to proceed to the next node even if an error occurs in the current node. Specifically, if the first node, like "modified\_cart," encounters an error while this setting is enabled, the workflow will not be halted. Instead, it will advance to the subsequent node, such as the rule node, with the error details passed along from the previous node. This functionality facilitates the continuation of the workflow despite errors, promoting greater flexibility and resilience in managing workflows by allowing for potential error handling at later stages of the process.

### Response Caching

For workflows that involve API calls through an **API Node**, Response Caching can be turned on to optimize API interactions by using cached responses based on defined inputs.

1. **Open the API Node**: Select the **API Node** within the workflow editor.
2. **Access the Settings Tab**: Go to the **Settings** tab of the API node.

   <figure><img src="https://4290782554-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLg716fCfV8IUwXQygkTG%2Fuploads%2Fp1tTMK0fbcwTtA6pgXFa%2Fimage.png?alt=media&#x26;token=ab6ca6ae-bc5f-464d-8bf4-bcfd9c17e1d7" alt=""><figcaption></figcaption></figure>
3. **Enable Response Caching**: Toggle the **Response Caching** option to activate it.
4. **Configure Caching Parameters**:
   * **Key Parameters**: Select input parameters that will use cached responses during workflow execution.
   * **Cache Expiry Time**: Set the duration (Days, Hours, or Minutes) for cached data to remain valid.
   * **Clear Cache**: Specify which environment (Staging or Production) cache data to clear, if needed.

The 'Test' and 'Save' buttons at the bottom of the tab are used to test the API call with the configured parameters and to save the node configuration if the tests are successful.
