Designing APIs for AI Agents: What Should Change, and What Should Stay? Lucas Suárez, writing for EkLine, argues that teams facing unreliable AI agent callers should fix their shared HTTP API contract before building agent-specific surfaces, making defaults explicit, echoing effective values, adding idempotency keys and stable error types, and documenting recovery actions. The piece recommends against wholesale rewrites, agent-only parallel APIs, and replacing HTTP with MCP, noting the hypothesis that most agent failures stem from unclear API behavior lacks public study evidence. Originally written by Lucas Suárez for EkLine https://ekline.io/blog/designing-apis-for-ai-agents . Some of your API's callers are now agents. One times out on a POST and sends it again without knowing whether the first one landed. Another accepts a default nobody told it about. A third gets an error written for a person, reads the prose, and guesses. The pressure that follows is "redesign the API for agents." That redesign touches developers who integrate by hand, the logs support debugs from, and your compatibility promises. You have to decide where to spend first. Our answer: fix the shared API first. Make its behavior explicit, make the effective values of each call visible, and write a recovery contract that says which errors to fix, which to wait out, and when to stop. Fund an agent-specific surface only when a measured task still fails after that. We found no public study showing that most agent failures have these causes, so that part is our hypothesis. The vendor reports here describe many such failures. Retry-After header says when to come back. Whether a POST is safe to send again depends on method semantics or on deduplication such as an idempotency key. "Agent" covers at least three caller shapes, with different tools, context budgets, and retry logic. A fix in the HTTP contract reaches all three shapes. A fix in the MCP layer reaches only the third, which is why the contract comes first. | Call | What | Why | |---|---|---| | Keep | Deterministic contracts | Both callers build on documented behavior. | | Keep | Security and scopes | Give agent callers the same scope model as human integrations. | | Keep | Sensible, documented defaults | They give people the shortest path to the common case. | | Keep | Compatibility and versioning | Existing integrations keep working while the contract improves. | | Change | Consequential defaults | Echo the effective values in the response so a caller can check them. | | Change | Schemas and discoverability | Strict request schemas and errors that point at the failing field. | | Change | Error details | A stable problem type and a documented next action for each type. | | Change | State transitions | Slow work returns an operation with an explicit state. | | Avoid | Wholesale rewrites | They risk every human integration to fix problems nobody measured. | | Avoid | Agent-only parallel APIs without evidence | Two surfaces to version, secure, and debug. | | Avoid | Rules such as "remove all defaults" or "expose every parameter" | No source here tests them, and they push cost onto every caller. | | Avoid | Replacing the API with MCP | Curl, CLI, and SDK callers still use HTTP. | The first round of work goes into the change rows, on the surface every caller shares. Defaults drew the sharpest disagreement in a Hacker News thread on Freestyle's agent API post https://news.ycombinator.com/item?id=48894874 . One commenter noted that "the API designer is also making the parameters they think should be used the most have the least resistance." The post's author replied: "im not opposed to good defaults, i just believe they should be explicit." Explicit defaults are what the change rows ask for. The status quo is the baseline: keep the API, then wrap it one to one as MCP tools or rely on SDK retries. | Option | What changes | Evidence in the sources | Risk to human callers | Fits when | |---|---|---|---|---| | Status quo: one-to-one MCP wrapper or SDK retries | Nothing in the contract | Webflow's starting point, which it found "overly chatty" | None new | Agent callers already finish their tasks | | Shared API made explicit | Errors, idempotency, effective values, state | Guides assert it without tests; our local service checks the contract only | Low: humans get the same fixes | Failures trace to unclear behavior or recovery | | Intent-shaped tool layer over the API | Adds task-level tools | Webflow session analytics; SpecterOps design notes without measurements | Low while the API underneath stays | Simple tasks take many tool calls | | One HTTP surface for the weakest client, MCP as fallback | GET-friendly flows and visible instructions | Hookdeck's own tests, mostly on its own product, with a brief comparison against other webhook testers | Hookdeck designed it to work as well for humans | Callers are fetch tools on a narrow flow | | Separate agent-only API | A parallel surface | ASAPP lists it https://docs.asapp.com/generativeagent/configuring/connect-apis/designing-apis-for-generativeagent , but says "Most customers choose the second approach," a shared API undated, no count | High: humans "work around it" | No source here shows a case | No row has a benchmark behind it; the evidence column records what each source reports, mostly about its own product. In Freestyle's opinion post on agent APIs https://www.freestyle.sh/blog/opinion/designing-apis-for-agents , Mika Sagindyk, co-founder of 2027.dev, writes that "Unlike humans, agents follow instructions literally, so a vague or wrong error makes them spiral instead of recover." RFC 9457 https://www.rfc-editor.org/rfc/rfc9457.html , the Standards Track RFC that obsoletes RFC 7807, already defines the format. An actionable error carries five things: type URI the problem type's primary identifier; without one, the type is about:blank . errors array with a pointer such as /age . detail , and the status member is "only advisory." Branch on the type. recovery action member A retry hint answers only when to come back. For a POST, safety to repeat depends on method semantics or deduplication. The 429 status comes from RFC 6585 https://www.rfc-editor.org/rfc/rfc6585.html . It means a caller sent too many requests in a given time, and the response may include Retry-After . In RFC 9110 https://www.rfc-editor.org/rfc/rfc9110.html , a 503 signals temporary overload or maintenance, and Retry-After suggests how long to wait. Neither says whether the first request had an effect. GitHub's rate limit docs https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api spell out the timing, from x-ratelimit-reset to a cap on the number of retries. An agent's runtime its harness may not follow the hint at all. Hookdeck's endpoint returned 503 with Retry-After until an event landed. "The harness backgrounded it, and the session ended before the event arrived." RFC 9110 calls a method idempotent when several identical requests have the same intended effect on the server as one. PUT, DELETE, and safe methods qualify; POST does not. The RFC says a client "SHOULD NOT automatically retry a request with a non-idempotent method unless it has some means to know that the request semantics are actually idempotent, regardless of the method, or some means to detect that the original request was never applied." After a timeout, the client cannot tell whether the server applied the request. An idempotency key lets the server recognize the resend. The Idempotency-Key header is not an RFC. It is an Active Internet-Draft https://datatracker.ietf.org/doc/draft-ietf-httpapi-idempotency-key-header/ in the IETF httpapi working group, now draft -08, revised on 2026-10-22. Draft -08 https://datatracker.ietf.org/doc/html/draft-ietf-httpapi-idempotency-key-header-08 answers a missing key with 400, a key reused with a different payload with 422, and a request that arrives while another with the same key is processing with 409. Google's AIP-155 https://google.aip.dev/155 uses a request id field and lets APIs "choose any reasonable timeframe for honoring request IDs." Stripe's API v1 shows the limits. Its API reference https://docs.stripe.com/api/idempotent requests says Stripe stores the status code and body of the first request with a key once the endpoint starts running, and returns them to every retry with that key, including 500 errors. Keys can be pruned once they are at least 24 hours old, and a key reused with different parameters gets an error. Its error handling guide https://docs.stripe.com/error-low-level adds the recovery rules. On a 409 for a request still running, wait and resend with the same key and parameters, because a new key can start a second operation. A 500 leaves the outcome indeterminate. Past the 24-hour window, the guide is direct: "If the outcome is still unknown after that window, don't retry with either the old key or a new one." From there, a lookup or a person decides. We wrote a small test service for this post. It is an illustrative export service: POST /v1/exports creates an export job, requires an Idempotency-Key header, validates the body, and returns RFC 9457 errors. The service, the problem type URIs under https://api.example.com/problems/ , the keys, and the ids are all illustrative. Its seven tests passed on 2026-11-09 with Python 3.12.16 and pytest 9.1.1. An invalid format gets a problem the caller can branch on, a pointer to the field, and a request id instead of a stack trace: POST /v1/exports Idempotency-Key: 4f6c1d2e-invalid {"dataset": "invoices-2026-10", "format": "xlsx"} HTTP/1.1 422 Unprocessable Content Content-Type: application/problem+json { "type": "https://api.example.com/problems/validation-error", "title": "Your request is not valid.", "status": 422, "errors": { "detail": "must be 'csv' or 'json'", "pointer": " /format" } , "request id": "req 0001" } A valid request gets a 202 that echoes the effective dataset and format and points to an operation: POST /v1/exports Idempotency-Key: 9b2e7a10-export {"dataset": "invoices-2026-10", "format": "csv"} HTTP/1.1 202 Accepted Content-Type: application/json Location: /v1/operations/op 0001 { "id": "op 0001", "state": "pending", "dataset": "invoices-2026-10", "format": "csv" } The test service rejects the same key with a different body, using the status and title from the example in draft -08: POST /v1/exports Idempotency-Key: 9b2e7a10-export {"dataset": "invoices-2026-10", "format": "json"} HTTP/1.1 422 Unprocessable Content Content-Type: application/problem+json { "type": "https://api.example.com/problems/idempotency-key-reused", "title": "Idempotency-Key is already used", "status": 422, "detail": "This key was sent with a different body. Use a new key for a new export.", "request id": "req 0003" } The tests run this client, shown complete and unedited: python import json import time import urllib.error import urllib.request PROBLEMS = "https://api.example.com/problems/" WAIT AND RESEND = { PROBLEMS + "temporarily-unavailable", PROBLEMS + "request-in-progress", } class FixTheRequest Exception : """A permanent error. Resending the same request will fail the same way.""" class OutcomeUnknown Exception : """Retries are used up. Look up the result or ask a person before acting again.""" def create export base url, body, key, attempts=4, timeout=2.0, max wait=5 : data = json.dumps body .encode for in range attempts : request = urllib.request.Request f"{base url}/v1/exports", data=data, method="POST", headers={"Content-Type": "application/json", "Idempotency-Key": key}, try: with urllib.request.urlopen request, timeout=timeout as response: return json.load response except TimeoutError: continue outcome unknown: resend the same key and the same body except urllib.error.HTTPError as error: problem = json.load error if problem.get "type" not in WAIT AND RESEND: raise FixTheRequest problem time.sleep min int error.headers.get "Retry-After", "1" , max wait raise OutcomeUnknown key The client branches on the problem type , never on detail . It waits out only two types, temporarily-unavailable 503 and request-in-progress 409 ; every other HTTP error raises FixTheRequest . The client encodes the body once and never changes the key, so a resend is the same request. Waits follow Retry-After , capped at max wait , and the loop stops after attempts with OutcomeUnknown . The timeout path from the test service. The same key returns the original job; a new key creates a second export. The timeout test is the hard case. The service records the first POST's work but sends its response 2 seconds late, and the client times out at 1 second. The client resends the same key and the same body. The first request is still running, so the service answers 409 request-in-progress with Retry-After: 1 . After waiting, the resend gets the stored 202 with the same operation id, op 0001 , and one export exists. A second test resends with a fresh key after the same timeout, as a blind retry would, and gets a second export. If the attempts run out, the client raises OutcomeUnknown and stops: look up the result or ask a person. The tests cover one local, illustrative service. The client does not resend invalid input. It resends after a 503 only after Retry-After , a bounded number of times. The same key and body after a timeout return the original job. The service rejects the same key with a different body. A fresh key creates a duplicate. We also broke the code on purpose, and the tests caught each change: removing deduplication fails two tests, resending every error fails two, and using a fresh key after a timeout fails one. The test service does not show agent success rates, real network partitions, key expiry windows, concurrency at scale, persistence across restarts, or any vendor's behavior. It has no result lookup either. The only read is GET /v1/operations/{id} by operation id, so a caller that never received the id cannot find its job. That is the gap OutcomeUnknown hands to a person. Google's AIP-151 https://google.aip.dev/151 says it is better "to return some kind of promise to the user and allow the user to check back in later" than to block. "A good rule of thumb is 10 seconds." The created resource "should indicate that it is not usable, generally with a state enum." The test service's 202, Location header, and "state": "pending" follow that shape. Pagination follows the same rule as defaults our recommendation : return the effective page size and an explicit next cursor, so a caller can tell a short page from the last one. For auth, keep one scope model for both callers and keep scopes narrow. Delegated access for general-purpose agents has its own problems, covered in our post on OAuth for AI agents https://ekline.io/blog/oauth-for-ai-agents . Agent failures can be quiet. Webflow's MCP observability found "a silent error affecting more than 10% of sessions" while its infrastructure looked healthy. Webflow gives no sample size or date range. Logging by problem type and request id, per task, surfaces these failures and gives a person the exact call to debug. Task tools carry a tradeoff. Webflow moved to tools shaped around intents rather than endpoints, then hit what it calls "tool explosion": its platform supports too many valid workflows to give each one its own MCP tool. SpecterOps https://specterops.io/blog/2026/07/28/designing-an-mcp-server-for-ai-agents-bloodhound-hunter/ puts it this way: "APIs are allowed to be implementation-shaped because their callers already know what they are doing. MCP tools should be intention-shaped." A task tool cuts calls but can hide a rule the caller needs, such as an export being asynchronous, so expose those rules in the tool. The strongest objection: agents are a new caller class and need an MCP server or a separate agent API now. Freestyle's founder, Ben Swerdlow, writes "Defaults are bad." and argues an agent should fill in every field. It is an opinion with no test method. Webflow says "APIs designed for developers don't work for agents." Hookdeck reports results from a few hundred runs across models and harnesses. Visible instructions on the page decided whether agents found its wait endpoint: 100% of the time with them, 0% without. Wording also cut both ways for Hookdeck. When it told Codex it was fine to stop and report back, Codex's delivery rate dropped from 8/10 to 1/10. Some models still did not complete the HTTP flow. For models that doubted they could follow it, Hookdeck says a dedicated MCP tool "would have really helped it scored 100% in our tests ." These are Hookdeck's own tests, mostly on its own product, and the 100% and 0% figures come without a run count. The reports show that some agents need a differently shaped layer to call. None of these reports describes replacing the human API. Webflow and SpecterOps describe changes to an MCP layer. Hookdeck kept one surface "designed to work just as well for an agent as it does for a human." freeCodeCamp's guide https://www.freecodecamp.org/news/how-to-design-apis-for-ai-agents/ says "MCP isn't a substitute for good API design." The objection holds for the layer agents call, funded after the shared contract works. The plan sets no expected numbers, and the vendor figures here are not targets. Pick one agent integration task that failed in your logs or support queue. Trace it to the hidden default, the unclassified error, or the unsafe resend. Fix that path on the shared API, then run the same task again with the same callers before you fund a broader redesign. For a written recovery contract to compare yours against, read Stripe's advanced error handling guide https://docs.stripe.com/error-low-level . Change the shared API first: visible effective values, RFC 9457 errors with stable types, and documented recovery rules. Add an agent-specific layer only when a measured task still fails. Only for a resend with the same key and body inside the window the server honors. Stripe API v1 replays stored 500 errors, can prune keys after 24 hours, and says not to retry with either key once an outcome stays unknown past the window. Possibly, as a layer over a clear HTTP contract. Hookdeck says a dedicated MCP tool would have helped models that doubted they could follow its HTTP flow; the tool scored 100% in its tests. For the interface tradeoffs, see MCP vs CLI for AI agents https://ekline.io/blog/mcp-vs-cli-for-ai-agents .