API Node¶
The API Node lets you connect to external systems and retrieve data by making SOAP or REST API calls. You can configure the APIs and pass the necessary parameters to fetch the required information.
Add and Configure an API Node¶
Setting up an API node in an Agent Flow involves adding the node at the appropriate location in the flow and configuring various node properties, as explained below.
Steps to add and configure the node:
-
On the Agents tab, click the name of the agent to which you want to add the node. The Agent Flow page is displayed.
-
Click the Go to flow button for the in-development version of the flow for editing.
-
In the flow builder, click the “+” icon on any existing node on the canvas and select API from the pop-up menu. (Alternatively, you can drag the API node from the Assets panel onto the canvas.)
-
Click the added node to open its properties dialog box. The General Settings for the node are displayed.
-
Enter or select the following information:
- Custom Name: Enter an appropriate name for the node.
- Type: Select the API type from the drop-down list - REST or SOAP.
-
Integration Type: Select the integration type for the connection—synchronous or Asynchronous—and set the timeout duration for the integration.
-
Synchronous: The allowed range is 5 to 180 seconds (3 minutes). The default is 60 seconds.
-
Asynchronous:
- Set timeout: The allowed range is 30 seconds to 300 seconds (5 minutes). The default is 60 seconds.
- No timeout: This allows the integration to wait indefinitely for the response without triggering a timeout error. This gives users the flexibility to automate their own processes, like approvals and checks, within their custom workflows before sending the response back. (Ensure to select the same "No timeout" setting for both the API node and the agent to prevent any timeouts.)
The node will trigger a timeout error if the request is not completed within the selected time frame.
Notes
-
The key difference between synchronous and asynchronous integration types is how the integration processes the request and response. Synchronous integrations block the client until the response is received, while asynchronous integrations allow the client to continue working while the integration processes the request.
-
Timeout precedence: Agent timeout > Node timeout > Third-party API endpoint timeout.
-
-
Request Definition: Define the details of the service request to make the call and fetch the data. Click Define Request and enter or select the following details in the Edit Request dialog box:
- Select the request type from the list - GET, PUT, POST, PATCH, or DELETE.
- Paste your API Endpoint URL or cURL in the text field.
- In the Headers tab, specify the details of the Key and Value pair. For example, Key: Content-Type Value: application/json
- The Body tab is displayed for all request types except GET. Select the body content type from the drop-down list:
- application/x-www-form-urlencoded: Allows file uploads through HTTP POST requests. Add key/value pairs encoded by the platform.
- application/json: Transmits data between servers and web applications using JSON format without processing.
- application/xml: Sends XML payload for SOAP services via POST methods, with the option to include node values.
- Custom: Allows sending request payload in non-standard formats, such as for handling blogs or custom variables.
- Click the Test button at the top-right corner of the dialog. The API response will appear on the Response tab.
- Click Save at the top-right corner of the dialog.
-
Click the Connections icon in the left navigation and select the Go to Node for both success and failure conditions.
-
On Success > Go to Node: After the current node is successfully executed, go to a selected node in the flow to execute next. For example, you can process the data from this node into a Function node and then use it further. In this case, select the Function node.
-
On Failure > Go to Node: If the execution of the current node fails, go to an appropriate node having a custom error message configured.
-
-
Finally, test the flow and fix any issues found: Click the Run Flow button at the top-right corner of the flow builder.
Note
To access an API node using the context variable, use the following format:
API Status Codes¶
- 200: Request successful
- 400: Client error, cannot process request
- 401: Authentication required
- 403: Access denied
- 404: Resource not found
- 500: Unexpected server error
- 504: Gateway timeout, no timely response from the upstream server