DEV Community

Ghayath Abu Ghosh
Ghayath Abu Ghosh

Posted on

What makes an email API "agent-ready"? Lessons from building for AI coding agents

A year ago, most API documentation was written for a developer reading it in a browser. Today, a growing share of integrations are written by AI coding agents that read the docs first, then write the code. That changes what good documentation looks like.

At Arsel, an AI-first email marketing platform, we wrote our REST API docs to be handed directly to a coding agent. Here is what we learned about making an email API work well for agents, and why it matters even if your users are still humans.

Agents read everything, literally

Human developers skim. They jump to the endpoint they need, copy an example, and fill gaps from experience. Agents don't fill gaps reliably. If something is implied rather than stated, an agent may guess, and a wrong guess in email marketing can mean a broken template or a campaign sent to the wrong list.

So the first rule is to state the things humans usually infer:

  • Which fields are required and which are optional.
  • What happens on create versus update (full replace or partial update).
  • Units, formats and limits, such as date formats, maximum batch sizes and page sizes.
  • What a successful response looks like, not just the error cases.

Publish a machine-friendly index

Agents work best with a single, compact entry point that lists everything available. We publish an llms.txt file that indexes the documentation in plain text. An agent can read it once, understand the shape of the API, and fetch only the pages it needs.

If you maintain an API, this is one of the cheapest improvements you can make for AI-assisted development.

Schemas beat prose for complex objects

Email objects are deeply nested. A template has sections, blocks, styles and variables. An automation has triggers, waits, conditions and branches. Describing these in paragraphs invites mistakes.

Instead, expose schemas: a precise description of what a valid template, campaign, segment or automation looks like. In Arsel's MCP server, there are dedicated schema tools for templates, campaigns, segments and automations, and the recommended flow is always "read the schema, then create." Agents that follow this produce valid objects on the first attempt far more often.

Make dependencies explicit

In email marketing, objects depend on each other in a specific order:

  1. A verified sending domain.
  2. A contact list that sends from that domain.
  3. A template, published after review.
  4. A campaign that uses the list (or a segment) and the template.

Humans learn this order by clicking through a dashboard. Agents need it written down. Our docs and MCP instructions spell out the order and what to check at each step, for example that a list's sender must be verified before a campaign can send.

Safe defaults for irreversible actions

Sending email is irreversible. Good agent-ready APIs make the safe path the default:

  • Campaigns are created as drafts. Sending or scheduling is an explicit change.
  • Test sends to a specific address are a first-class operation, so agents can verify before going live.
  • Edits to a published template go back through review automatically.

These defaults protect users from an agent that misunderstood a request, and they make it easy to keep a human in the loop.

Predictable errors

Agents recover well from errors when the errors are predictable. We use a small set of error codes, like validation failures, not found, forbidden, plan limits and rate limits, and validation messages start with the field name. An agent that gets validation_failed: from_email ... knows exactly what to fix.

Rate limits are documented with clear numbers and a retry time, so agents can back off instead of hammering the API.

Batch where it matters

Agents often need to import or update many records. A batch endpoint for subscribers, with a clear maximum per call, is far better than an agent looping thousands of single requests. For very large imports, we point users to the dashboard import instead, which is honest about where each tool is the right choice.

REST and MCP, side by side

There are two ways AI touches an email platform today:

  • Coding agents write integrations against the REST API, for example sending lifecycle emails from a SaaS product's own events.
  • Assistants like Claude and ChatGPT act directly through an MCP server, for example building a campaign from a chat request.

Arsel supports both. The REST API is documented at docs.arsel.ai, and the MCP server is at https://api.arsel.ai/mcp. Keeping the two consistent, with the same objects, names and rules, means what an agent learns in one applies to the other.

Why this helps humans too

Everything that makes docs agent-ready also makes them better for people: explicit requirements, clear schemas, documented order of operations and predictable errors. Writing for agents just removes the excuses for leaving things implied.

If you are building email into a product or an internal tool and want an API designed this way, you can explore Arsel and its documentation.

Top comments (1)

Collapse
 
foundrybell profile image
Foundry Bell •

drafts protect