Your Robotomail API Quick Start to Autonomous Email
This API quick start guide shows you how to build autonomous email workflows for AI agents. Create accounts, send email, and handle inbound messages in minutes.

Getting an AI agent to use email shouldn't feel like you're fighting with ancient SMTP protocols. A true API quick start means creating a fully functional mailbox with a single command in under 60 seconds, ready to plug directly into frameworks like LangChain or CrewAI. This is about skipping the manual OAuth flows and getting straight to building autonomous send-and-receive workflows.
Your Fast Track to Programmatic Email for AI
Let's be honest: giving an AI agent email capabilities has always been a pain. The process usually involves wrestling with clunky SMTP servers, navigating manual OAuth consent screens, and writing a ton of boilerplate code just to get a basic connection. All that friction slows you down and distracts you from what you're actually trying to build—an intelligent agent.
Robotomail is an agent-native email infrastructure designed around one simple idea: give an agent a real, working mailbox with a single API call. No human-in-the-loop provisioning required.

Why an API-First Approach Is the Only Way
When we say API-first, we mean every single function—from creating an account to sending an email—is designed to be hit programmatically. This is non-negotiable for building scalable, autonomous systems. An agent should be able to provision its own tools.
Before you jump in, it's worth seeing how this approach stacks up against the old way of doing things.
Robotomail vs Traditional Email APIs a Quick Comparison
| Feature | Robotomail | Traditional Email APIs (e.g., SendGrid, Mailgun) |
|---|---|---|
| Mailbox Creation | Instant via a single API call | Manual setup or not supported |
| Onboarding | Agent self-onboarding capable | Requires human admin setup |
| Communication | Built for two-way conversations | Optimized for one-way sending |
| Inbound Handling | First-class feature (Webhooks, SSE, Polling) | Often a bolted-on "inbound parse" feature |
The difference is clear: traditional APIs were built to send notifications from an app. Robotomail was built for an agent to have a conversation within an app.
The goal is to remove all friction. We want you to integrate email into agent frameworks like LangChain or CrewAI immediately. This is your most direct route to building autonomous send-and-receive workflows.
If you want to see the initial commands in action, our docs have a detailed walkthrough. You can find it in our https://robotomail.com/docs/quickstart.
Getting Your Credentials Ready
Before your agent can send its first email, it needs its credentials. For most AI projects, this means grabbing API keys from your core providers. If you haven't done it before, this guide on how to get an OpenAI API key is a great place to start.
With your keys in hand, you can create your first Robotomail mailbox instantly. A simple REST or cURL command is all it takes to go from zero to a sending mailbox in seconds.
Alright, you've got a mailbox. Now let's make sure it actually works.
This is where a simple REST API beats wrestling with old-school SMTP libraries. Instead of a multi-step authentication handshake, you can fire off a complete email—subject, body, and all—with a single POST request.
It’s the fastest way to get that "hello world" moment, confirming your setup is good to go without getting stuck in a configuration rabbit hole.
The Anatomy of an Email Payload
To send an email, you just need to put together a simple JSON object. The great thing about this is that the payload is easy to read and build in any language, letting you stick with standard HTTP clients instead of hunting for a specialized email library.
Your request just needs a few key fields. Here’s the breakdown:
to: An array of strings. Each string is a recipient's email address.subject: A simple string for your email's subject line.text: The plain-text version of your email. This is essential for compatibility and for clients that block HTML.html: The HTML version of your body, where you can add rich formatting, links, and images.
A single POST request validates your entire setup almost instantly. This is by design. It gets you from setup to a successfully sent email in seconds, so you can move on to the interesting parts.
Ready-to-Run Code Examples
To get you sending even faster, here are some copy-paste examples for cURL and Python. Just drop in your own API key, mailbox ID, and recipient, and you'll see an email land in your inbox right away.
cURL
For a quick test straight from your terminal, cURL is perfect.
curl -X POST https://api.robotomail.com/v1/mailboxes/{MAILBOX_ID}/send
-H "Authorization: Bearer {YOUR_API_KEY}"
-H "Content-Type: application/json"
-d '{
"to": ["[email protected]"],
"subject": "Testing Robotomail API",
"text": "Hello from your new mailbox!",
"html": "
Hello from your new mailbox!
" }'Python with requests
If you're building in Python, the requests library makes this incredibly clean. Here’s how you’d structure the same request.
import requests import json
api_key = "{YOUR_API_KEY}" mailbox_id = "{MAILBOX_ID}" url = f"https://api.robotomail.com/v1/mailboxes/{mailbox_id}/send"
headers = { "Authorization": f"Bearer {api_key}", "Content-Type": "application/json" }
payload = { "to": ["[email protected]"], "subject": "Testing from Python", "text": "This is a test email sent via Python.", "html": "
This is a test email sent via Python.
" }response = requests.post(url, headers=headers, data=json.dumps(payload)) print(response.json())
And that's it. These examples give you a direct path to sending your first email programmatically. No fuss, no complex libraries. Just a simple, effective API call.
Getting Replies: Handling Inbound Email for Your Agent
An agent that only sends emails isn't really having a conversation. It’s just a notification bot. To build something that can actually manage tasks, respond to questions, or carry on a dialogue, it needs to receive, understand, and react to replies. This is where your agent goes from being a simple script to a truly interactive assistant.
Robotomail gives you three ways to handle inbound email: Webhooks, Server-Sent Events (SSE), and good old-fashioned Polling. Picking the right one is a key architectural decision that depends entirely on what your agent is doing. Does it need to reply instantly, or is checking for new mail every few minutes good enough?
Choosing Your Inbound Strategy
This first decision—how your agent listens for new messages—shapes how you'll build the rest of your logic. Once your mailbox is set up, the game shifts from provisioning to action, which means either sending or, more importantly, receiving email.

Here's the breakdown of your options:
- Webhooks: This is the most common, event-driven approach. When an email arrives, Robotomail just sends a POST request to a URL you specify. It's perfect if you need to trigger a specific workflow the moment a message lands.
- Server-Sent Events (SSE): For true real-time interaction, SSE creates a persistent connection from our server to your agent, pushing updates instantly. Think of it as an "always-on" connection for agents that can't afford any delay.
- Polling: The simplest of the three. Your agent just makes a GET request to the API every so often to ask, "Anything new?" It's a rock-solid choice for less urgent tasks or in environments where you can't (or don't want to) open up an inbound port for a webhook.
Don't Skip This: Securing Your Webhooks with HMAC
If you're going with webhooks, you absolutely have to verify that the requests are actually coming from Robotomail and not some bad actor. Robotomail includes an HMAC signature in every webhook request.
Validating the HMAC signature isn't just a good idea—it's mandatory for secure production systems. It proves the message came from us and wasn't tampered with.
The process is simple: you calculate a signature on your end using your webhook secret and the request payload, then compare it to the signature we send in the X-Robotomail-Signature header. If they match, you're golden. Our guide on how to receive and reply to emails programmatically has copy-pasteable code examples for this.
This kind of secure, developer-first API design is becoming the standard. The API Management Market is expected to hit USD 22.11 billion by 2031, growing at a 21.10% CAGR, according to a recent API market trends report from Mordor Intelligence. That growth is all about demand for APIs that are flexible and secure enough for modern applications, especially ones driven by agents.
Real-Time with SSE vs. Reliability with Polling
So, when would you choose SSE over polling? If your agent is a customer support bot that needs to provide instant answers, SSE is the obvious choice. By holding a connection open, your agent gets the message with almost zero latency, letting it fire back a reply immediately.
But don't write off polling. For a huge number of use cases, it's the right tool for the job. If your agent generates a daily report from inbound emails or processes messages in batches, checking every few minutes is perfectly fine. It's also simpler to implement and requires no open ports, which can be a big win. It's often the best place to start.
Integrating Custom Domains to Boost Deliverability
If you're building a real product, sending emails from a generic domain just won't fly. To build trust and make sure your agent’s messages actually land in the inbox, using your own custom domain is non-negotiable. This is the moment you move from a quick test to a production-ready system.
Using a custom domain is the single most effective way to signal to providers like Gmail and Outlook that your agent is a legitimate sender. Without it, you’re basically starting a new fight with spam filters every single time your agent sends a message.

Why Email Authentication Is a Must
Adding a custom domain is more than just swapping out the "from" address. It’s about proving your agent has the right to send on that domain's behalf. This is all handled through a set of email authentication standards that work together to shut down spoofing and phishing attempts.
- SPF (Sender Policy Framework): Think of this as a public guest list for your domain. It tells receiving servers which IP addresses are approved to send email for you.
- DKIM (DomainKeys Identified Mail): This adds a digital signature to your emails. The recipient's server uses it to verify the message wasn't tampered with on its way over.
- DMARC (Domain-based Message Authentication, Reporting, and Conformance): This is the rulebook. It instructs servers on what to do if an email fails the SPF or DKIM check—like sending it to spam or rejecting it outright.
Setting these up by hand is a notorious headache, often derailing what should be a simple api quick start. You're stuck generating keys, creating a bunch of very specific records, and then just waiting for them to propagate across the internet.
The good news is, platforms like Robotomail were built to handle this mess for you. When you add a custom domain, Robotomail automatically configures the necessary SPF, DKIM, and DMARC records, taking all the guesswork and manual labor out of securing your email.
Keeping Conversations in Context
Beyond authentication, the other big piece of the puzzle is maintaining context. When your agent is in a real back-and-forth dialogue, replies absolutely must be threaded correctly into the same conversation.
Robotomail takes care of this by managing conversation threading automatically. When your agent replies to an inbound message, the platform makes sure the right In-Reply-To and References headers are set. This small detail is what makes conversations easy for humans to follow in their email clients, grouping all the messages into one neat thread.
This automatic handling preserves the natural flow of a conversation, letting your agent act more like a human assistant and less like a disconnected bot. It means you can focus on your application's logic, not on manually tracking message IDs.
Common Pitfalls and Pro Tips for Agent Developers
Every developer hits a few walls when an AI agent moves from a slick demo to a real production system. This is especially true when your agent depends on external APIs for core skills like email.
Think of this section as our hard-won advice from building in this space. It’s a cheat sheet for skipping the most common snags we see developers run into, helping you build a more resilient system from day one.
Navigating Per-Mailbox Rate Limits
One of the first "gotchas" you’ll likely hit is API rate limiting. When an agent gets busy—sending a burst of emails or rapidly checking for replies—it can slam into usage caps without warning.
Robotomail uses per-mailbox rate limiting, which is a critical detail. If one of your agents gets a little too enthusiastic and hits its limit, it won't throttle the rest of your system. To handle this gracefully, your agent needs to implement exponential backoff with jitter in its error-handling logic. This simple strategy stops a throttled agent from hammering the API the second it becomes available again.
Securely Handling Email Attachments
Attachments add another layer of complexity. Your agent needs a way to upload and download files without hardcoding credentials or passing sensitive data around. The only sane way to do this is with presigned URLs.
- For uploads: Your agent should first call the API to get a secure, short-lived URL. It can then
PUTthe file directly to that URL. - For downloads: When an inbound email has an attachment, the API payload will include a presigned URL. Your agent uses that URL to download the file directly and securely.
This keeps your API tokens out of the file transfer process entirely. Access is temporary and scoped only to the specific file and action required.
This shift towards secure, scalable API interactions is part of a much larger trend. Cloud APIs are at the heart of modern application development, enabling the very architecture that AI agents depend on.
The growth here isn't just incremental; it’s a fundamental move toward cloud-native computing. The global cloud API market is projected to explode from USD 85.34 billion in 2026 to USD 773.73 billion by 2034, with a compound annual growth rate of 31.73%. For platforms enabling agent-native workflows, this growth creates massive opportunities as businesses seek modern infrastructure. You can explore the full forecast on cloud API market growth to see the data behind the trend.
Protecting Your Sender Reputation
Deliverability is everything. If your agent's emails land in spam, the whole workflow breaks down. A classic mistake is letting an agent repeatedly try sending to invalid or bouncing addresses. This is a huge red flag for email providers and a fast track to getting your domain blocklisted.
This is exactly what a suppression list is for. Robotomail manages this for you automatically. When an email hard-bounces, we add the recipient's address to a suppression list for your account. Any future attempts to send to that address, from any mailbox, will be blocked before they can damage your reputation.
It's one less thing you have to build and a key advantage for any api quick start project.
Frequently Asked Questions
When you're giving an AI agent email for the first time, a few questions pop up again and again. Here are the straight answers we give developers who are getting started, based on our experience building in this space.
What's the Easiest Way to Give an Agent Email?
Hands down, the fastest way is using an API-first platform. Forget about wrestling with complex email protocols or manual account setups. The right API lets you provision a fully functional mailbox with a single call.
From there, your agent can fire off emails with a simple POST request and listen for replies using webhooks. This completely sidesteps the nightmare of traditional SMTP libraries and the dreaded OAuth consent flows, letting you get a proof-of-concept running in minutes, not days.
How Much Do Programmatic Mailboxes Cost?
It varies, but you shouldn't have to pay anything just to start building. Most modern platforms offer a free tier that's more than enough for prototyping and early development.
For example, the Robotomail free plan gives you a mailbox, a daily sending limit, and a solid number of monthly sends to work with. Once your agent gets traction, you can move to paid plans that offer more, like:
- Multiple mailboxes for different agents or workflows
- Higher sending and receiving capacity
- Support for your own custom domains
Why Do I Need a Custom Domain?
Because sending from a generic, shared domain is one of the biggest red flags for spam filters. Using your own custom domain is non-negotiable if you want to build a good sender reputation and make sure your agent's emails actually reach the inbox.
A custom domain signals to providers like Gmail and Outlook that your agent is a legitimate sender. It's the difference between being a trusted source and getting automatically junked.
Platforms built for agent email make this painless. They'll often generate the required SPF, DKIM, and DMARC records for you—these are the technical handshakes that prove your agent has permission to send email from your domain.
Can My Agent Handle Attachments Securely?
Yes, as long as you use the right method. The most secure way to handle file uploads and downloads is with presigned URLs. This technique is critical because it means you never have to pass around API keys or other credentials during the file transfer itself.
When your agent needs to upload an attachment, it asks the API for a secure, one-time URL. It then uploads the file directly to that URL. The same logic applies to downloads; the API provides a temporary, secure link for the agent to grab the file. This keeps all file access temporary and tightly scoped to only the action needed.
Ready to give your AI agents the power of autonomous email? Robotomail provides the agent-native infrastructure you need, letting you provision mailboxes and manage conversations with simple API calls. Sign up and get started for free.