agentmail 0.4.15


pip install agentmail

  Latest version

Released: Mar 30, 2026

Project Links

Meta
Requires Python: >=3.8,<4.0

Classifiers

Intended Audience
  • Developers

Operating System
  • MacOS
  • Microsoft :: Windows
  • OS Independent
  • POSIX
  • POSIX :: Linux

Programming Language
  • Python
  • Python :: 3
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
  • Python :: 3.14
  • Python :: 3.15

Topic
  • Software Development :: Libraries :: Python Modules

Typing
  • Typed

Agentmail Python Library

fern shield pypi

The Agentmail Python library provides convenient access to the Agentmail APIs from Python.

Table of Contents

Installation

pip install agentmail

Reference

A full reference for this library is available here.

Usage

Instantiate and use the client with the following:

from agentmail import AgentMail

client = AgentMail(
    api_key="<token>",
)

client.inboxes.create()

Async Client

The SDK also exports an async client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use httpx.AsyncClient() instead of httpx.Client() (e.g. for the httpx_client parameter of this client).

import asyncio

from agentmail import AsyncAgentMail

client = AsyncAgentMail(
    api_key="<token>",
)


async def main() -> None:
    await client.inboxes.create()


asyncio.run(main())

Exception Handling

When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error will be thrown.

from agentmail.core.api_error import ApiError

try:
    client.inboxes.create(...)
except ApiError as e:
    print(e.status_code)
    print(e.body)

Advanced

Access Raw Response Data

The SDK provides access to raw response data, including headers, through the .with_raw_response property. The .with_raw_response property returns a "raw" client that can be used to access the .headers and .data attributes.

from agentmail import AgentMail

client = AgentMail(...)
response = client.inboxes.with_raw_response.create(...)
print(response.headers)  # access the response headers
print(response.status_code)  # access the response status code
print(response.data)  # access the underlying object

Retries

The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long as the request is deemed retryable and the number of retry attempts has not grown larger than the configured retry limit (default: 2).

A request is deemed retryable when any of the following HTTP status codes is returned:

  • 408 (Timeout)
  • 429 (Too Many Requests)
  • 5XX (Internal Server Errors)

Use the max_retries request option to configure this behavior.

client.inboxes.create(..., request_options={
    "max_retries": 1
})

Timeouts

The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.

from agentmail import AgentMail

client = AgentMail(..., timeout=20.0)

# Override timeout for a specific method
client.inboxes.create(..., request_options={
    "timeout_in_seconds": 1
})

Custom Client

You can override the httpx client to customize it for your use-case. Some common use-cases include support for proxies and transports.

import httpx
from agentmail import AgentMail

client = AgentMail(
    ...,
    httpx_client=httpx.Client(
        proxy="http://my.test.proxy.example.com",
        transport=httpx.HTTPTransport(local_address="0.0.0.0"),
    ),
)

Contributing

While we value open-source contributions to this SDK, this library is generated programmatically. Additions made directly to this library would have to be moved over to our generation code, otherwise they would be overwritten upon the next generated release. Feel free to open a PR as a proof of concept, but know that we will not be able to merge it as-is. We suggest opening an issue first to discuss with us!

On the other hand, contributions to the README are always very welcome!

Websockets

The SDK supports both sync and async websocket connections for real-time, low-latency communication. Sockets can be created using the connect method, which returns a context manager. You can either iterate through the returned SocketClient to process messages as they arrive, or attach handlers to respond to specific events.

from agentmail import AgentMail

client = AgentMail(...)

# Connect to the websocket (Sync)
with client.websockets.connect(...) as socket:
    # Iterate over the messages as they arrive
    for message in socket:
        print(message)

    # Or, attach handlers to specific events
    socket.on(EventType.MESSAGE, lambda message: print("received message", message))

import asyncio
from agentmail import AsyncAgentMail

client = AsyncAgentMail(...)

# Connect to the websocket (Async)
async with client.websockets.connect(...) as socket:
    async for message in socket:
        print(message)
0.4.15 Mar 30, 2026
0.4.14 Mar 30, 2026
0.4.13 Mar 28, 2026
0.4.12 Mar 23, 2026
0.4.11 Mar 23, 2026
0.4.10 Mar 19, 2026
0.4.9 Mar 18, 2026
0.4.7 Mar 16, 2026
0.4.5 Mar 10, 2026
0.4.4 Mar 09, 2026
0.2.24 Mar 06, 2026
0.2.23 Mar 02, 2026
0.2.22 Feb 27, 2026
0.2.21 Feb 26, 2026
0.2.20 Feb 25, 2026
0.2.17 Feb 17, 2026
0.2.16 Feb 17, 2026
0.2.15 Feb 13, 2026
0.2.14 Feb 13, 2026
0.2.13 Feb 12, 2026
0.2.12 Feb 09, 2026
0.2.11 Feb 02, 2026
0.2.10 Feb 01, 2026
0.2.9 Jan 30, 2026
0.2.8 Jan 30, 2026
0.2.6 Jan 28, 2026
0.2.5 Jan 27, 2026
0.2.4 Jan 23, 2026
0.2.3 Jan 23, 2026
0.2.1 Jan 21, 2026
0.2.0 Jan 21, 2026
0.1.18 Jan 16, 2026
0.1.17 Jan 16, 2026
0.1.16 Jan 05, 2026
0.1.15 Dec 23, 2025
0.1.14 Dec 23, 2025
0.1.13 Dec 23, 2025
0.1.12 Dec 19, 2025
0.1.11 Dec 19, 2025
0.1.10 Dec 16, 2025
0.1.9 Dec 05, 2025
0.1.8 Nov 30, 2025
0.1.7 Nov 29, 2025
0.1.6 Nov 28, 2025
0.1.5 Nov 19, 2025
0.1.4 Nov 17, 2025
0.1.3 Oct 30, 2025
0.1.2 Oct 30, 2025
0.1.1 Oct 30, 2025
0.1.0 Oct 29, 2025
0.0.284 Feb 25, 2026
0.0.281 Feb 25, 2026
0.0.78 Oct 29, 2025
0.0.76 Oct 29, 2025
0.0.75 Oct 29, 2025
0.0.74 Oct 29, 2025
0.0.73 Oct 26, 2025
0.0.72 Oct 26, 2025
0.0.71 Oct 26, 2025
0.0.70 Oct 26, 2025
0.0.69 Oct 26, 2025
0.0.68 Oct 13, 2025
0.0.67 Oct 02, 2025
0.0.66 Oct 01, 2025
0.0.60 Sep 27, 2025
0.0.59 Sep 27, 2025
0.0.58 Sep 27, 2025
0.0.57 Sep 27, 2025
0.0.56 Sep 14, 2025
0.0.55 Aug 27, 2025
0.0.54 Aug 25, 2025
0.0.53 Aug 22, 2025
0.0.52 Aug 22, 2025
0.0.51 Aug 21, 2025
0.0.50 Aug 18, 2025
0.0.49 Aug 18, 2025
0.0.48 Aug 15, 2025
0.0.45 Jul 20, 2025
0.0.44 Jul 18, 2025
0.0.43 Jul 18, 2025
0.0.42 Jul 17, 2025
0.0.41 Jul 16, 2025
0.0.40 Jul 09, 2025
0.0.39 Jul 08, 2025
0.0.38 Jul 03, 2025
0.0.37 Jun 30, 2025
0.0.36 Jun 20, 2025
0.0.35 Jun 20, 2025
0.0.33 Jun 19, 2025
0.0.32 Jun 18, 2025
0.0.31 Jun 17, 2025
0.0.30 Jun 17, 2025
0.0.29 Jun 14, 2025
0.0.28 Jun 10, 2025
0.0.27 Jun 09, 2025
0.0.26 Jun 07, 2025
0.0.25 May 31, 2025
0.0.24 May 21, 2025
0.0.23 May 15, 2025
0.0.22 May 15, 2025
0.0.21 May 13, 2025
0.0.20 May 13, 2025
0.0.19 Apr 02, 2025
0.0.18 Mar 25, 2025
0.0.17 Mar 19, 2025
0.0.16 Mar 17, 2025
0.0.15 Mar 04, 2025
0.0.14 Mar 01, 2025
0.0.13 Feb 26, 2025
0.0.12 Feb 24, 2025
0.0.11 Feb 23, 2025
0.0.10 Feb 19, 2025
0.0.9 Feb 19, 2025
0.0.8 Feb 19, 2025
0.0.7 Feb 19, 2025
0.0.6 Feb 19, 2025
0.0.5 Feb 17, 2025
0.0.4 Feb 15, 2025
0.0.3 Feb 13, 2025

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
httpx (>=0.21.2)
pydantic (>=1.9.2)
pydantic-core (>=2.18.2)
typing_extensions (>=4.0.0)
websockets (>=12.0)