AI Employees and APIs
An agent treats every endpoint as a typed contract with declared failure modes — and every write as an action it has no authority to take by default.
Direct Answer (Quick Summary)
An AI employee uses APIs as its interface to systems it cannot see into. For that to be reliable, every endpoint must be exposed as a typed tool contract with declared scopes, rate limits and failure semantics, and every write must carry authority the model does not hold by default. Without both properties, API access produces demos, not dependable operations.
Key Takeaways
- A raw REST endpoint is not an agent-grade tool. It needs a description, a typed schema, and declared failure behaviour.
- Error semantics matter more than endpoint count. An agent that cannot distinguish 404 from 403 will retry into damage.
- The read/write line is the single most important design decision, because it determines your blast radius.
- Retries are safe for idempotent reads and unsafe for writes, which is why idempotency keys belong in the tool contract.
- Pagination and rate limits must be part of the contract, or a run will silently truncate its own input.
- API deprecation is an operational problem: an agent with a cached schema will fail quietly on a Tuesday release.
An AI employee uses APIs the way a person uses a UI — as the interface to a system it cannot see into. What makes that reliable is treating every endpoint as a typed contract with declared failure semantics, and every write as an action carrying authority the model does not hold by default. Get those two properties right and API access becomes boring infrastructure. Get them wrong and you get demos.
An API is a contract, not a feature
Most teams start by giving a model a list of endpoints and a bearer token. It works on the happy path and then fails in ways that look like model incompetence but are integration design failures.
A useful tool contract declares five things:
- What the tool does, in one sentence the model can reason about.
- Typed inputs and outputs, with enums where the API actually enforces them.
- Scope, stated explicitly — read, write, or delete.
- Failure behaviour — which errors are retryable, which are terminal, which need a human.
- Side effects, so the model knows whether calling this twice is safe.
Point 4 is where most hand-rolled integrations are silent, and it is the direct cause of the classic agent failure: a tool that returns 403 for insufficient scope, the agent reads it as a transient error, retries four times, and buries the real message in a log nobody opens.
The five things that break API-backed agents
| Failure | What actually happened | Fix |
|---|---|---|
| Blind retry | 403 or 422 treated as transient | Declare retryable error classes in the contract |
| Silent truncation | Paginated response read as complete | Return cursors and page counts to the model |
| Partial write | Step A committed, step B failed | Idempotency keys plus a compensating record |
| Scope drift | Vendor changed a response field | Validate responses against the schema at the boundary |
| Rate-limit cascade | Parallel steps exhaust a per-minute quota | Concurrency limits per connection, backoff on 429 |
None of these need a better model. All of them need the contract to state what the model could not otherwise know.
Turning an endpoint into an agent-grade tool
The work is mechanical, which is good news:
- Generate the schema from the OpenAPI document, or write it by hand if none exists.
- Name the tool for the action, not the resource.
search_open_invoicesbeatsget_invoices. - Constrain inputs to what the call needs. Every optional parameter is a decision the model has to make without evidence.
- Classify the errors. Return 403 as a scope error the model must escalate, not as a generic failure.
- Mark idempotency in the schema, and pass a key when the operation is not naturally idempotent.
- Publish through a server so the tool is discoverable rather than hard-coded into one employee's prompt.
Step 6 is what makes integration cost linear instead of quadratic. What is MCP and why it matters for AI employees covers the discovery layer in detail.
Contract tests
An API contract is a promise made by a vendor you do not control. The only way to know it still holds is to test it cheaply, on a schedule, with no agent in the loop.
- Schema validation. Store the expected response shape per tool, validate every real response against it, and alert on the first field that disappears.
- Error-path probes. Call tools you expect to fail — missing scope, expired token, malformed id — and assert each returns the error class the contract declares.
- Fixture replays. Re-run a small set of known payloads and check the output still satisfies the contract. Do not assert identical text, because model output legitimately varies.
- Permission canaries. Confirm a revoked credential actually fails, instead of quietly succeeding from a cache.
None of this needs a model, which is the point. These tests run in CI, cost seconds, and turn a Tuesday schema change into an alert rather than a month of quietly wrong records.
What MCP standardises, and what it does not
MCP gives a shared wire format for tool discovery and invocation. That is genuinely useful: an employee picks up a new server and immediately sees typed tools rather than a hand-written client.
It does not give you authority. A tool discovered over MCP still needs a scope, a credential and an approval policy, because the protocol describes how to call something, not whether you should. MCP versus traditional integrations works through that boundary, and how AI employees use tools and MCPs covers tool selection at execution time.
The read/write line
Draw it early, per employee, and treat it as the primary control. Reads are reversible, cheap and mostly safe to repeat. Writes are not. An employee with read-only access to your CRM, billing system and support platform can do genuinely valuable work — reconciliation, triage, drafting, reconciliation reports — with no approval gate at all, because nothing has changed.
The moment you allow a write, you need a gate on that specific action, and you need the run record to show what was written. How to control what AI employees can access covers how to express this as policy rather than as code.
Idempotency and partial failure
The rule is short: an agent that performs multiple writes to multiple systems must be able to resume without duplicating. Concretely, that means a stable key per intended action, a record of which actions are confirmed, and a written decision about what happens when a later action fails after an earlier one succeeded.
That last part is a business decision, not a technical one. Retrying everything risks double-charging. Retrying nothing risks an incomplete record. You have to say which, in advance, per outcome. How AI employees handle multi-step work covers how the runtime tracks step state.
Deprecation is an operations problem
Vendor APIs change. The failure mode is quiet: the agent keeps calling with an old schema, gets a 200 with a missing field, and writes incomplete records that nobody notices for a month. Response validation at the tool boundary converts that into an explicit failure. AI employees and enterprise data covers the surrounding data contracts.
How to apply this
- Inventory the endpoints the outcome actually needs. Usually it is fewer than you think.
- Give each one a typed contract with classified errors before connecting it to any agent.
- Start every employee read-only and prove the run completes.
- Add exactly one write, gate it, and confirm the run record captures the payload.
- Define the partial-failure decision for that write before you enable it in production.
- Validate responses at the boundary and treat any drift as a hard failure.
AI employees and SaaS applications covers the per-system patterns, and how to prevent AI employees from taking unauthorized actions covers the controls in more depth.
Sources and further reading
- Model Context Protocol: Introduction: the open standard for connecting AI applications to tools and data.
- Anthropic: Tool use with Claude: how a model requests a tool call and reads the result.
- OpenAI: Function calling: typed tool contracts in a model API.
Frequently Asked Questions
Do AI employees need API access, or is browser automation enough?
API access is strongly preferred. Browser automation is brittle, slow and hard to audit, and it usually fails the moment a vendor changes a selector. Reserve browser control for systems with no documented interface at all. Where an API exists, an employee working through it is faster, cheaper and produces a cleaner audit record.
How is an API-backed AI employee different from a normal API client?
A normal client knows the call sequence in advance. An AI employee decides the next call at runtime, which means the integration must describe failure modes the client would never encounter and must make partial failure survivable. Retry policy, pagination and error classification move from optional polish to correctness requirements.
Should we expose our internal microservices directly to AI employees?
Not the raw internal interfaces. Expose a purpose-built tool surface with named business operations, explicit scopes and stable schemas. Internal services change shape frequently, and an agent bound to those shapes becomes a maintenance liability the first time a service is refactored.
How do we stop an AI employee from calling an API too often?
Set concurrency and rate limits per connection rather than per employee, return 429s as a normal retryable condition, and back off. Also cap the number of tool calls a single run may make, because the expensive failure is a retry loop against a quota that only resets hourly.
What happens when an API we rely on gets deprecated?
Treat it as a scheduled migration, not a surprise. Track the contract version each employee depends on, validate responses against the declared schema so drift fails loudly, and give every integration an owner with a deprecation deadline. Agents fail quietly when this is unmanaged.
Is there a standard way to expose our APIs to AI employees?
MCP is the emerging answer and is what most platforms now speak. The practical sequence is to publish your systems as MCP servers once, then let employees and workflows attach to them by name instead of embedding bespoke clients in prompts.
Related reading
- What Is MCP and Why Does It Matter for AI Employees?
- MCP vs Traditional Integrations: An Architecture Comparison
- AI Employees and SaaS: Integration That Survives Change
- How AI Employees Use Tools and MCPs: A Practical Guide
- AI Employees and Enterprise Data
- How to Control AI Employee Access Without Slowing Work
- Isolated AI Workloads: Running AI Employees in Sandboxes