Metadata-Version: 2.4
Name: agenticemail
Version: 0.2.0
Summary: Python SDK for AgenticEmail — API-first email for AI agents.
Project-URL: Homepage, https://agenticemail.dev
Project-URL: Repository, https://github.com/AgenticEmail/agenticemail-python
Project-URL: Documentation, https://agenticemail.dev/docs
License-Expression: Apache-2.0
Requires-Python: >=3.9
Requires-Dist: httpx>=0.27
Provides-Extra: e2e
Requires-Dist: jwcrypto>=1.5; extra == 'e2e'
Provides-Extra: events
Requires-Dist: websocket-client>=1.6; extra == 'events'
Provides-Extra: langchain
Requires-Dist: langchain-core>=0.3; extra == 'langchain'
Description-Content-Type: text/markdown

# agenticemail (Python)

API-first email for AI agents.

```bash
pip install agenticemail
```

```python
from agenticemail import AgenticEmail, verify_webhook

client = AgenticEmail(api_key="am_...", base_url="https://api.agenticemail.dev")

inbox = client.inboxes.create(username="support", domain="acme.io")

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

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

Resources: `inboxes`, `messages`, `threads`, `drafts`, `webhooks`, `domains`, `api_keys`. Responses are plain dicts (the API's snake_case JSON). Errors raise `AgenticEmailError` (`.status`, `.code`).

Verifying webhooks:

```python
from agenticemail import verify_webhook

event = verify_webhook(raw_body, headers, secret)  # raises AgenticEmailError if invalid
if event["type"] == "message.received":
    ...
```

See `examples/auto_reply.py` for a polling auto-reply agent.

## End-to-end encryption

Optional, opt-in, and agent-to-agent. The private key stays on your side, so
neither the platform nor AWS can read the contents. Wire-compatible with the
TypeScript SDK.

```bash
pip install 'agenticemail[e2e]'
```

```python
from agenticemail import AgenticEmail
from agenticemail.e2e import generate_identity, serialize_identity, deserialize_identity

# Once: create an identity for this inbox and store the private key safely.
identity = generate_identity("agent@acme.io")
open("agent.key", "w").write(serialize_identity(identity))

# Later: load it and enable e2e on the client.
identity = deserialize_identity(open("agent.key").read())
client = AgenticEmail(
    api_key="am_...",
    e2e={"identity": identity, "auto_publish": True},
)

# Encrypts automatically when the recipient has a published key; otherwise
# sends plaintext (set "allow_plaintext_fallback": False to fail closed).
client.messages.send("agent@acme.io", to=["peer@other.io"], subject="secret", text="...")

# Reads decrypt automatically; sender is verified against the published key.
msg = client.messages.get("agent@acme.io", message_id)
msg["text"], msg["decrypted"], msg["sender_verified"]
```

The recipient must be an AgenticEmail inbox that has published its key
(`client.publish_public_key()`); you cannot end-to-end encrypt to an external
address like Gmail.

## Related

- [CLI](https://github.com/AgenticEmail/agenticemail-cli): the same API as JSON-first shell commands — `npm install -g agenticemail-cli`, including `wait-for-message` for agent loops
- [TypeScript SDK](https://github.com/AgenticEmail/agenticemail-typescript): `npm install agenticemail`
- [Docs](https://agenticemail.dev/docs): guides, CLI, MCP server, and the interactive API reference

