| Author: Abdullah Ahmed | Category: API Development and Integration
An employee asks an AI assistant to find a delayed order and update the customer. Producing a plausible reply is easy to demonstrate. Completing the task requires something more concrete: locating the correct order, checking the employee's access, retrieving a reliable delivery status, selecting an authorised communication channel, and confirming whether the message was sent.
APIs provide the application boundaries through which an assistant can obtain information and request business operations. They do not automatically make those operations appropriate. The surrounding software must still enforce identity, permissions, validation, and a clear account of what actually happened.
A useful integration turns a broad language request into a small number of inspectable operations. This article follows that connection from user intent to confirmed outcome and explains the design decisions business and technical owners should make before giving an agent access to existing systems.
Separate the model from the execution environment
The model interprets a request and may propose a tool call. The application hosting it decides which tools exist, validates their inputs, executes permitted operations, and returns results. Keeping these responsibilities distinct makes the system easier to reason about.
A tool can wrap an existing API endpoint or combine several controlled read operations. For example, an order-status tool might retrieve an order and its latest shipment record, then return only the fields needed to answer a support question.
Do not treat a generated tool name or argument as trusted code. The runtime should accept only registered operations with validated inputs. It should reject unsupported actions rather than attempting to improvise a request from the model's text.
The model also should not be the final authority on success. A business action is complete when the application or external system confirms it under the operation's contract. The assistant can then explain that confirmed result to the user.
Start with the business action catalogue
List the operations the assistant needs in language that a process owner understands. Search orders, retrieve shipment status, prepare a customer reply, and send an approved message are distinct capabilities with different consequences.
Classify each capability by its access and effect. Reading a public product description differs from reading a private customer record. Preparing a draft differs from changing an address or releasing a refund. This classification should influence credentials, review, and logging.
Remove tools that are not needed for the initial use case. A general-purpose HTTP client may appear flexible, but it makes allowed destinations and actions harder to inspect. Narrow tools give both the application and the model a clearer operating boundary.
Assign an owner to each operation contract. The owner should understand its validation, permissions, rate limits, failure modes, and recovery procedure. This is especially important when several internal teams maintain the APIs involved in one agent workflow.
Preserve the user's permission context
An assistant acting for a user should not silently gain access that the user lacks. Establish the authenticated actor and relevant organisation or tenant, then enforce resource-level permission checks at the service that owns the data.
Passing a customer identifier from the model is not enough. The server must verify that the actor may access that customer and perform the requested operation. Apply the same checks to searches, exports, bulk actions, and individual record reads.
For scheduled automation, define the service identity and its limited purpose. A background process may legitimately act without a person present, but that requires an explicit access model and ownership. Do not borrow an employee's broad account as an informal shortcut.
Keep credentials in the execution environment rather than placing them in prompts or tool descriptions. The assistant needs to know how to request an allowed operation; it does not need to see reusable secrets used by the integration.
Design tool inputs for unambiguous use
A useful tool has a clear purpose, a constrained schema, and predictable validation errors. Prefer stable identifiers for records and explicit fields for important choices. Ambiguous free-text parameters move business interpretation into a place that is difficult to test.
For example, a send-message operation can require a specific customer record, a verified channel, final message content, and an approved proposal reference. It should not accept only “tell them the order is late” and privately decide who “them” means.
Use enumerated choices where the domain is controlled, such as supported message channels or allowed status filters. Validate lengths, formats, ranges, and required combinations in application code. Return a clear error when the request does not satisfy the contract.
Document side effects in the tool description. The model should be able to distinguish a preview from a committed change, but the server must enforce that difference regardless of the description. Naming a tool safely does not make its implementation safe.
Return useful results without excessive data
Tool responses should provide enough information for the next decision without exposing entire internal records unnecessarily. A shipping lookup may need confirmed status, update time, and a tracking reference, not every customer attribute in the order database.
Use structured result states. Found, not found, forbidden, temporarily unavailable, and ambiguous are different outcomes. If all become an empty string, the model may fill the gap with an assumption or repeatedly call the same tool.
Include provenance that the interface can present. A record link, source system, and retrieval time can help users assess the answer. Do not reveal restricted record metadata in an error message to an actor who lacks access.
Treat free-text content returned by tools as data. A support note or external document can contain instructions aimed at the agent. It should not acquire authority merely because it arrived through a legitimate API response.
Choose a fixed workflow when the steps are known
If every valid request requires the same sequence, a conventional orchestrated workflow may be sufficient. The model can interpret the initial question or draft a response while application code controls the order of operations.
An agent becomes more relevant when the next useful lookup depends on what previous results reveal. Even then, define an allowed action set, a stopping condition, and a route to human assistance. Open-ended exploration is not automatically valuable in a business transaction.
Anthropic's effective-agents guidance distinguishes code-defined workflows from agents that dynamically direct their own process. Use that distinction to discuss where flexibility is actually needed, rather than labelling every API-connected feature an autonomous agent.
Keep deterministic calculations and policy checks outside generated reasoning. The assistant can explain why an order needs review, while tested application logic determines whether the proposed operation satisfies the rules.
Bind approval to a concrete operation
When approval is required, show the actual record, action, and relevant values. A user should understand the effect without reading the agent's entire conversation. “Send this message to this verified recipient” is more reviewable than “approve the next step.”
Store approval against the operation or proposal version. If the model changes the recipient, content, or affected record after approval, the earlier decision should not silently authorise the revised action.
Recheck permissions and current business state at execution. An order may have shipped, a customer may have changed contact preferences, or the approving user's role may have changed while the proposal waited.
Separate approval from authentication. Knowing who clicked a button does not establish that they can authorise every action. The execution service should enforce the appropriate role and scope for that specific operation.
Handle retries as a transaction design problem
A request can time out after the destination completed the action. If the assistant interprets every timeout as failure and tries again, it can create duplicate messages, orders, or other side effects.
Use a stable operation identifier and the destination's supported idempotency mechanism where available. Persist the intent and state of consequential operations so the runtime can investigate uncertain outcomes rather than relying on conversation memory.
Distinguish transport success from business acceptance. An API may accept a job that completes later. Return a pending state and provide a status lookup instead of telling the user that the final outcome is already complete.
For multi-system work, record each confirmed step. A customer record update and a message dispatch may succeed independently. Recovery should target the unfinished or failed step without repeating everything that already happened.
Put budgets around execution
An agent can repeat lookups or explore unproductive paths. Set limits on tool calls, elapsed time, cost, and returned data appropriate to the workflow. When a limit is reached, stop with an understandable result and an escalation route.
Respect API rate limits through the integration layer. Coordinate retries and concurrency so several agent runs do not overwhelm the same dependency. A model deciding independently when to retry is not a substitute for operational traffic control.
Use pagination and result limits deliberately. Returning an entire customer database for a broad search is unnecessary and potentially unsafe. Ask for clarification or narrow the query when the request is too ambiguous to identify an appropriate record.
OWASP's AI agent security guidance includes unbounded resource use among agent risks. Budget controls also improve ordinary reliability by ensuring that a confused run ends predictably rather than consuming resources indefinitely.
Make the trace useful to operators
Record the initiating actor, business goal, tool operation, validated arguments, authorisation result, and confirmed outcome. Redact secrets and unnecessary personal information. The trace should support investigation without becoming a second unrestricted business database.
Use correlation identifiers across the agent run and downstream services. An operator investigating one failed customer update should be able to find the relevant API call and destination record without searching unrelated conversations.
Log decisions made by the application separately from generated explanations. “Permission denied by the order service” is an enforceable result. “The assistant believed it lacked access” describes model behaviour and has a different evidential value.
Provide an exception interface for the business cases that need intervention. Missing account mappings and uncertain message delivery should be visible with ownership and next steps. A developer log alone is rarely enough for support staff to finish the work.
Test contracts and behaviour together
Test each API wrapper independently with valid, invalid, forbidden, missing, and duplicate inputs. Verify that permissions and validation hold even when the model supplies unexpected arguments. These controls should work without relying on a cooperative prompt.
Then evaluate full tasks with representative language and records. Include similar customer names, conflicting statuses, unavailable dependencies, and requests outside the assistant's authority. Check whether it asks for clarification or stops when it should.
Introduce adversarial text through the same channels the assistant will read, such as customer notes and retrieved pages. Verify that this material cannot expand tool access, redirect protected data, or authorise an unrelated operation.
Assess the final business state, not only the assistant's response. A reassuring completion message is a failure if the intended record was not updated. Conversely, a completed operation followed by a response timeout needs accurate recovery rather than a duplicate execution.
## Make search and record selection safe to repeat
An assistant often begins with a search rather than an exact record identifier. Search tools should define matching behaviour, result limits, and the information returned for disambiguation. Similar names must not become permission to select a record arbitrarily.
If several plausible records exist, ask the user to choose using appropriate identifying details. Preserve the selected stable identifier for the subsequent operation, then recheck access when it executes. Do not rerun a broad name search and assume the first result is still the same entity.
Keep pagination explicit. A response containing the first page should not be described as an exhaustive search unless the tool actually checked the complete relevant set. Return a continuation state or a reason to narrow the request.
These details can seem minor in a demonstration with a few sample customers. They become central when the assistant works against a large business system containing duplicates, historical records, and accounts with changing status.
Treat tool contracts as a product interface
The people maintaining a business API and those building the assistant should agree on compatibility expectations. Document required fields, supported states, error categories, and the meaning of completion. Include representative examples that can be checked automatically.
A tool wrapper can shield the agent from irrelevant provider detail, but it should not hide important uncertainty. If the destination accepts work asynchronously, the wrapper must preserve pending status and expose a way to confirm the outcome.
When replacing a provider, compare semantics rather than just field names. Two send-message endpoints may differ in whether success means accepted, queued, or delivered. The assistant's user-facing wording needs to follow the actual contract.
This is a useful reason to keep the integration boundary in maintained application code: changes can be reviewed and tested without relying on the model to discover them during a live task.
Plan for changes on both sides of the connection
Existing APIs evolve, and model behaviour changes. Version tool schemas and maintain representative fixtures so contract drift is visible. A renamed field or altered error response can change how the assistant chooses its next step.
Review model or prompt changes against the same business tasks before rollout. Better prose quality does not guarantee better tool selection or fewer unnecessary calls. Track those behaviours directly.
Keep the integration deployable and reversible as a maintained software component. Define who owns credentials, dependency upgrades, incident response, and evaluation data. These responsibilities remain necessary even if the first demonstration required only a few lines of code.
A strong starting point is one read-only task with clear identity checks and source-linked results. Once it works with ambiguous requests and failing dependencies, add a narrowly defined write operation with review, duplicate protection, and confirmed outcomes. That progression makes access useful without turning a broad language request into unrestricted authority.