For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
contact@agentmail.ccDiscord
DocumentationAPI ReferenceKnowledge BaseChangelog
DocumentationAPI ReferenceKnowledge BaseChangelog
  • Get Started
    • Welcome
    • Introduction
    • Quickstart
  • Core Concepts
    • Inboxes
    • Messages
    • Threads
    • Drafts
    • Labels
    • Lists
    • Attachments
    • Pods
    • Permissions
  • Integrations
    • Agent Onboarding
    • Skills
    • MCP
    • CLI
    • Google ADK
    • OpenClaw
    • Replit
    • x402
    • MPP
    • LiveKit
    • Sim.ai
  • Guides
    • Sending & Receiving Email
    • IMAP & SMTP
    • Multi-Tenancy
  • Webhooks
    • Overview
    • Events
    • Setup Guide
    • Verifying Webhooks
  • WebSockets
    • Overview
    • Quickstart
  • Best Practices
    • Email Deliverability
    • Idempotency
  • Examples
    • Github Repo Agent
    • Auto Reply Agent
    • Smart Labeling Agent
    • Sales Agent (WebSocket)
    • Live AgentMail Examples
  • Resources
    • FAQ
    • Talon Reply Extraction
    • Community
    • Support
LogoLogo
contact@agentmail.ccDiscord
On this page
  • What is an Inbox?
  • The AgentMail Hierarchy
  • Core Capabilities
  • Metadata
  • Updating metadata
  • Inbox-scoped API keys
  • Copy for Cursor / Claude
Core Concepts

Inboxes

The foundation of your agent's identity and communication.
Was this page helpful?
Edit this page
Previous

Messages

The fundamental unit of communication for your agents.
Next
Built with

What is an Inbox?

People are used to the traditional Gmail limitations — only having one inbox. That’s of the past.

An Inbox is now a fully loaded, programmatically accessible API resource re-designed for the scale of AI Agents.

Think of it as being similar to a Gmail or Outlook account, but built API-first. Each Inbox has a unique email address and serves as the primary resource your agent uses to send and receive emails, giving it a first-class identity on the internet.

Unlike traditional email providers that are designed for human scale, AgentMail Inboxes are built to scale horizontally. You can create tens, hundreds, or even thousands of Inboxes for your agents on demand.

Psst! Rather than sending 1000 emails from 1 Inbox, sending 10 emails across 100 Inboxes actually improves deliverability! Read more about optimizing for deliverability here

The AgentMail Hierarchy

As the diagram below illustrates, your organization is the top-level container that holds all your resources. You can provision many Inboxes within your organization, each with its own Threads, Messages, and Attachments, allowing you to manage a large fleet of agents seamlessly.

AgentMail Organizational Hierarchy
1

Organization

Your organization is the highest-level entity. It acts as a container for all your Inboxes, Domains, and API keys, allowing you to manage everything in one place.

2

Inbox

An Inbox is a single, scalable “email account” for your agent. You can create thousands of Inboxes within your organization, each with its own unique email address.

3

Thread

A Thread represents a single conversation. It groups together all replies and forwards related to an initial email, keeping your interactions organized.

4

Message

A Message is an individual email. It contains the content, sender, recipients, and any associated metadata or Attachments. You can cc humans at any point in time to keep a “human-in-the-loop”

5

Attachment

An Attachment is a file that is sent along with a Message. You can programmatically access and download attachments from incoming Messages.

Core Capabilities

Here at AgentMail we’ve now made an Inbox an API resource, meaning you can perform standard CRUD operations on it. Here are the core capabilities you’ll use to manage your Inboxes.

1from agentmail import AgentMail
2
3# Initialize the client
4client = AgentMail(api_key="YOUR_API_KEY")
5
6# --- Create an Inbox ---
7# Creates a new inbox with a default agentmail.to domain
8new_inbox = client.inboxes.create()
9print(f"Created Inbox: {new_inbox.inbox_id}")
10
11# --- Retrieve an Inbox ---
12# Gets a specific inbox by its ID
13retrieved_inbox = client.inboxes.get(inbox_id = 'my_name@domain.com')
14print(f"Retrieved Inbox: {retrieved_inbox.inbox_id}")
15
16# --- List Inboxes ---
17# Lists all inboxes in your organization
18all_inboxes = client.inboxes.list()
19
20print(f"Total Inboxes: {all_inboxes.count}")

When creating an Inbox, the username and domain are optional. If you don’t provide them, AgentMail will generate a unique address for you using our default domain. Check out our guide on managing domains to learn more.

Metadata

Attach your own key-value data to any Inbox with the metadata field. Use it to link an inbox to records in your own system: a user ID, an agent name, or feature flags. Metadata is returned on every inbox response.

Values may be a string, number, or boolean. An Inbox can hold up to 256 keys, and each key and string value is limited to 256 characters.

1# Attach metadata when creating an inbox; values may be a string, int, float, or boolean
2inbox = client.inboxes.create(
3 username="support-agent",
4 metadata={
5 "tenant_id": "acme", # string
6 "seat_count": 5, # int
7 "monthly_spend": 19.99, # float
8 "active": True, # boolean
9 },
10)
11
12# Read it back from any inbox response
13print(inbox.metadata)

Updating metadata

Updates merge into the inbox’s existing metadata — keys you include are added or overwritten, and keys you omit are preserved.

To remove a single key, send it with a null value. To clear all metadata at once, send metadata as null. Every update must include either display_name or metadata.

1# Add or overwrite keys; the keys you omit stay unchanged
2client.inboxes.update(
3 inbox_id="support-agent@agentmail.to",
4 metadata={"tier": "enterprise"},
5)
6
7# Remove a single key
8client.inboxes.update(
9 inbox_id="support-agent@agentmail.to",
10 metadata={"tier": None},
11)
12
13# Clear all metadata
14client.inboxes.update(
15 inbox_id="support-agent@agentmail.to",
16 metadata=None,
17)

Inbox-scoped API keys

You can create API keys that are restricted to a single inbox. An inbox-scoped key can only access that inbox’s threads, messages, and drafts. This is useful when you want to give an agent or integration the minimum access it needs.

1# Create a key scoped to one inbox
2key = client.inboxes.api_keys.create(
3 new_inbox.inbox_id,
4 name="support-agent-key"
5)
6
7# The full key is only returned once
8print(key.api_key)

See the Multi-Tenancy guide for more on scoped keys.

Copy for Cursor / Claude

Copy one of the blocks below into Cursor or Claude for complete Inboxes API knowledge in one shot.

1"""
2AgentMail Inboxes — copy into Cursor/Claude.
3
4Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
5
6API reference:
7- inboxes.create(username?, domain?, display_name?, client_id?, metadata?) — client_id for idempotent retries; metadata is custom key-value data
8- inboxes.get(inbox_id)
9- inboxes.list(limit?, page_token?)
10- inboxes.update(inbox_id, display_name?, metadata?) — at least one field required; metadata is merged, not replaced
11- inboxes.delete(inbox_id)
12- inboxes.api_keys.create(inbox_id, name) — inbox-scoped key
13- inboxes.api_keys.list(inbox_id)
14- inboxes.api_keys.delete(inbox_id, api_key_id)
15
16Errors: SDK raises on 4xx/5xx. Rate limit: 429 with Retry-After.
17"""
18import os
19from dotenv import load_dotenv
20from agentmail import AgentMail
21
22load_dotenv()
23client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
24
25# Create (client_id for idempotent retries)
26inbox = client.inboxes.create(client_id="my-inbox-v1")
27
28# Get, list
29retrieved = client.inboxes.get(inbox.inbox_id)
30all_inboxes = client.inboxes.list(limit=20)
31print(f"Total: {all_inboxes.count}")