# Table of Contents - [Welcome | AgentMail | Documentation](#welcome-agentmail-documentation) - [Welcome | AgentMail | Documentation](#welcome-agentmail-documentation) - [API Welcome | AgentMail | Documentation](#api-welcome-agentmail-documentation) - [Message Sent | AgentMail | Documentation](#message-sent-agentmail-documentation) - [Message Delivered | AgentMail | Documentation](#message-delivered-agentmail-documentation) - [Message Bounced | AgentMail | Documentation](#message-bounced-agentmail-documentation) - [Message Rejected | AgentMail | Documentation](#message-rejected-agentmail-documentation) - [Message Complained | AgentMail | Documentation](#message-complained-agentmail-documentation) - [Quickstart | AgentMail | Documentation](#quickstart-agentmail-documentation) - [Domain Verified | AgentMail | Documentation](#domain-verified-agentmail-documentation) - [Message Received | AgentMail | Documentation](#message-received-agentmail-documentation) - [Introduction | AgentMail | Documentation](#introduction-agentmail-documentation) - [Threads | AgentMail | Documentation](#threads-agentmail-documentation) - [Drafts | AgentMail | Documentation](#drafts-agentmail-documentation) - [Inboxes | AgentMail | Documentation](#inboxes-agentmail-documentation) - [Messages | AgentMail | Documentation](#messages-agentmail-documentation) - [MCP | AgentMail | Documentation](#mcp-agentmail-documentation) - [Attachments | AgentMail | Documentation](#attachments-agentmail-documentation) - [Labels | AgentMail | Documentation](#labels-agentmail-documentation) - [Guide: Sending & Receiving Email | AgentMail | Documentation](#guide-sending-receiving-email-agentmail-documentation) - [Replit | AgentMail | Documentation](#replit-agentmail-documentation) - [Pods | AgentMail | Documentation](#pods-agentmail-documentation) - [Connect | AgentMail | Documentation](#connect-agentmail-documentation) - [Integrate LiveKit Agents | AgentMail | Documentation](#integrate-livekit-agents-agentmail-documentation) --- # Welcome | AgentMail | Documentation ##### Welcome to AgentMail! We’re thrilled to have you here! Dive in to learn how to give your AI agents their own email inboxes.  We're excited to have you onboard! AgentMail is an API platform for giving AI agents their own inboxes to send, receive, and act upon emails. This allows agents to assume their own identity and communicate via the universal protocol of email with services, people, and other agents. Get Started ----------- [Introduction\ \ Learn about the core concepts and what makes AgentMail unique.](https://docs.agentmail.to/introduction) [Quickstart\ \ Create your first inbox and send an email in minutes.](https://docs.agentmail.to/quickstart) [API Reference\ \ Explore the full API with interactive examples.](https://docs.agentmail.to/api-reference) Need Help? ---------- [Join our Discord\ \ Ask questions and share your projects with the community.](https://discord.gg/hTYatWYWBc) [Email Support\ \ Get in touch with our team for personalized help.](mailto:support@agentmail.cc) --- # Welcome | AgentMail | Documentation ##### Welcome to AgentMail! We’re thrilled to have you here! Dive in to learn how to give your AI agents their own email inboxes.  We're excited to have you onboard! AgentMail is an API platform for giving AI agents their own inboxes to send, receive, and act upon emails. This allows agents to assume their own identity and communicate via the universal protocol of email with services, people, and other agents. Get Started ----------- [Introduction\ \ Learn about the core concepts and what makes AgentMail unique.](https://docs.agentmail.to/introduction) [Quickstart\ \ Create your first inbox and send an email in minutes.](https://docs.agentmail.to/quickstart) [API Reference\ \ Explore the full API with interactive examples.](https://docs.agentmail.to/api-reference) Need Help? ---------- [Join our Discord\ \ Ask questions and share your projects with the community.](https://discord.gg/hTYatWYWBc) [Email Support\ \ Get in touch with our team for personalized help.](mailto:support@agentmail.cc) [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # API Welcome | AgentMail | Documentation Introduction ------------ AgentMail provides a powerful API for managing email communications programmatically. Whether you’re building automated testing systems, handling customer support workflows, or developing email-based applications, our API offers the tools you need! Available SDKs -------------- [Python SDK\ \ Use our Python SDK for seamless integration with your Python applications.](https://github.com/agentmail-to/agentmail-python) [Node SDK\ \ Use our Node SDK for seamless integration with your Node applications.](https://github.com/agentmail-to/agentmail-node) Contribute ---------- We welcome contributions to our SDKs. If you have any suggestions or improvements, please feel free to open a pull request! If you have any other languages you would like us to support, please [reach out to us](mailto:support@agentmail.cc) . License ------- All of our SDKs are open source and available under the MIT license. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Message Sent | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"message.sent"Required event\_idstringRequired ID of event. sendobjectRequired Show 5 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Message Delivered | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"message.delivered"Required event\_idstringRequired ID of event. deliveryobjectRequired Show 5 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Message Bounced | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"message.bounced"Required event\_idstringRequired ID of event. bounceobjectRequired Show 7 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Message Rejected | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"message.rejected"Required event\_idstringRequired ID of event. rejectobjectRequired Show 5 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Message Complained | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"message.complained"Required event\_idstringRequired ID of event. complaintobjectRequired Show 7 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Quickstart | AgentMail | Documentation This guide will walk you through installing the AgentMail SDK, authenticating with your API key, and creating your first email inbox. [1](https://docs.agentmail.to/quickstart#access-the-agentmail-console) ### Access the AgentMail Console First, you’ll need to access the AgentMail Console to manage your account and API keys. Click the link below to get started. [Open AgentMail Console](https://console.agentmail.to/) If you don’t have an account yet, you can sign up directly from the console. Once you’re logged in, you’ll be able to manage your inboxes, view analytics, and create API keys. [2](https://docs.agentmail.to/quickstart#create-an-api-key) ### Create an API Key Now that you’re in the console, you’ll need to create an API key to authenticate your requests. Navigate to the API Keys section in your console dashboard.  Click “Create New API Key” and give it a descriptive name. Once created, copy the API key and store it securely. Create a `.env` file in your project’s root directory and add your key to it. We recommend using environment variables to keep your keys secure. [3](https://docs.agentmail.to/quickstart#install-the-sdk) ### 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. PythonNode | | | | --- | --- | | $ | pip install agentmail python-dotenv | [4](https://docs.agentmail.to/quickstart#create-an-inbox-and-send-an-email) ### Create an inbox and send an email Now you’re ready to make your first API call. Create a new file (e.g., `quickstart.py` or `quickstart.ts`) and add the following code. This script will initialize the AgentMail client, create a new inbox, and then send a test email. PythonTypeScript | | | | --- | --- | | 1 | import os | | 2 | from dotenv import load\_dotenv | | 3 | from agentmail import AgentMail | | 4 | | | 5 | \# Load the API key from the .env file | | 6 | load\_dotenv() | | 7 | api\_key = os.getenv("AGENTMAIL\_API\_KEY") | | 8 | | | 9 | \# Initialize the client | | 10 | client = AgentMail(api\_key=api\_key) | | 11 | | | 12 | \# Create an inbox | | 13 | print("Creating inbox...") | | 14 | inbox = client.inboxes.create() # domain is optional | | 15 | print("Inbox created successfully!") | | 16 | print(inbox) | | 17 | | | 18 | \# Send Email | | 19 | | | 20 | client.inboxes.messages.send( | | 21 | inbox\_id="your-email@example.com", | | 22 | to="contact@agentmail.to", | | 23 | subject="Hello from AgentMail!", | | 24 | text="This is my first email sent with the AgentMail API." | | 25 | | | 26 | ) | The `domain` parameter is optional. If not provided, AgentMail will use the default `@agentmail.to` domain. If you would like a custom domain, please [upgrade to a paid plan](https://agentmail.to/pricing) . [5](https://docs.agentmail.to/quickstart#run-the-code) ### Run the code Execute the script from your terminal. PythonTypeScript | | | | --- | --- | | $ | 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! Next Steps ---------- Congrats, you sent your first email via AgentMail. But this isn’t our strength. Explore the full power of creating agents that can autonomously reply, take action, parse attachments, semantically search your inbox, by exploring our docs and tutorials below. Looking for a different language? Email us at [support@agentmail.cc](mailto:support@agentmail.cc) and we’ll get you set up. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Domain Verified | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"domain.verified"Required event\_idstringRequired ID of event. domainobjectRequired Show 8 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Message Received | AgentMail | Documentation ### Headers svix-idstringRequired ID of webhook message. svix-signaturestringRequired Signature of webhook message. svix-timestampdatetimeRequired Timestamp of webhook message. ### Payload The payload of this webhook request is an object. type"event"Required event\_type"message.received"Required event\_idstringRequired ID of event. messageobjectRequired Show 23 properties threadobjectRequired Show 16 properties ### Response 200 any Return a 200 status to indicate that the data was received successfully. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Introduction | AgentMail | Documentation What is AgentMail? ------------------ AgentMail is an API platform for giving AI agents their own inboxes to send, receive, and act upon emails. We handle the infrastructure so you can focus on building email agents. **Email agents** can: * Have conversations with users in their inboxes * Automate email-based workflows for enterprises * Authenticate with third party applications * Act as first-class users on the internet The Problem with Traditional Email ---------------------------------- Existing email infrastructure was built for humans. Legacy providers such as Gmail and Outlook have several limitations for agentic use cases: No API for Inboxes Legacy providers lack API support for creating new inboxes on-demand. Per-Inbox Pricing They charge monthly subscriptions per inbox($12/inbox/month !!), which is costly for agents. Restrictive Limits They impose restrictive rate and sending limits not suitable for automation. Poor DX Overall, they offer a poor developer experience for building on top of email. The Gmail API sucks! The Solution ------------ AgentMail is an API-first email provider that is designed for agents. Think of it like Gmail, but with: [1](https://docs.agentmail.to/introduction#api-first-infrastructure) ### API-First Infrastructure **Programmatic Inboxes**: Create and manage inboxes via API. **Usage-Based Pricing**: Pay only for what you use. **High-Volume Ready**: No restrictive rate or sending limits. **Real-Time Events**: Get notified instantly with webhooks and websockets. **Simple Authentication**: Use API keys, no complex OAuth flows. [2](https://docs.agentmail.to/introduction#ai-native-features) ### AI-Native Features **Built-in Security**: Use API permissions and agent guardrails to control access. **Semantic Search**: Search across all inboxes in your organization by meaning. **Automatic Labeling**: Automatically categorize emails with user-defined prompts. **Structured Data Extraction**: Pull structured data from unstructured emails. And more on the way… Our customers use AgentMail for agent identity, authentication, and communication. To get started make an account on our [console](https://console.agentmail.to/) and please email [support@agentmail.cc](mailto:support@agentmail.cc) if you run into any issues. Get Started ----------- [Quickstart](https://docs.agentmail.to/quickstart) [API Reference](https://docs.agentmail.to/api-reference) Support ------- [Discord](https://discord.gg/hTYatWYWBc) [Email](mailto:support@agentmail.cc) [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Threads | AgentMail | Documentation What is a Thread? ----------------- A `Thread` is an API resource that represents a single conversation. It acts as a container, grouping a series of related `Messages` together in chronological order, just like a conversation thread in a traditional email client. `Threads` are created automatically. When your agent sends a `Message` that isn’t a reply to a previous one, a new `Thread` is initiated. Any subsequent replies are automatically added to this same `Thread`, allowing your agent to easily maintain the context of a conversation over time. Querying `Threads` ------------------ While `Threads` are created implicitly, you can retrieve them in two powerful ways: scoped to a single `Inbox` or across your entire `Organization`. ### Listing `Threads` per `Inbox` This is the standard way to retrieve all the conversations associated with a single agent or `Inbox`. PythonTypeScript | | | | --- | --- | | 1 | \# You'll need an inbox ID to list threads from. | | 2 | inbox\_id = "inbound-agent@agentmail.to" | | 3 | | | 4 | \# This retrieves all threads within the specified Inbox | | 5 | | | 6 | inbox\_threads = client.inboxes.threads.list(inbox\_id=inbox\_id) | ### Listing `Threads` Across an `Organization` This is one of AgentMail’s most powerful features. By omitting the `inbox_id`, you can retrieve a list of `Threads` from **every `Inbox`** in your `Organization`. This org-wide querying capability is essential for building: * **Supervisor Agents:** An agent that monitors conversations from a fleet of other agents. * **Analytics Dashboards:** Building something where you need visibility across all inboxes across the organization * **Advanced Workflows:** Systems that can route or escalate conversations between different agents with different permissions. PythonTypeScript | | | | --- | --- | | 1 | \# By not providing an inbox\_id, we get all threads in the organization | | 2 | all\_threads = client.threads.list() | | 3 | | | 4 | print(f"Found {all\_threads.count} threads across the entire organization.") | ##### Coming Soon: Org-Wide Semantic Search We are actively developing semantic search for the organization-wide thread listing endpoint. Soon, you’ll be able to find `Threads` based on the meaning and concepts within the `Messages`, not just keywords. ### Getting a Single `Thread` You can also retrieve a single `Thread` by its ID. This will return the `Thread` object, which typically contains a list of all its associated `Messages` and their ID’s. A common workflow is listing the messages in a thread and calling the `messages.reply` method on the last one. PythonTypeScript | | | | --- | --- | | 1 | thread\_id = "thread\_456def" | | 2 | | | 3 | \# This retrieves a single thread and its messages | | 4 | | | 5 | thread = client.threads.get( | | 6 | thread\_id="thread\_id" | | 7 | ) | | 8 | | | 9 | print(f"Retrieved thread {thread.thread\_id} with {len(thread.messages)} messages.") | [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Drafts | AgentMail | Documentation What is a Draft? ---------------- A `Draft` is an unsent `Message`. It’s a resource that allows your agent to prepare the contents of an email—including recipients, a subject, a body, and `Attachments`—without sending it immediately. We know agent reliability is big these days—with `Drafts` you can have agents have ready-to-send emails and only with your permission it can send them off into the world. `Drafts` are a key component for building advanced agent workflows. They enable: * **Human-in-the-Loop Review:** An agent can create a `Draft` for a sensitive or important `Message`, which a human can then review and approve before it’s sent. * **Scheduled Sending:** Your agent can create a `Draft` and then have a separate process send it at a specific time, such as during business hours for the recipient. * **Complex Composition:** For `Messages` that require multiple steps to build (e.g., fetching data from several sources, generating content), `Drafts` allow you to save the state of the email as it’s being composed. The `Draft` Lifecycle --------------------- You can interact with `Drafts` throughout their lifecycle, from creation to the moment they are sent. ### 1\. Create a `Draft` This is the first step. You create a `Draft` in a specific `Inbox` that will eventually be the sender. PythonTypeScript | | | | --- | --- | | 1 | \# You'll need an inbox ID to create a draft in. | | 2 | | | 3 | new\_draft=client.inboxes.drafts.create( | | 4 | inbox\_id="outbound@domain.com", | | 5 | to=\["review-team@example.com"\], | | 6 | subject="\[NEEDS REVIEW\] Agent's proposed response" | | 7 | ) | | 8 | | | 9 | print(f"Draft created successfully with ID: {new\_draft.draft\_id}") | ### 2\. Get `Draft` Once a `Draft` is created, you can retrieve it by its ID PythonTypeScript | | | | --- | --- | | 1 | \# Get the draft | | 2 | draft = client.inboxes.drafts.get(inbox\_id = “my\_inbox@domain.com”, draft\_id = “draft\_id\_123”) | ### 3\. Send a `Draft` This is the final step that converts the `Draft` into a sent `Message`. Once sent, the `Draft` is deleted. PythonTypeScript | | | | --- | --- | | 1 | \# This sends the draft and deletes it | | 2 | | | 3 | sent\_message = client.inboxes.drafts.send(inbox\_id = 'my\_inbox@domain.com', draft\_id = 'draft\_id\_123') | | 4 | | | 5 | print(f"Draft sent! New message ID: {sent\_message.message\_id}") | Note that now we access it by message\_id now because now its a message!! Org-Wide `Draft` Management --------------------------- Similar to `Threads`, you can list all `Drafts` across your entire `Organization`. This is perfect for building a central dashboard where a human supervisor can view, approve, or delete any `Draft` created by any agent in your fleet. PythonTypeScript | | | | --- | --- | | 1 | \# Get all drafts across the entire organization | | 2 | all\_drafts = client.drafts.list() | | 3 | | | 4 | print(f"Found {all\_drafts.count} drafts pending review.") | [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Inboxes | AgentMail | Documentation 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](https://docs.agentmail.to/best-practices/email-deliverability) ### 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.  [1](https://docs.agentmail.to/inboxes#organization) ### 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](https://docs.agentmail.to/inboxes#inbox) ### 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](https://docs.agentmail.to/inboxes#thread) ### Thread A `Thread` represents a single conversation. It groups together all replies and forwards related to an initial email, keeping your interactions organized. [4](https://docs.agentmail.to/inboxes#message) ### 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](https://docs.agentmail.to/inboxes#attachment) ### 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`. PythonTypeScript | | | | --- | --- | | 1 | from agentmail import AgentMail | | 2 | | | 3 | \# Initialize the client | | 4 | client = AgentMail(api\_key="YOUR\_API\_KEY") | | 5 | | | 6 | \# --- Create an Inbox --- | | 7 | \# Creates a new inbox with a default agentmail.to domain | | 8 | new\_inbox = client.inboxes.create() | | 9 | print(f"Created Inbox: {new\_inbox.inbox\_id}") | | 10 | | | 11 | \# --- Retrieve an Inbox --- | | 12 | \# Gets a specific inbox by its ID | | 13 | retrieved\_inbox = client.inboxes.get(inbox\_id = 'my\_name@domain.com') | | 14 | print(f"Retrieved Inbox: {retrieved\_inbox.inbox\_id}") | | 15 | | | 16 | \# --- List Inboxes --- | | 17 | \# Lists all inboxes in your organization | | 18 | all\_inboxes = client.inboxes.list() | | 19 | | | 20 | print(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](https://docs.agentmail.to/guides/domains/managing-domains) to learn more. [](https://docs.agentmail.to/) [contact@agentmail.cc](mailto:contact@agentmail.cc) [Discord](https://discord.gg/hTYatWYWBc) --- # Messages | AgentMail | Documentation What is a Message? ------------------ In the AgentMail ecosystem, a `Message` is the API-first representation of a traditional email. It’s a structured object containing all the elements you’d expect: a sender, recipients, a subject line, and the body of the email. Every `Message` lives inside a `Thread` to keep conversations organized. When you send a new `Message`, a new `Thread` is created. When you reply, the new `Message` is added to the existing `Thread`. Literally a normal email thread as we know it. One of the powerful features of AgentMail is the ability to seamlessly include humans in agent-driven conversations. You can `cc` or `bcc` a real person on any message your agent sends, creating a “human-in-the-loop” workflow for oversight, escalations, or quality assurance. Core Capabilities ----------------- You can interact with `Message` resources in several ways, from sending new `Messages` to listing a history of correspondence. ### 1\. Initialize the Client First, you need to initialize the AgentMail client with your API key. This client object is your gateway to interacting with the AgentMail API. PythonTypeScript | | | | --- | --- | | 1 | from agentmail import AgentMail | | 2 | | | 3 | client = AgentMail(api\_key="YOUR\_API\_KEY") | ### 2\. Send a New `Message` To start a new conversation, you can send a `Message` from one of your inboxes. This action will create a new `Thread` and return the `Message` object. PythonTypeScript | | | | --- | --- | | 1 | \# You'll need an inbox ID to send from. | | 2 | \# Let's assume we have one: | | 3 | | | 4 | sent\_message = client.inboxes.messages.send( | | 5 | inbox\_id = 'my\_inbox@domain.com', | | 6 | to = 'recipient@domain.com', | | 7 | labels=\[ |\ | 8 | "outreach", |\ | 9 | "startup" |\ | 10 | \], | | 11 | subject="\[YC S25\] Founder Reachout ", | | 12 | text="Hello, I'm Michael, and I'm a founder at AgentMail...", | | 13 | html="
Invoice Number: INV-2025-10-0123
| | 102 |Amount: $49.00
| | 103 |Status: Paid
| | 104 |