Skip to main content
An API data source calls one of your APIs, such as a CRM or a subscription platform, to fetch data about the current user or conversation. AGO uses the response in two ways:
  • Permission rules grant permissions to a user based on the returned data, for example premium features for customers on a premium plan.
  • Context mappings pass selected fields to your agents, so they can answer with the customer’s plan, account status or order details in mind.

Creating an API Data Source

Navigate to Studio > 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>> - AGO user ID
  • <<username>> - Username
  • <<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 claims are available through <<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. A placeholder with no value, such as a claim missing from the user’s JWT, is sent unchanged. The call still runs, and the conversation’s Full Thread Debug View lists the missing placeholders.

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:
Map the fields of the response (for example 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.
The source is called while the agent searches your knowledge, so a slow service only delays the answer if it takes longer than that search. Clearing a user’s cache does not clear these per-conversation responses; they expire after the cache TTL.

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.
  1. Create a workflow, set Execution to To be used by an agent in its Settings, and publish it. Any trigger works.
  2. 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.
The workflow receives these inputs: 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 Authentication: Enable this option to send the user’s credentials to the external API, so your API can verify the user’s identity itself. A widget JWT is sent as an Authorization: Bearer header; a widget auth token is sent as an X-Auth-Token header.

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 of timestamp.body, using your secret as a UTF-8 key and the exact request body bytes. For GET requests, the body is empty.
These two headers are generated automatically and override any manually configured values. Add other required headers, such as X-Partner-Id, in Request Headers. For a partner context endpoint, choose POST and configure these headers:
Use this Request Body Template:
If the organization comes from the authenticated user’s JWT, replace 12345 with <<jwt.organizationId>> (or the matching claim path). Link the source to your agent in the agent settings so its response reaches the conversation. A cached response does not send a new request, so disable caching if you need fresh data on every message. 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)
Example: With a mapping of department → user.department and a JWT containing:
The API URL 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:
Set the response data path to data.user to extract just the user object. Excluded Response Paths: List paths to drop from the response, such as metadata.debug, so that data never reaches your rules or agents.

Caching

Permission Rules

Permission rules define conditions that, when matched against API data, automatically grant specific permissions to users.

Creating a Permission Rule

  1. Navigate to Agents > Permissions > API-based permissions
  2. Click Add Rule
  3. 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:
If you need OR logic, create separate rules with different priorities.

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:
Use each mapping’s Label to choose the displayed name.

Testing

Before you link a source to an agent, test it with real user data.
  1. Navigate to Studio > Data > API Integration and open the Test API Data tab
  2. Select the API data source
  3. Enter an existing user’s email in User Email, or leave it empty to test with your own user
  4. 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
  5. Click Run Test and review the API response, matched rules, and granted permissions

Selecting Sources for Permissions and Conversations

To choose the source used to resolve user permissions, navigate to Agents > Permissions > JWT-based permissions and select API to base the permission on. Create the corresponding rules in API-based permissions. For conversation context, link the relevant API data sources directly to each agent in its settings. Conversation context uses those linked sources; the permission source is not a fallback for agents without linked sources. An agent can use several sources at once, for example one for billing and one for your CRM. They are called at the same time, so the answer waits only for the slowest one, and the agent receives the context of every source that responded. If one source fails, the agent still receives the others. Give the fields of different sources distinct names: when two sources return the same field, the agent sees both values, but the user’s stored business context keeps only one.

Troubleshooting

Run the source from the Test API Data tab to see the API response, the business context sent to the agent, the matched rules and the granted permissions. Check Bypass Cache to send a new request instead of reading a cached response. API Connection Fails: Verify the API URL, authentication credentials, and placeholder formatting. Check timeout settings if the external API is slow. Permission Rules Not Working: Verify the rule is active and applies to the source selected in API to base the permission on. Run a test to inspect the returned API data, matched rules, and granted permissions. If a rule does not match, compare its conditions with the returned data. Clear the cache and retry. Context Data Not Appearing: Verify the context mapping is active and that Include in Conversation is enabled. Check that field mappings match the API response structure, and that the source is linked to the agent. Slow Answers: Enable caching, increase the cache TTL, or reduce the API timeout setting.