Overview
With API Data Sources, you can:- Connect External APIs: Configure secure connections to fetch user data from external systems
- Define Permission Rules: Automatically grant permissions based on API response data
- Enrich Conversations: Include relevant user context in AI agent conversations
- Test Configurations: Validate API connections and permission rules for specific users
Creating an API Data Source
Navigate to Developer > Data > API Integration to create a new connection. Basic Settings:URL Placeholders
Use the following placeholders in your API URL, headers, or request body:<<email>>- User’s email address<<user_id>>- Internal user ID<<username>>- Username<<clerk_id>>- Clerk authentication ID<<api_key>>- Your configured API key<<thread_id>>- ID of the current conversation (empty outside a conversation)<<first_user_message>>- The customer’s first message in the conversation<<user_messages>>- All the customer’s messages in the conversation so far, oldest first, separated by a blank line
<<jwt.claimName>>, including nested paths such as <<jwt.user.id>>. A placeholder occupying the entire JSON value preserves its original type: "<<jwt.userId>>" becomes a JSON number when the JWT claim is numeric.
If the external API requires a string, use "<<jwt.userId|string>>". For example, {"organizationId": "<<jwt.userId|string>>"} sends {"organizationId": "12345"} when userId is the number 12345 in the JWT.
Using the Conversation
The conversation placeholders let an external service answer about the conversation itself, not only about the user. For example, a classifier can tell the agent whether the customer’s request should go straight to a ticket:covered and category) with Include in Conversation enabled, then tell the agent in its instructions what to do with them.
A source that uses a conversation placeholder caches one response per conversation, so a response is never reused in another conversation:
- With
<<first_user_message>>, the service is called once per conversation and the cached response is reused on every later message while the cache is valid. - With
<<user_messages>>, the service is called again after each new customer message. Use it when the first message is often only a greeting.
Answer with a workflow
Instead of calling an external API, a source can be answered by a workflow that runs inside AGO, for example to call your classifier, tag the conversation with its answer (kb_covered or kb_not_covered) and return the answer to the agent. No URL, secret or request template is needed.
- Create a workflow, set Execution to Wait for the result in its Settings, and publish it. Any trigger works.
- Edit the source, set Answered by to AGO workflow and choose the workflow. Workflows that run in the background or are not published yet are shown but cannot be selected.
Its result becomes the source’s response: Response Data Path, Excluded Response Paths, context mappings and permission rules apply to it as to an API response. The workflow runs with its creator’s permissions and must finish within 20 seconds.
While the cache is valid, the workflow runs once per conversation; disable the cache to run it before every answer. If it fails, the agent answers without this context and the error is shown in the workflow’s Executions; the next message runs it again. The test panel has no conversation, so
thread_id is empty and a Tag conversation block tags nothing. A workflow used by a source cannot be deleted; choose another workflow or switch the source back to its API first. The source keeps its API settings while a workflow answers, so switching back restores them.
Authentication
API Key: Enter your API key in the dedicated field. It is encrypted and stored securely. Reference it in headers using the<<api_key>> placeholder.
Forward User Auth: Enable this option to pass the user’s authentication token to the external API. Useful when the external API needs to verify the user’s identity directly.
HMAC-SHA256 Authentication
Enable Sign requests with HMAC-SHA256 and enter the shared HMAC secret. The secret is stored encrypted and is never returned by the configuration API. When editing a source, leave the secret empty to keep it, or enter a new value to replace it. You do not need to re-enter the secret when changing other settings. Disabling and re-enabling HMAC signing also retains the stored secret. For every outgoing request, AGO generates:X-Timestamp: the current Unix timestamp in seconds.X-Signature: the lowercase hexadecimal HMAC-SHA256 oftimestamp.body, using your secret as a UTF-8 key and the exact request body bytes. For GET requests, the body is empty.
X-Partner-Id, in Request Headers.
For a partner context endpoint, choose POST and configure these headers:
12345 with <<jwt.organizationId>> (or the matching claim path).
Link the source to your agent in the agent settings so its response can enrich conversation context. HMAC uses the existing API data source loading and caching behavior: a cached response does not trigger a new HTTP request. Disable caching if you need fresh data on every context load. Use the source’s test panel to verify your configuration.
JWT Query Parameters
Map JWT claim values to URL query parameters for user-specific API calls. This allows you to pass information from the user’s authentication token directly as query parameters to the external API. Configuration: Each mapping consists of:- Parameter Name: The query parameter name to add to the URL
- JWT Claim Path: Dot-notation path to the value in the JWT claims (e.g.,
user.department)
department → user.department and a JWT containing:
https://api.example.com/data becomes https://api.example.com/data?department=Engineering.
If a JWT claim is missing or empty, that parameter is silently skipped. This feature requires JWT-authenticated widget users.
Response Configuration
Response Data Path: If your API wraps data in nested objects, specify the path to extract the relevant data using dot notation. For example, if your API returns:data.user to extract just the user object.
Caching
Permission Rules
Permission rules define conditions that, when matched against API data, automatically grant specific permissions to users.Creating a Permission Rule
- Navigate to AI Studio > Permissions > API-based permissions
- Click Add Rule
- Select the API data source and configure the rule name, priority, conditions, and permissions to grant
Conditions
Each condition has a field, operator, and value. All conditions in a rule must match (AND logic).Example
Grant premium permissions to users with an active premium subscription:Context Mappings
Context mappings extract fields from API responses and include them in AI conversations, giving agents relevant business context about users.Field Mapping Configuration
Enable Include in Conversation to share the mapped data with AI agents.
Context Formatting
Included fields appear as a list of labels and values. For example:Testing
Before deploying, test your configuration with real user data.- Navigate to Developer > Data > API Integration > Test API Data
- Select the API data source
- Enter an existing user’s email in User Email, or leave it empty to test with your own user
- For a source that uses a conversation placeholder, type a sample message in Customer message. It is used as the first message and as the whole conversation
- Click Run Test and review the API response, matched rules, and granted permissions
