For Agents
For agents that sign themselves up programmatically, no Console or dashboard needed. The agent registers itself using an email you provide and receives an API key in response. This flow is for first-time users only: human email addresses already signed up with AgentMail will not work here.
Sign up
The agent registers itself using the human email you provide and gets back an API key, inbox ID, and organization ID. An OTP is sent to that email.
npm install -g agentmail-cliagentmail agent sign-up \--human-email [email protected] \--username my-agent
The sign-up endpoint is idempotent. Calling it again with the same email rotates the API key and resends the OTP if expired.
No human email yet? Leave human_email out to get a receive-only inbox, then attach a human later with POST /v0/agent/human, or, for a US-region inbox, have your human claim it at console.agentmail.to/claim with the API key. Share the key only with your human, over a channel you already use with them, never by email. See Sign up without a human email.
Verify with the OTP
Check the human’s email for a 6-digit OTP code and verify to unlock full permissions.
export AGENTMAIL_API_KEY="am_..." # from the sign-up responseagentmail agent verify --otp-code 123456
Create an inbox and send an email
With the API key from sign-up, the agent can create inboxes and send mail on its own.
# create an inboxagentmail inboxes create# send an email (replace <inbox_id> with the id from above)agentmail inboxes messages send \--inbox-id <inbox_id> \--to [email protected] \--subject "Hello" \--text "Hello from my agent!"
For Humans
For developers who want to try AgentMail from the Console.
Sign up and get an API key
Go to the AgentMail Console, create an account, and generate an API key from the dashboard.
Signing up is free: 3 inboxes and 100 emails per day, no credit card required.

Store your API key
Create a .env file in your project root and add your key:
AGENTMAIL_API_KEY=am_...
We recommend using environment variables to keep your keys secure.
Install the SDK
Install the AgentMail SDK using your preferred package manager. We’ll also
use a library to load the environment variable from the .env file.
pip install agentmail python-dotenv
Create an inbox and send an email
Create a new file (e.g., quickstart.py or quickstart.ts) and add the
following code. This script initializes the AgentMail client, creates a new
inbox, and sends a test email.
import osfrom dotenv import load_dotenvfrom agentmail import AgentMail# load the API key from the .env fileload_dotenv()api_key = os.getenv("AGENTMAIL_API_KEY")# initialize the clientclient = AgentMail(api_key=api_key)# create an inboxprint("Creating inbox...")inbox = client.inboxes.create() # domain is optionalprint("Inbox created successfully!")print(inbox)# send an email from the new inboxclient.inboxes.messages.send(inbox.inbox_id,to="[email protected]",subject="Hello from AgentMail!",text="This is my first email sent with the AgentMail API.",)
The domain parameter is optional. If not provided, AgentMail will
use the default @agentmail.to domain. Every plan, including Free, includes at least one custom domain; see how to set one up.
Run the code
Execute the script from your terminal.
python quickstart.py
You should see the details of your newly created inbox printed to the console. Congratulations, you’ve successfully created your first AgentMail inbox!
Copy for Cursor / Claude
Copy one of the blocks below into Cursor or Claude for a complete, working AgentMail integration. Each block includes setup, API reference, error handling, rate limiting, and idempotency guidance.
"""AgentMail Python Quickstart — copy into Cursor/Claude for instant setup.Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.Agent sign-up (no API key needed):- agent.sign_up(username, human_email?) — returns api_key, inbox_id, organization_id; without human_email the inbox is receive-only- agent.attach_human(human_email) — attach a human later; emails them an OTP- agent.verify(otp_code) — verify with OTP sent to human_emailAPI reference:- inboxes.create(request=CreateInboxRequest(username?, domain?, display_name?, client_id?)) — client_id for idempotent retries- messages.send(inbox_id, to, subject, text, html?, cc?, bcc?, reply_to?, attachments?)- messages.list(inbox_id, limit?, page_token?, labels?) — receive emails; use extracted_text/extracted_html for reply contentErrors: SDK raises on 4xx/5xx. Inspect error.body.message or str(e).Rate limit: 429 with Retry-After header. Implement exponential backoff for retries.Idempotency: Pass client_id to inboxes.create() to safely retry without duplicates."""import osfrom dotenv import load_dotenvfrom agentmail import AgentMailfrom agentmail.inboxes import CreateInboxRequestload_dotenv()client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))# create inbox (client_id enables safe retries)inbox = client.inboxes.create(request=CreateInboxRequest(client_id="my-agent-inbox-v1"))# send emailtry:client.inboxes.messages.send(inbox.inbox_id,to="[email protected]",subject="Hello from AgentMail",text="Plain text body",html="<p>HTML body</p>",)except Exception as e:# handle validation, not found, rate limit (429), etc.print(f"Send failed: {e}")raise# receive messagesfor msg in client.inboxes.messages.list(inbox.inbox_id, limit=10).messages:print(msg.subject, msg.extracted_text or msg.text)
When receiving emails, messages include extracted_text and extracted_html
for reply content without quoted history.
Next Steps
You’ve created an inbox and sent your first email. Now set up your agent to receive and respond to incoming messages:
The fastest way to receive emails. No public URL or ngrok needed.
Get real-time HTTP notifications when emails arrive.
Build a complete conversational agent workflow.
Explore the full API with interactive examples.
Looking for a different language? Email us at [email protected] and we’ll get you set up.