Build AI Agent

How to Connect Your AI Agent to Any External System

July 14, 20267 min read

If your AI Agent only lives inside a dashboard, you're leaving most of its value on the table. The real payoff comes when the agent can be called from the tools your business already runs on — your own app, a mobile experience, an internal ops tool, or an automation platform like Zapier or Make. Ajax Union MarTech's Public API makes that possible: it lets any external system list, inspect, and run your production-ready AI Agents programmatically, without anyone logging into the dashboard by hand.

This guide walks through what the Public API does, when to use it, and how to connect it to an outside system step by step.

What the Public API Actually Does

The Public API is a secure channel for outside applications to talk to your AI Agents directly. Instead of a person clicking through the interface, your software sends a request over HTTPS, the matching agent runs, and you get back a structured JSON response your system can parse immediately — no extra parsing or natural-language cleanup required on your end.

Every request is tied to a specific account and must carry proper authentication. Only agents that have been promoted to Active status in the Production stage are reachable through the API — agents still in draft or testing are not exposed.

Why You'd Connect an External System

A few common reasons teams reach for this:

  • Embedding agents elsewhere. Put an agent's intelligence inside a mobile app, a SaaS product, a voice assistant, or an internal tool your team already uses daily.

  • Triggering agents from automations. Kick off an agent run as a step inside a larger workflow in Zapier, Make, or a custom pipeline.

  • Centralizing access control. Manage who can call which agent through scoped, revocable tokens rather than shared logins.

  • Getting clean, structured output. Every response comes back as JSON, so downstream systems can act on it without additional interpretation.

Before You Start

Confirm two things before writing any code:

  1. The agent you want to call is already published and Active in Production. Agents in draft won't respond to API calls.

  2. You know which account you're connecting to — every request needs to specify this, and requests missing it are rejected outright.

How to Connect Your AI Agent to an External System

Step 1: Turn on AI Agents for your account. Make sure the AI Agents capability is enabled and that the agent you plan to call has at least one version published to Production.

Step 2: Create your API credentials. In your account's developer settings, create either a Private Integration or an OAuth app, depending on how you plan to authenticate (more on the difference below). This step generates the credentials your external system will use to identify itself.

Step 3: Save your credentials securely. Copy the Client ID and Client Secret (for OAuth) or the Private Integration Token (for a direct server-to-server connection). Treat these the same way you'd treat a password — they grant access to run agents on your account's behalf.

Step 4: Exchange for an access token (OAuth only). If you're using OAuth, your app calls the token endpoint with an authorization code to receive a bearer access token. Store this token securely and refresh it before it expires — OAuth supports a standard refresh flow so users don't need to re-authenticate manually.

Step 5: Test the connection. Make a simple List Agents call, passing your account identifier as a query parameter. [Guessing] The exact base URL for this call should come from your Ajax Union MarTech developer settings rather than being hardcoded — confirm the correct endpoint domain before publishing this instruction externally. A successful response returns the list of agents available to that account.

Step 6: Grab the agent ID you want to run. Parse the response from Step 5 and note the ID of the specific agent you intend to execute.

Step 7: Execute the agent. Send a request to the Execute Agent endpoint with your account identifier and the input you want the agent to process (for example, a prompt like "Write a Facebook ad for a plumbing company"). The response comes back as a single JSON object containing the agent's full output.

Step 8: Save the execution ID for follow-up turns. If the conversation needs to continue — a follow-up question, a refinement — the response includes an execution ID. Pass that same ID on your next call to keep the conversation threaded rather than starting over.

The Three Endpoints You'll Use Most

  • List Agents — returns every active agent available to your account. Useful for populating a dropdown of available agents inside your own app.

  • Get Agent — retrieves full detail on one agent: its name, status, configured tools, variables, and lifecycle stage. Useful for showing agent details before running it, or checking what inputs it expects.

  • Execute Agent — runs the agent and returns the complete result in one response. This is the endpoint that does the actual work.

Beyond these three, account management actions — creating, updating, publishing, and deleting agents — are also available through the API for teams that want to manage their entire agent library programmatically rather than through the dashboard.

Authentication: OAuth vs. Private Integration

You have two ways to authenticate:

OAuth 2.0 is the standard choice when you're building something other users will connect their own accounts to — think a SaaS product with multiple customers. It uses a bearer access token in the request header and supports token refresh without requiring the user to log in again.

Private Integration is the simpler path for server-to-server connections where you control both ends — an internal tool, a backend automation, a single-account integration. You generate one token scoped to a specific account and use it the same way you'd use an OAuth access token, just without the authorization-code exchange.

Neither approach should ever be called directly from client-side JavaScript. Always route the request through your own backend so the token itself is never exposed in a browser.

Rate Limits and Session Handling

Each account is capped at 300 API requests per minute across all AI Agent endpoints — worth knowing before you build a high-volume integration. Execution sessions (tracked by the execution ID) expire after 30 minutes of inactivity; after that, start a fresh session rather than trying to resume the old one.

Frequently Asked Questions

Is there a rate limit on API calls?

Yes. Each account is limited to 300 requests per minute across all AI Agent endpoints.

Can I stream partial responses as the agent works?

Not currently. The Execute Agent endpoint returns one complete JSON response after the agent finishes running.

Does my agent need to be published before I can call it?

Yes. Only agents that are Active in the Production stage are reachable through the API.

What happens if I forget to include my account identifier?

The request fails with an error indicating the account identifier is required.

Is it safe to call the API from client-side JavaScript?

No — always proxy the call through your own backend so your access token isn't exposed to anyone viewing the page source.

How long does an execution session stay active?

30 minutes of inactivity before it expires. Start a new session if you need to pick the conversation back up after that.

Does OAuth support refreshing my access token automatically?

Yes, through the standard OAuth refresh flow, so returning users don't need to reauthorize manually.

Are Private Integration tokens tied to one account only?

Yes — a Private Integration token is scoped to the single account it was generated for and won't work across others.


Ready to put your AI Agents to work outside the dashboard? Head to app.ajaxunion.com to generate your credentials and get connected, or visit  https://martechsupport.com/home for more guides on getting the most out of your AI Agents.

Back to Blog