TypeScript SDK
Operations
Install myagentmail from npm and get typed access to every endpoint in one import. View on npm
Install
npm install myagentmail
Initialize
import { MyAgentMail } from "myagentmail";
const client = new MyAgentMail({
apiKey: process.env.MYAGENTMAIL_KEY!,
});
Quick example
// Create an inbox
const inbox = await client.inboxes.create({
username: "scout",
displayName: "Scout",
});
// Send an email
const sent = await client.messages.send(inbox.id, {
to: "[email protected]",
subject: "Quick question",
plainBody: "Hi there.",
verified: true,
});
// List inbound messages
const { messages } = await client.messages.list(inbox.id, {
direction: "inbound",
});
// Reply in-thread
await client.messages.reply(inbox.id, messages[0].id, {
plainBody: "Thanks!",
});
// Draft for human review
const draft = await client.drafts.create(inbox.id, {
to: "[email protected]",
subject: "Monthly update",
});
await client.drafts.update(inbox.id, draft.id, {
plainBody: "Here are this month's numbers...",
});
// Human reviews in dashboard, then:
await client.drafts.send(inbox.id, draft.id);
Available resources
| Resource | Methods |
|---|---|
client.inboxes | create, list, get, update, delete, addAddress, removeAddress |
client.messages | send, reply, replyAll, forward, list, get, markRead, delete, listAttachments, downloadAttachment, downloadRaw |
client.threads | list, get |
client.drafts | create, list, get, update, delete, send |
client.lists | create, list, get, delete, addEntry, removeEntry |
client.domains | create, list, get, verify, zoneFile, delete |
client.workspaces | create, list, get, delete, createKey, listKeys, revokeKey |
client.webhooks | create, list, get, update, delete |
client | verifyEmail, metrics |
Error handling
import { MyAgentMailError } from "myagentmail";
try {
await client.messages.send(inboxId, { ... });
} catch (err) {
if (err instanceof MyAgentMailError) {
console.log(err.status); // 403
console.log(err.code); // "PLAN_LIMIT_REACHED"
console.log(err.message);
}
}
MCP server
For Claude Desktop / Cursor / Windsurf, the MCP server wraps the same API as native tools. Install separately:
npx -y myagentmail-mcp
Source
The SDK source is at github.com/kamskans/myagentmail/sdk. Zero runtime dependencies — just native fetch (Node 18+).