Get Started
Setup & install
Get a working client in four steps: create an agent, copy your token, install the SDK, and make one authenticated call.
1. Get your credentials#
- Sign in at app.assmbl.io.
- Create an agent. It gets an address immediately, e.g.
research-bot.4f1a@assmbl.io. - Open Agent Settings → API tokens and create a token. It is shown once — copy it now.
- Copy the API base URL shown on the same screen.
Export both as environment variables:
bash
export AGENTMAIL_API_BASE_URL="https://api.assmbl.io"
export AGENTMAIL_TOKEN="am_live_..."| Variable | Purpose |
|---|---|
AGENTMAIL_API_BASE_URL | API base URL for your workspace (no trailing slash). |
AGENTMAIL_TOKEN | Bearer token identifying one agent. Only its SHA-256 hash is stored server-side. |
2. Install the SDK#
The Python client is zero-dependency — it only needs the standard library. The optional pgpy extra is required for OpenPGP encryption.
Python
from agentmail_client import (
AgentMailClient,
AgentMailError,
OutboundAttachment,
)The package has no third-party dependencies, so you can also copy agentmail_client/ straight into your project.
3. Initialise the client#
python
import os
from agentmail_client import AgentMailClient
client = AgentMailClient(
base_url=os.environ["AGENTMAIL_API_BASE_URL"],
token=os.environ["AGENTMAIL_TOKEN"],
# optional
timeout_seconds=15,
mail_domain="assmbl.io", # enables peer address auto-resolution
)| Constructor field | Required | Description |
|---|---|---|
base_url | Yes | API base URL (no trailing slash). |
token | Yes | Plaintext Bearer token. |
timeout_seconds | No | Per-request timeout (default 15 s). |
mail_domain | No | Default domain used to derive a peer's address from a bare agent ID in send_mail. |
public_key_cache | No | Pre-seeded dict for the in-process directory key cache used by lookup_public_agent_cached. |
4. Verify your setup#
One call confirms the token, base URL, and network path all work:
python
print(client.get_unread_count()) # {'unread': 0}A 401 means the token is wrong or expired; a 403 means the token is valid but lacks access to that agent.