Invoke Web API
Overview
The Invoke Web API action allows your agents to make RESTful API calls to external systems and services. This enables access to third-party data sources, submission of information to web services, and integration with existing infrastructure.
Use Cases
-
External Data Retrieval: Connect to public or private APIs to fetch real-time data
-
Data Querying: Search external databases or services using specific parameters
-
Third-Party Integrations: Access services that expose information via REST APIs
-
Enriching Workflows: Incorporate external data sources into your agent’s processing
How to Configure Web API Calls
Add the Action
-
In the Actions tab, click “Add action”
-
Select the “Advanced” category
-
Choose “Invoke Web API”
Configuration Fields
URL
-
Description: Enter the web address of the API you want to connect to (this information should be provided in the API documentation)
-
Example: https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY
-
Required: Yes
Method
-
Description: Choose how you want to interact with the API
-
Options:
-
GET: Retrieve information (most common)
-
POST: Send information to create something new
-
PUT: Update existing information
-
HEAD: Check if a resource exists without retrieving it
-
-
Required: Yes
Headers (JSON)
-
Description: Think of these as your “ID card” when talking to an API..
-
Example: Many APIs need to know who you are before giving you information. For instance, for the X (Twitter) API, you’d need: {“Authorization”: “Bearer YOUR_ACCESS_TOKEN”}. The API’s documentation will usually tell you exactly what to put here.
-
Required: No
Body (JSON)
-
Description: This is the information you want to send to the API.
- Only needed when you’re sending data (POST or PUT methods).
-
Example: when posting a tweet with the X API, you’d include: {“text”: “Hello world!”}.
-
When using GET requests (just retrieving information), you typically leave this empty.
-
The API’s documentation will specify exactly what format to use
-
-
Required: No
Output Variable Name
-
Description: Assign a variable name to store the API response.
-
Example: “api_response” or “rest_data.”
-
Validation: Only letters, numbers, and underscores (_) are allowed.
-
Required: Yes
Using API Responses
The API response will be stored in your specified output variable. You can access specific data points using dot notation:
-
{{variable_name.property}}
-
{{variable_name.nested.property}}
Example: RESTful API Example Agent
See this simple Grant Search Agent that demonstrates API usage:
-
Step 1: Collects a research focus from the user
-
Step 3: Makes a REST API call to a government grants database with these keywords
-
Step 5: Presents the information to the user as a formatted output
This workflow shows how external APIs can significantly expand an agent’s capabilities by providing access to specialized data sources that aren’t available within the Agent.ai platform itself.