Send API: How Email Sending APIs Work, and What Agents Need

A send API is an HTTPS endpoint that takes a structured request (sender, recipients, subject, body, attachments) and hands the message to a mail provider for delivery. For a notification or password reset, that is the whole job. For an AI agent, it is half of it: the agent also has to receive the reply, keep the thread intact and act on the new text. Qubrics provides agent mailboxes and message retrieval through its Mailbox API, and supports managed and connected providers through its Sending API.
This guide covers how a send request works end to end, where it goes wrong in production, and when a sending endpoint alone stops being enough.
TL;DR
- A send API replaces a raw SMTP session with one authenticated JSON request, then reports what happened through delivery events.
- "The provider accepted it" is not "it was delivered". Record API acceptance and delivery events separately.
- Agents need replies, so threading headers and inbound mail matter as much as the send call.
- Per-tenant identity, scoped keys, quotas and logs are easier to build in from the start than to retrofit.
- Qubrics offers dedicated agent mailboxes and lets you send through your own providers or its managed sending account.
Table of Contents
What a send API actually does
Email still travels over SMTP (Simple Mail Transfer Protocol), a text protocol designed in 1982. With plain SMTP your application opens a connection, authenticates with a username and password, and streams the message line by line. A send API wraps that in a single HTTPS request: JSON in, JSON out, and the provider converts the payload into the wire format for you.
That difference matters more than it first looks. With a REST call you get structured errors you can branch on, idempotent retries you control, and a response body you can store. With SMTP you manage sessions, ports and encoding, and you find out about most problems later, by bounce.
A typical send request carries:
- Sender identity: a verified address or domain you are allowed to send from.
- Recipients: to, cc and bcc.
- Content: subject plus plain text and HTML bodies.
- Attachments: inline as base64, or as an uploaded reference when files are large.
- Headers: most importantly for agents, the threading headers covered below.
The call returns quickly with an identifier. Delivery happens afterwards, and that gap is where most production surprises live.
From request to delivery: the five stages
1. Authenticate
Every request carries an API key. Keep it on the server, never in a browser or a prompt, and scope it to what the caller needs. An agent that only sends from one mailbox should not hold a key that can delete a whole workspace. The same applies to coding agents in Cursor, Claude Code or Codex: give them a scoped key, not your account key.
2. Validate the sender
Providers refuse mail from a domain you have not proved you own. That means publishing SPF, DKIM and DMARC records in DNS. SPF lists which servers may send for your domain, DKIM signs each message so tampering is detectable, and DMARC tells receivers what to do when either check fails. Our SPF, DKIM and DMARC setup guide walks through the records, and the notes on relaxed versus strict DMARC alignment explain why a mismatched From domain fails even when SPF passes.
One domain is a ten-minute job. Thirty sender domains, or one per customer, is a process. Qubrics verifies SPF, DKIM and DMARC records for custom domains. An agent can register an @myagent.mx inbox without setting up DNS. A human owner must approve sending.
3. Submit and get acceptance
The provider checks the request, queues the message and responds. This is acceptance. It tells you the payload was valid and the provider will try. It says nothing about the recipient's server.
4. Delivery attempt
The provider connects to the recipient's mail server. Outcomes include delivered, deferred (retry later), hard bounce (the address does not exist) and soft bounce (mailbox full, temporary refusal). A complaint can arrive later if the recipient marks the message as spam.
5. Receive the events
Providers report these outcomes through webhooks or an event feed. With Amazon SES, for instance, the usual pattern is separate SNS topics for bounces, complaints and deliveries attached to your verified identity. Your system should verify the webhook signature, deduplicate repeated events, and add suppressed addresses to a list so you never send to a hard bounce again.
The habit that saves the most pain: store the acceptance response and the delivery events as separate records. A dashboard that treats "accepted" as "delivered" will overstate success until a customer complains.
Where a plain send API stops
A transactional send endpoint is one-directional. That suits receipts and alerts. It breaks down the moment the message is a question and the answer arrives by email.
Consider what an agent has to do after sending:
- Receive the reply at an address that belongs to that agent or tenant.
- Match the reply to the original conversation.
- Read only the new text, not the quoted history of the last six messages.
- Respond in the same thread, so the recipient's client groups it correctly.
With a send-only provider, you assemble this yourself: an inbound parser, a webhook relay, a mailbox store, and often a Gmail OAuth connection bolted on to read replies. OAuth tokens expire, providers rate-limit or suspend automated mailboxes, and each piece has its own billing. Teams commonly end up maintaining four systems to do one job.
Threading is a header problem
Threading depends on the In-Reply-To and References headers. Open-source agent tooling documents the same approach: correlating a reply to its conversation using References or In-Reply-To, and including the sender address in the conversation key to reduce the risk of one sender hijacking another's thread. The practical rule for your own code is to set both headers on every reply, and to key conversations on thread plus sender rather than subject line alone.
Reading mail without parsing MIME
Raw email is MIME: nested parts, encodings, signatures and quoted history. Feeding that to a language model wastes tokens and invites mistakes. The Qubrics Mailbox API has a clean content endpoint with body-cleaning controls, and a raw body endpoint that returns text, HTML or both without cleaning. Reading the relevant reply text can reduce how much text the agent sends to a language model.
When an agent needs a mailbox, not just an endpoint
Use this as a quick test.
| Your agent... | A send endpoint is enough | It needs a persistent mailbox |
|---|---|---|
| Sends receipts, alerts, password resets | Yes | No |
| Waits for a customer reply | No | Yes |
| Handles a verification email for a browser agent | No | Yes |
| Triages inbound candidate, invoice or enquiry mail | No | Yes |
| Runs a long thread over days | No | Yes |
| Needs its own identity per tenant | Partly | Yes |
A Qubrics mailbox stores messages and threads. You can create a dedicated mailbox for an agent, customer, workspace or tenant on the shared @myagent.mx domain or a custom domain verified for sending and receiving. The Mailbox API covers messages, threads, folders, attachments, sender identities, quotas, usage and submissions.
These retrieval endpoints can help keep payloads small when an LLM pays per token.
GET /mailbox/messageslists messages with filters, sorting and cursor pagination.
- A count endpoint answers "how many" without returning rows.
- Search snippets return previews without pulling full bodies.
- Batch endpoints read, update or delete multiple messages in one call.
- Sync endpoints return changes since a prior state token, so an agent polls for changes instead of re-listing the inbox.
GET /mailbox/sessionreports supported features, state tokens and request limits.
That last pair replaces the IMAP polling loop many self-hosted assistants still run. If you want the full picture of what sits behind the mailbox, see our inbound mailboxes page.
Designing for many tenants
If you serve more than one customer, isolation is the design question that decides everything else. Per-tenant checklist:
- Identity: a separate sender address, and ideally a separate domain, per tenant.
- Keys: scoped credentials so one tenant's agent cannot read another's mail.
- Quotas: a per-mailbox cap so one runaway agent cannot burn the shared sending reputation.
- Logs: delivery logs and audit trails you can filter by tenant.
- Suppression: a bounce for one tenant should not silently block, or leak into, another's list.
- Offboarding: a safe way to remove a tenant's mailbox and data.
Our multi-tenant suppression and isolation checks go through the second half of that list in detail, and the multi-tenant email infrastructure page shows how the controls fit together in the product. Qubrics provides team-scoped API keys, delivery logs and team resource management. The Mailbox API reports mailbox quota usage and limits.
Outbound routing across providers
Sending from a single provider is a single point of failure, and cold or high-volume outbound teams hit provider limits quickly. Qubrics lets you connect Gmail, Outlook or a custom SMTP provider, or send through its managed Amazon SES account. Delivery groups route mail through groups of active providers.
That suits GTM engineers and agencies who keep client-owned sending accounts separate, and platform teams who want batch sending without being tied to a single vendor. The email sending API with provider failover page covers the routing options.
Wiring it into your agent stack
The integration surface depends on how you build:
- Frameworks and code: call the REST API or SDK from LangChain, CrewAI, the Vercel AI SDK, the OpenAI Agents SDK or AutoGen as an ordinary tool.
- MCP clients: See the MCP for AI agent builders page for agent integration context.
- Terminal and CI: a CLI is available for scripts, alerting and incident workflows.
- No-code: use webhooks to pass events to flows in tools such as n8n, Make and Zapier.
Whichever you choose, two habits pay off. Give the agent the narrowest tool you can: send, list, read. And never put the API key in the model's context. For background on what email delivery looks like from the marketing side, how email marketing works is a useful companion to the developer view here.
What it costs
See the pricing page for current plans and rates. A spreadsheet can help you estimate the monthly cost of connected outbound, managed sending, inbound delivery and storage.
A short perspective
We built Qubrics because every agent team we talk to ends up assembling the same stack: a sending provider, a Gmail OAuth workaround, a parser, a webhook relay and a separate bill for each.
Our view is that an agent's email should be treated as state, not as a stream of events. A dedicated mailbox gives the agent a real address and a place to keep threads and folders. The Mailbox API exposes quotas and usage, and the Management API provides delivery logs. Sending then becomes one capability of the mailbox rather than a separate product.
The send call is the easy part. The reliable part is what happens after it: threading the reply correctly, reading only the new text, routing the next message to the right agent, and failing over when a provider pushes back.
Getting started
Register an agent inbox on @myagent.mx. After its owner approves sending, send a message and read the reply through the Mailbox API. See the Qubrics product overview for custom domains and connected providers.
Sources
Recommended
Frequently Asked Questions
What is a send API?
It is an HTTPS endpoint that accepts a structured request describing an email and passes it to a mail provider for delivery. You authenticate with an API key, receive an identifier straight away and learn the final outcome through delivery events.
How is a send API different from SMTP?
SMTP is the underlying protocol: you manage a connection, credentials and message formatting yourself. A send API wraps that in one JSON request with structured responses and webhooks for bounces and complaints, which is easier to retry, log and secure.
Can an AI agent receive and reply to email through an API?
Yes, if the API provides inbound mail as well as sending. The agent reads new messages from its mailbox and sets the In-Reply-To and References headers when replying so the recipient’s email client can group the reply with the original message. Qubrics provides a Mailbox API and a Sending API.
Do I need a custom domain to start?
No. You can start with a Qubrics mailbox on the shared @myagent.mx domain. To receive mail under your own brand, verify a custom domain in sending and receiving mode.
How do I stop one tenant's bounces affecting another?
Give each tenant its own sender identity, quota, delivery logs and suppression list. When a tenant leaves, follow a defined offboarding step to remove its mailbox and data.