Understanding API Connections
API Connections are the bridge between your GenerativeAgent and your external APIs. They allow your agent to interact with your existing systems and services, just like a human agent would.How API Connections Fit In
GenerativeAgent uses a hierarchical structure to organize its capabilities:- Tasks: High-level instructions that tell GenerativeAgent what to do. A task can have one or more functions.
- Functions: Tools that help GenerativeAgent complete tasks. A function can point to a single API Connection.
- API Connections: Configurations that enable Functions to interact with your APIs.

Core Components
Each API Connection consists of three main parts that work together:-
API Source:
- Handles the technical details of calling your API
- Manages authentication and security
- Configures environment-specific settings (sandbox/production)
-
Request Interface:
- Defines what information GenerativeAgent can send
- Transforms GenerativeAgent’s requests into your API’s format
- Includes testing tools to verify the transformation
-
Response Interface:
- Controls what data GenerativeAgent receives
- Transforms the API response to a GenerativeAgent friendly format
- Includes testing tools to verify the transformation
Create an API Connection
To create an API Connection, you need to:Access the API Integration Hub
- Navigate to API Integration Hub in your dashboard
- Select the API Connections tab
- Click the Create Connection button
Select or Upload Your API Specification
- Choose an existing API spec from your previously uploaded API Specs, or
- Upload a new OpenAPI specification file
Configure Basic Details
- Name: A descriptive name for the API Connection
- Description: Brief explanation of the connection’s purpose
- Endpoint: Select the specific API endpoint from your specification
Configure the API Source
- Set up authentication methods
- Configure environment settings
- Define error handling rules
- Add any required static headers
Set Up Request and Response Interfaces
- Define the Request Interface:
- Specify the schema GenerativeAgent will use
- Create request transformations
- Test with sample requests
- Configure the Response Interface:
- Define the response schema
- Set up response transformations
- Validate with sample responses
Test and Validate
- Run test requests in the sandbox environment
- Verify transformations work as expected
- Check error handling behavior
Link to Functions
Request Interface
The Request Interface defines how GenerativeAgent interacts with your API. It consists of three key components that work together to enable effective API communication.- Request Schema: The schema of the data that GenerativeAgent can send to your API.
- Request Transformation: The transformation that will apply to the data before sending it to your API.
- Testing Interface: The interface that allows you to test the request transformation with different inputs.

Request Schema
The Request Schema specifies the structure of data that GenerativeAgent can send to your API. This schema should be designed for optimal LLM interaction.Simplify Field Names
Simplify Field Names
Flatten Complex Structures
Flatten Complex Structures
Add Clear Descriptions
Add Clear Descriptions
Remove Optional Fields
Remove Optional Fields
- Keep only essential fields that GenerativeAgent needs
- Set
"additionalProperties": false
to prevent unexpected data
Request Transformation
The Request Transformation converts GenerativeAgent’s request into the format your API expects. This is done using JSONata expressions.-
request
: The request object provided by GenerativeAgent. This will match your defined schema. -
context
: The context object passed in by the ASAPP system. This currently contains the following values:externalConversationId
: The id of the conversation as provided by your system when creating the conversation.asapp.conversationId
: The id of the conversation as generated by ASAPP.
Example Context JSON
context.[value]
and request.[value]
.Basic Field Mapping
Basic Field Mapping
Data Formatting
Data Formatting
Conditional Logic
Conditional Logic
Request Testing
Thoroughly test your request transformations to ensure GenerativeAgent can send the correct data to your API. The API Connection can not be saved until the request transformation has a successful test. Testing Best PracticesTest Various Scenarios
Test Various Scenarios
Validate Error Cases
Validate Error Cases
- Test with missing required fields
- Verify invalid data handling
- Check boundary conditions
Use Sandbox Environment
Use Sandbox Environment
- Test against actual API endpoints
- Verify complete request flow
- Check response handling
Response Interface
The Response Interface determines how API responses are processed and presented to GenerativeAgent. A well-designed response interface makes it easier for GenerativeAgent to understand and use the API’s data effectively. There are three main components to the response interface:- Response Schema: The JSON schema for the data returned to GenerativeAgent from the API.
- Response Transformation: A JSONata transformation where the API response is transformed into the response given to GenerativeAgent.
- Test Response: The testing panel to test the response transformation with different API responses and see the output.

Response Schema
The Response Schema defines the structure of data that GenerativeAgent will receive. Focus on creating clear, simple schemas that are optimized for LLM processing.Focus on Essential Data
Focus on Essential Data
Use Clear Data Types
Use Clear Data Types
Standardize Formats
Standardize Formats
- Use consistent date/time formats
- Normalize enumerated values
- Use standard units of measurement
Response Transformation
The Response Transformation converts the raw API response into the format GenerativeAgent will receive. This is done using JSONata expressions. GenerativeAgent works best with simple, structured data. The goal is to simplify and standardize the data.clientApiCall.data
: The raw JSON response from the API.
clientApiCall.data
.Response Testing
Thoroughly test your response transformations to ensure GenerativeAgent receives well-formatted, useful data. The API Connection can not be saved until the response transformation has a successful test. Use API Mock Users to save response from your server to use them in the response testing. Testing StrategiesTest Different Response Types
Test Different Response Types
Validate Data Formatting
Validate Data Formatting
- Check date/time formatting
- Verify numeric calculations
- Test string manipulations
Edge Cases
Edge Cases
- Handle null/undefined values
- Process empty arrays/objects
- Manage missing optional fields
Redaction
You have the option to redact fields in the request or response from API Connection Logs or Conversation Explorer. You can redact fields the internal request and response, by addingx-redact
to a field in the Request Schema or Response Schema. You will need to save the API connection to apply the changes. This will redact the fields in the Conversation Explorer as well.
You can redact fields in the raw API request and response, by flagging the fields in the relevant API Spec:
- Navigate to API Integration Hub > API Specs
- Click on the relevant API Spec.
- Click on the “Parameters” tab and flag
- Per endpoint, click the fields you want to redact.
API Versioning
Every update to an API Connection requires a version change. This is to ensure that no change can be made to an API connection that impacts a live function. If you make a change to an API connection, the Function that references that API connection will need to be explicitly updated to point to the new version.API Connection Logs
We log all requests and responses for API connections. This allows you to see the raw requests and responses, and the transformations that were applied. Use the logs to debug and understand how API connections are working. Logs are available in API Integration Hub > API Connection Logs.Default API Spec Settings
You can set default information in an API spec. These default settings are used as a template for newly created API connections, copying those settings for all API connections created for that API spec. You can set the following defaults:- Headers
- Sandbox Settings:
- Base URL
- Authentication Method
- Production Settings:
- Base URL
- Authentication Method
Examples
Here are some examples of how to configure API connections for different scenarios.Update Passenger Name (Simple mapping)
Update Passenger Name (Simple mapping)
API Endpoint
API Response
Request Configuration
Request Configuration
- Request Schema:
- Request Transformation:
- Sample Test Request:
Response Configuration
Response Configuration
- Response Schema:
- Response Transformation:
- Sample Test Response:
Lookup Flight Status (Complex mapping)
Lookup Flight Status (Complex mapping)
API Endpoint
API Response
Request Configuration
Request Configuration
- Request Schema:
- Request Transformation:
- Sample Test Request:
Response Configuration
Response Configuration
- Response Schema:
- Response Transformation:
Appointment Lookup (Date Formatting)
Appointment Lookup (Date Formatting)
API Endpoint
API Response
Request Configuration
Request Configuration
- Request Schema:
- Request Transformation:
- Sample Test Request:
Response Configuration
Response Configuration
- Response Schema:
- Response Transformation:
- Sample Transformed Response: