Quickstart

Create your first inbox with the AgentMail API

This guide will walk you through installing the AgentMail SDK, authenticating with your API key, and creating your first email inbox.

1

Get your API Key

First, you’ll need an AgentMail API key. You can request one from the link below.

Once you have your key, 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.

1AGENTMAIL_API_KEY="YOUR_API_KEY"
2

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
3

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.

1import os
2from dotenv import load_dotenv
3from agentmail import AgentMail
4
5# Load the API key from the .env file
6load_dotenv()
7api_key = os.getenv("AGENTMAIL_API_KEY")
8
9# Initialize the client
10client = AgentMail(api_key=api_key)
11
12# Create an inbox
13print("Creating inbox...")
14inbox = client.inboxes.create() # domain is optional
15print("Inbox created successfully!")
16print(inbox)

The domain parameter is optional. If not provided, AgentMail will use the default @agentmail.to domain. If you would like a custom domain, please email contact@agentmail.cc

4

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!

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 attachements, semantically search your inbox, by exploring our docs and tutorials below.

Looking for a different language? Email us at support@agentmail.cc and we’ll get you set up.