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.

referencestypescript.md

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

TypeScript SDK

These examples target agentmail 0.5.14. Path parameters are positional; request bodies are objects.

Contents

Inboxes

const inbox = await client.inboxes.create({
  username: "support",
  displayName: "Support Agent",
  clientId: "support-v1",
  metadata: { tenant: "acme" },
});

const page = await client.inboxes.list({ limit: 20 });
const fetched = await client.inboxes.get(inbox.inboxId);
await client.inboxes.update(inbox.inboxId, { displayName: "Customer Support" });

Use client.pods.inboxes.* for pod-scoped inbox operations; do not pass a pod ID to organization-level client.inboxes.* methods.

Messages and threads

const sent = await client.inboxes.messages.send(inbox.inboxId, {
  to: ["customer@example.com"],
  subject: "Hello",
  text: "Plain-text body",
  html: "<p>Plain-text body</p>",
});

// .list() returns metadata only (subject, from, labels, timestamps) — no
// body. Fetch the full message with .get() to read .text / .html / .extractedText.
const messages = await client.inboxes.messages.list(inbox.inboxId, { limit: 20 });
const message = await client.inboxes.messages.get(inbox.inboxId, "msg_123");
const body = message.extractedText ?? message.text ?? message.extractedHtml ?? message.html;

await client.inboxes.messages.reply(inbox.inboxId, message.messageId, {
  text: "Thanks for the update.",
});

await client.inboxes.messages.forward(inbox.inboxId, message.messageId, {
  to: "teammate@example.com",
  text: "For your review.",
});

const raw = await client.inboxes.messages.getRaw(inbox.inboxId, message.messageId);

const threads = await client.inboxes.threads.list(inbox.inboxId, { limit: 20 });
const thread = await client.inboxes.threads.get(inbox.inboxId, message.threadId);

Use the search methods on inbox messages or threads for full-text queries. getRaw 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.

await client.inboxes.messages.update(inbox.inboxId, message.messageId, {
  addLabels: ["processed", "replied"],
  removeLabels: ["unread"],
});

Pagination

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

let response = await client.inboxes.messages.list(inbox.inboxId, { limit: 20 });
while (response.nextPageToken) {
  response = await client.inboxes.messages.list(inbox.inboxId, {
    limit: 20,
    pageToken: response.nextPageToken,
  });
}

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. Override retries client-wide with maxRetries, or per call with requestOptions.

const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY, maxRetries: 5 });

await client.inboxes.messages.send(
  inbox.inboxId,
  { to: "user@example.com", subject: "Hi", text: "Hello" },
  { maxRetries: 5 },
);

Drafts and attachments

const draft = await client.inboxes.drafts.create(inbox.inboxId, {
  to: ["customer@example.com"],
  subject: "Pending approval",
  text: "Draft content",
  clientId: "draft-customer-123",
});

await client.inboxes.drafts.update(inbox.inboxId, draft.draftId, {
  text: "Revised draft content",
});

// Send converts the draft to a message and removes it from drafts.
await client.inboxes.drafts.send(inbox.inboxId, draft.draftId, {});

// Delete without sending.
await client.inboxes.drafts.delete(inbox.inboxId, draft.draftId);

const attachment = await client.inboxes.messages.getAttachment(
  inbox.inboxId,
  message.messageId,
  "att_456",
);

getAttachment does not return file bytes. It returns an AttachmentResponse with downloadUrl (a CloudFront-signed URL), expiresAt (~1 hour after the call), filename, size, and contentType. Fetch the bytes immediately; never persist the URL — it expires. Note the positional path params, per the Core rules.

const att = await client.inboxes.messages.getAttachment(inbox.inboxId, message.messageId, "att_456");
const res = await fetch(att.downloadUrl);
if (!res.ok) throw new Error(`Attachment fetch failed: ${res.status}`);
const fileBytes = Buffer.from(await res.arrayBuffer());

Signed URLs point at cdn.agentmail.to, not api.agentmail.to — an egress allowlist with only the API host will fail the fetch even though getAttachment succeeded.


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


## Pods (multi-tenant isolation)

```typescript
const pod = await client.pods.create({ name: "customer-acme", clientId: "pod-acme-v1" });
const inbox = await client.pods.inboxes.create(pod.podId, { username: "notifications", clientId: "acme-notif-v1" });
const inboxes = await client.pods.inboxes.list(pod.podId);
const threads = await client.pods.threads.list(pod.podId); // top-level threads.list has no pod filter

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.