Index of every page on this site: llms.txt
All skills
agentmail-to avatar

/agentmail

@8b3d9ae
Run it yourself

Build with the AgentMail TypeScript or Python SDK for inbox, message, thread, draft, attachment, domain, allow/block list, pod, webhook, and WebSocket workflows, including programmatic agent sign-up, domain/DNS administration, and deliverability triage (bounces, spam, blocked mail). Use when implementing or reviewing AgentMail API code; do not use for direct mailbox operations, CLI usage, MCP setup, or framework-toolkit integration.

Use this Skill: https://skilld.dev/gh/agentmail-to/agentmail-skills/agentmail

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencespython.md

≈1.6k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Python SDK

These examples target agentmail 0.5.6. Python methods use snake_case, and configured organization-level inbox creation uses a request object.

Contents

Inboxes

from agentmail.inboxes.types import CreateInboxRequest

inbox = client.inboxes.create(
    request=CreateInboxRequest(
        username="support",
        display_name="Support Agent",
        client_id="support-v1",
        metadata={"tenant": "acme"},
    )
)

page = client.inboxes.list(limit=20)
fetched = client.inboxes.get(inbox_id=inbox.inbox_id)
client.inboxes.update(inbox_id=inbox.inbox_id, display_name="Customer Support")

Use client.pods.inboxes.* for pod-scoped inbox operations; do not pass pod_id to organization-level client.inboxes.* methods. Unlike client.inboxes.create, client.pods.inboxes.create takes flat kwargs, not a request object. See SKILL.md — API gotchas.

Messages and threads

sent = client.inboxes.messages.send(
    inbox_id=inbox.inbox_id,
    to="customer@example.com",
    subject="Hello",
    text="Plain-text body",
    html="<p>Plain-text body</p>",
)

# .list() returns MessageItem objects (metadata only: subject, from, labels,
# timestamps). There is no body. Fetch the full message with .get() to read
# .text / .html / .extracted_text.
messages = client.inboxes.messages.list(inbox_id=inbox.inbox_id, limit=20)
message = client.inboxes.messages.get(
    inbox_id=inbox.inbox_id,
    message_id="msg_123",
)
body = message.extracted_text or message.text or message.extracted_html or message.html

client.inboxes.messages.reply(
    inbox_id=inbox.inbox_id,
    message_id=message.message_id,
    text="Thanks for the update.",
)

client.inboxes.messages.forward(
    inbox_id=inbox.inbox_id,
    message_id=message.message_id,
    to="teammate@example.com",
    text="For your review.",
)

raw = client.inboxes.messages.get_raw(
    inbox_id=inbox.inbox_id,
    message_id=message.message_id,
)

threads = client.inboxes.threads.list(inbox_id=inbox.inbox_id, limit=20)
thread = client.inboxes.threads.get(
    inbox_id=inbox.inbox_id,
    thread_id=message.thread_id,
)

Use the search methods on inbox messages or threads for full-text queries. get_raw returns the raw MIME source of a message. reply() has no subject parameter — see SKILL.md — API gotchas. Max 50 recipients across to + cc + bcc combined on send().

Labels

AgentMail has no built-in read/unread flag; use labels to track processing state.

client.inboxes.messages.update(
    inbox_id=inbox.inbox_id,
    message_id=message.message_id,
    add_labels=["processed", "replied"],
    remove_labels=["unread"],
)

Pagination

Pagination is per call — request the next page explicitly with page_token.

response = client.inboxes.messages.list(inbox_id=inbox.inbox_id, limit=20)
while response.next_page_token:
    response = client.inboxes.messages.list(
        inbox_id=inbox.inbox_id,
        limit=20,
        page_token=response.next_page_token,
    )

Errors and retries

Both SDKs raise/throw on error responses and automatically retry 5xx, 408, 409, and 429 (default: 2 retries). On a 429, read the Retry-After header. The AgentMail constructor has no max_retries argument — override retries per call with request_options.

client.inboxes.messages.send(
    inbox_id=inbox.inbox_id,
    to="user@example.com",
    subject="Hi",
    text="Hello",
    request_options={"max_retries": 5},
)

Drafts and attachments

draft = client.inboxes.drafts.create(
    inbox_id=inbox.inbox_id,
    to="customer@example.com",
    subject="Pending approval",
    text="Draft content",
    client_id="draft-customer-123",
)

client.inboxes.drafts.update(
    inbox_id=inbox.inbox_id,
    draft_id=draft.draft_id,
    text="Revised draft content",
)

# Send converts the draft to a message and removes it from drafts.
client.inboxes.drafts.send(inbox_id=inbox.inbox_id, draft_id=draft.draft_id)

# Delete without sending.
client.inboxes.drafts.delete(inbox_id=inbox.inbox_id, draft_id=draft.draft_id)

attachment = client.inboxes.messages.get_attachment(
    inbox_id=inbox.inbox_id,
    message_id=message.message_id,
    attachment_id="att_456",
)

get_attachment does not return file bytes. It returns an AttachmentResponse with download_url (a CloudFront-signed URL), expires_at (~1 hour after the call), filename, size, and content_type. The signed URL is public-readable during its window — no auth header on the GET. Fetch the bytes immediately; never persist the URL (a later worker sees an expired-signature 403). Store the bytes or the attachment_id and re-fetch a fresh URL on demand.

import urllib.request

att = client.inboxes.messages.get_attachment(
    inbox_id=inbox.inbox_id, message_id=message.message_id, attachment_id="att_456",
)
with urllib.request.urlopen(att.download_url, timeout=30) as r:
    file_bytes = r.read()

Signed URLs point at cdn.agentmail.to, not api.agentmail.to — sandboxes that only allow the API host will 403/timeout on the fetch even though get_attachment succeeded.

Send attachments with either base64 content or a supported url, plus filename and content_type.

Pods (multi-tenant isolation)

Each pod is an isolated set of inboxes (one per customer/tenant). Note pods.inboxes.create takes flat kwargs, unlike top-level inboxes.create.

pod = client.pods.create(name="customer-acme", client_id="pod-acme-v1")
inbox = client.pods.inboxes.create(pod_id=pod.pod_id, username="notifications", client_id="acme-notif-v1")
inboxes = client.pods.inboxes.list(pod_id=pod.pod_id)
threads = client.pods.threads.list(pod_id=pod.pod_id)   # top-level threads.list has no pod filter
pods = client.pods.list()
client.pods.delete(pod_id=pod.pod_id)

Async client

For async codebases, use AsyncAgentMail in place of AgentMail; it mirrors the same method names with await.

from agentmail import AsyncAgentMail

client = AsyncAgentMail()
inbox = await client.inboxes.create(request=CreateInboxRequest(username="support"))

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

2 warnings1mo5 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill provides an SDK for the AgentMail email platform, enabling AI agents to manage inboxes, send messages, and handle webhooks. It follows security best practices by recommending environment variables for secret management and explicitly warning developers to treat all incoming email content as untrusted. No malicious patterns or unauthorized behaviors were detected.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: MEDIUM · 1 issue

  • Runlayer9mo

    2/3 files flagged

  • ZeroLeaks7mo

    3 findings · Score: 69/100

Signed by skilld at 8b3d9ae. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 4 months ago

README badge

README badge for agentmail-to/agentmail-skills

AgentMail is an API-first email platform that gives AI agents dedicated email inboxes for sending, receiving, and managing messages programmatically. The SDK supports multi-tenant pods, label-based organization, draft creation for human approval, attachment handling, and real-time event notifications via webhooks or websockets. Available in TypeScript/Node and Python.

Generated from the current SKILL.md.

Does this support both TypeScript and Python?
Yes. The SDK is available for both Node.js/TypeScript (npm install agentmail) and Python (pip install agentmail).
Can I use custom domains for agent email addresses?
Yes. You can create inboxes with a custom username and domain (e.g., support@yourdomain.com) or let AgentMail auto-generate an address.
How do I set up real-time email notifications?
AgentMail supports both webhooks (HTTP-based, requires a public URL) and websockets (persistent connection, no public URL needed). See the webhooks.md and websockets.md reference files.
Does this support human-in-the-loop workflows?
Yes. You can create draft messages for human approval before sending them, then convert the draft to a sent message via the API.
How does multi-tenant isolation work?
Use pods to create isolated inbox namespaces per customer. Each pod gets its own set of inboxes scoped within it, useful for SaaS platforms.

Generated from the current SKILL.md. These answers refresh after source changes.