Skip to main content

Python SDK for AgenticEmail — API-first email for AI agents.

Project description

AgenticEmail Python SDK

The official Python library for the AgenticEmail API — programmatic inboxes, send and receive email, webhooks, and real-time events for AI agents.

Installation

pip install agenticemail
# publishing to PyPI is in progress — until then, install from GitHub:
pip install git+https://github.com/AgenticEmail/agenticemail-python.git

Optional extras: agenticemail[events] (WebSocket event stream), agenticemail[langchain] (LangChain toolkit).

Usage

import os
from agenticemail import AgenticEmail

client = AgenticEmail(api_key=os.environ["AGENTICEMAIL_API_KEY"])

# Give your agent an inbox in one call
inbox = client.inboxes.create(username="support", domain="acme.io")

# Send
client.messages.send(
    inbox["id"],
    to=["customer@example.com"],
    subject="Hello",
    text="Sent from an agent.",
)

# Read
threads = client.threads.list(inbox["id"])

Responses are plain dicts in the API's snake_case. Get an API key from the dashboard.

Real-time events

Requires the events extra (websocket-client):

for event in client.events.stream(event_types=["message.received"]):
    print(event["type"], event["data"])

Webhook verification

from agenticemail import verify_webhook

event = verify_webhook(raw_body, request.headers, os.environ["WEBHOOK_SECRET"])
if event["type"] == "message.received":
    ...

verify_webhook raises AgenticEmailError when the signature is invalid.

LangChain toolkit

from agenticemail.langchain import AgenticEmailToolkit

tools = AgenticEmailToolkit.from_api_key().get_tools()  # reads AGENTICEMAIL_API_KEY

Error handling

All non-2xx responses raise AgenticEmailError with .status, .code, and a message:

from agenticemail import AgenticEmailError

try:
    client.inboxes.get("missing")
except AgenticEmailError as err:
    print(err.status, err.code)

Self-hosted

client = AgenticEmail(api_key="am_...", base_url="https://your-agenticemail-host")

API surface

See api.md for every resource and method: inboxes, messages, threads, drafts, lists, webhooks, domains, api_keys, events.

Requirements

Python 3.9+. Fully type-annotated (py.typed).

Contributing

See CONTRIBUTING.md. This repo is an exported snapshot of the SDK developed in the AgenticEmail monorepo.

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agenticemail-0.1.0.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agenticemail-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file agenticemail-0.1.0.tar.gz.

File metadata

  • Download URL: agenticemail-0.1.0.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agenticemail-0.1.0.tar.gz
Algorithm Hash digest
SHA256 11d7553f6aa7bbffc7f1aadfa426796949db43fb3d3e9ae94f5fbc5189f31d34
MD5 e3c2a310209ec97ceca7a3784207aed3
BLAKE2b-256 919d1c1168a8dbdb85d6c277bf70e2bd67e975e83107d00ab9b19cbc844f1410

See more details on using hashes here.

Provenance

The following attestation bundles were made for agenticemail-0.1.0.tar.gz:

Publisher: publish.yml on AgenticEmail/agenticemail-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file agenticemail-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: agenticemail-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for agenticemail-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2a0f19e8233abe082ecc171944590347557465ef398fe71bf3d837d17e063600
MD5 58525f1d4dc2eba28b35f246c8ee9adf
BLAKE2b-256 a6fe23e8965fb3daa7cd5bb52f4b6bd34b22a684cd91307ea417edab61e91fba

See more details on using hashes here.

Provenance

The following attestation bundles were made for agenticemail-0.1.0-py3-none-any.whl:

Publisher: publish.yml on AgenticEmail/agenticemail-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page