2026-04-04
Build an Email-Powered AI Agent in 5 Minutes [2026]
What We’re Building
In this tutorial, you’ll build an AI agent workflow that can:
- Create its own email address
- Register on a website using that address
- Automatically extract the verification code
- Send a confirmation email back
Prerequisites
You need an agentsbase API key. Get one for free at agentsbase.net/login.
export AGENTSBASE_API_KEY="ak_your_key_here"
Step 1: Create a Mailbox
RESULT=$(curl -s -X POST \
-H "Authorization: Bearer $AGENTSBASE_API_KEY" \
-H "Content-Type: application/json" \
https://agentsbase.net/api/register -d '{}')
MAILBOX=$(echo $RESULT | jq -r '.mailbox')
TOKEN=$(echo $RESULT | jq -r '.token')
echo "Agent email: $MAILBOX"
Your agent now has an address like swift-fox-1234@agentsbase.net.
Step 2: Use the Email for Registration
Have your agent fill in registration forms using $MAILBOX as the email. Then wait for the verification code:
SINCE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
# ... agent submits registration form ...
CODE=$(curl -s -H "Authorization: Bearer $TOKEN" \
"https://agentsbase.net/api/code?to=$MAILBOX&timeout=55&since=$SINCE" \
| jq -r '.code')
echo "Got verification code: $CODE"
Step 3: Send a Confirmation
curl -s -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
https://agentsbase.net/api/send \
-d '{"from":"'$MAILBOX'","to":["admin@example.com"],"subject":"Registration Complete","text":"Agent registered successfully with code '$CODE'"}'
MCP Alternative
If your agent runs in Claude Code, skip the API calls entirely. Add agentsbase as an MCP server and your agent can use natural language to manage emails:
claude mcp add agentsbase-mcp -e AGENTSBASE_API_KEY=ak_xxx -- npx -y agentsbase-mcp
Then just ask: “Create a mailbox and wait for a verification code.”
Frequently Asked Questions
What programming languages work with agentsbase?
Any language that can make HTTP requests works with the REST API. The TypeScript SDK provides native support for Node.js and Bun. Python, Go, Ruby, and other languages work directly with the API.
Is there a rate limit on the agentsbase API?
Yes. The free tier allows 500 sends and 1,000 receives per month. Pro users get 5,000 sends and 10,000 receives. Rate-limited requests return a 429 status with upgrade information.
Can I use webhooks instead of polling for new emails?
Yes. agentsbase supports webhook subscriptions. You can register a webhook URL to receive real-time notifications when new emails arrive, eliminating the need for polling.