Skip to content

Blog

Designing APIs for AI Agents: What Should Change, and What Should Stay?

Agents misread defaults, errors, and retries. Fix the shared contract first: visible effective values, RFC 9457 errors, and a tested recovery path for timeouts, then fund an agent-specific layer only where a measured task still fails.

Diagram: a human developer and an agent caller (HTTP, SDK, or tools) both call one API contract with effective values shown, typed errors, and safe resend rules.
Published on
Read time
16 min

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.

TL;DR

  • Keep deterministic contracts, scopes, documented defaults, and versioning. Change what an agent cannot see: effective values, error details, state, and recovery rules.
  • A 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.
  • Idempotency keys bound the risk of a resend. Keys can expire, some APIs (Stripe's API v1, for one) replay stored errors, and an outcome that stays unknown needs a lookup or a person.
  • Build an agent-specific tool layer when a measured task still fails on the improved API, and build it on top of that API.

Start with which agent is calling

"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.

Keep, change, avoid

CallWhatWhy
KeepDeterministic contractsBoth callers build on documented behavior.
KeepSecurity and scopesGive agent callers the same scope model as human integrations.
KeepSensible, documented defaultsThey give people the shortest path to the common case.
KeepCompatibility and versioningExisting integrations keep working while the contract improves.
ChangeConsequential defaultsEcho the effective values in the response so a caller can check them.
ChangeSchemas and discoverabilityStrict request schemas and errors that point at the failing field.
ChangeError detailsA stable problem type and a documented next action for each type.
ChangeState transitionsSlow work returns an operation with an explicit state.
AvoidWholesale rewritesThey risk every human integration to fix problems nobody measured.
AvoidAgent-only parallel APIs without evidenceTwo surfaces to version, secure, and debug.
AvoidRules such as "remove all defaults" or "expose every parameter"No source here tests them, and they push cost onto every caller.
AvoidReplacing the API with MCPCurl, 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. 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 options side by side

The status quo is the baseline: keep the API, then wrap it one to one as MCP tools or rely on SDK retries.

OptionWhat changesEvidence in the sourcesRisk to human callersFits when
Status quo: one-to-one MCP wrapper or SDK retriesNothing in the contractWebflow's starting point, which it found "overly chatty"None newAgent callers already finish their tasks
Shared API made explicitErrors, idempotency, effective values, stateGuides assert it without tests; our local service checks the contract onlyLow: humans get the same fixesFailures trace to unclear behavior or recovery
Intent-shaped tool layer over the APIAdds task-level toolsWebflow session analytics; SpecterOps design notes without measurementsLow while the API underneath staysSimple tasks take many tool calls
One HTTP surface for the weakest client, MCP as fallbackGET-friendly flows and visible instructionsHookdeck's own tests, mostly on its own product, with a brief comparison against other webhook testersHookdeck designed it to work as well for humansCallers are fetch tools on a narrow flow
Separate agent-only APIA parallel surfaceASAPP lists it, 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.

Errors an agent can act on

In Freestyle's opinion post on agent APIs, 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, the Standards Track RFC that obsoletes RFC 7807, already defines the format. An actionable error carries five things:

  1. A stable type. RFC 9457 makes the type URI the problem type's primary identifier; without one, the type is about:blank.
  2. Where it failed. The RFC's example 422 has an errors array with a pointer such as #/age.
  3. What failed, for a person. Consumers should not parse detail, and the status member is "only advisory." Branch on the type.
  4. The next actions. Document them per type, since consumers should not dereference type URIs automatically. One guide adds a field for it: a recovery_action member.
  5. A request id a person can search for, with no secrets or stack traces. The RFC warns against exposing details "such as a stack dump available through the HTTP interface."

Why a retry hint does not make a resend safe

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. It means a caller sent too many requests in a given time, and the response may include Retry-After. In RFC 9110, 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 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 in the IETF httpapi working group, now draft -08, revised on 2026-10-22. Draft -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 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 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 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.

One request, one error, one recovery path

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:

http
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:

http
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:

http
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.

Diagram: after a POST times out with an unknown outcome, resending with the same key and same body gets a 409, waits, then returns the original job, op_0001, so one export exists. Resending with a new key creates two exports. Illustrative. (opens the full-size image in a new tab)
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.

What the test service proves and what it does not

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.

Long-running work, auth, and observability

Google's AIP-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.

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 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 case for a separate agent surface

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 says "MCP isn't a substitute for good API design." The objection holds for the layer agents call, funded after the shared contract works.

Test before you fund a redesign

  1. Pick a few realistic tasks, such as creating a resource, recovering from a rate limit, and finishing a long-running job.
  2. Run the same tasks with human developers and with each agent caller shape you serve, across more than one model and harness.
  3. Track task success, incorrect side effects, recovery after an error, calls and cost per completed task, and whether a person can diagnose a failure from the request id.
  4. Change one part of the shared contract and run the same tasks again.
  5. Fund an agent-specific layer for the tasks that still fail.

The plan sets no expected numbers, and the vendor figures here are not targets.

Where to start

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.

FAQ

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.


Sources


Read more about

Blog

What ChatGPT, Claude and Perplexity cite when recommending developer tools: a 1,160-citation study

·9 min read

We asked ChatGPT, Claude and Perplexity 10 developer-tool questions 5 times each and sorted the 1,160 citations behind their answers. ChatGPT cited vendors' own pages; Claude and Perplexity mostly cited "best X" lists and comparison pages.

Blog

More than blog posts: the EkLine Marketing Agent now drafts battlecards, positioning and launch plans

·5 min read

The EkLine Marketing Agent now takes on any marketing task. It starts from the goal, reads your connected tools before the web, and drafts battlecards, positioning, launch plans, web pages and more in your company's voice.

Blog

How to track whether ChatGPT and Claude recommend your developer tool

·10 min read

Business Hub counts mentions and GEO trackers score visibility. Neither says whether ChatGPT or Claude put your developer tool on the shortlist. How to choose a measure, and how to judge recommendations with a written rule.

Blog

ChatGPT Business Hub counts mentions, not recommendations

·7 min read

OpenAI's Business Hub shows how often ChatGPT references your website and sends clicks. It cannot tell a developer tool company whether ChatGPT recommends it. What it counts, what it leaves out, and what to track next to it.

Blog

EkLine vs Mintlify Autopilot: do you need both?

·10 min read

Mintlify Autopilot drafts docs after code merges. EkLine checks the code PR before merge, comments on docs PRs in CI, keeps your help center current, and shows whether AI assistants recommend you. Here is when to run Autopilot alone, EkLine alone, or both on one Mintlify site.

Blog

What Is Agent Dreaming, and When Should You Use It?

·14 min read

Agent dreaming is offline upkeep of an agent's saved memory between tasks. When search over past sessions is enough, when to adopt dreaming, and how to test a reviewed candidate memory on your own tasks before you trust it.