agentmail 0.3.7 → 0.3.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -171,6 +171,146 @@ Follow this guide to make your first AgentMail API request and create a new
171
171
  email inbox.
172
172
  ------------
173
173
 
174
+ ## Quickest start
175
+
176
+ <CodeBlocks>
177
+ ```bash title="Python"
178
+ pip install agentmail
179
+ ```
180
+
181
+ ```bash title="TypeScript"
182
+ npm install agentmail
183
+ ```
184
+ </CodeBlocks>
185
+
186
+ Get your API key from the [Console](https://console.agentmail.to) and replace `am_...` in the code below.
187
+
188
+ <CodeBlocks>
189
+ ```python title="Python"
190
+ from agentmail import AgentMail
191
+
192
+ client = AgentMail(api_key="am_...")
193
+ inbox = client.inboxes.create()
194
+ client.inboxes.messages.send(inbox.inbox_id, to="user@example.com", subject="Hello", text="Hello from my agent!")
195
+ ```
196
+
197
+ ```typescript title="TypeScript"
198
+ import { AgentMailClient } from "agentmail";
199
+
200
+ (async () => {
201
+ const client = new AgentMailClient({ apiKey: "am_..." });
202
+ const inbox = await client.inboxes.create();
203
+ await client.inboxes.messages.send(inbox.inboxId, { to: "user@example.com", subject: "Hello", text: "Hello from my agent!" });
204
+ })();
205
+ ```
206
+ </CodeBlocks>
207
+
208
+ ## Copy for Cursor / Claude
209
+
210
+ Copy one of the blocks below into Cursor or Claude for a complete, working AgentMail integration. Each block includes setup, API reference, error handling, rate limiting, and idempotency guidance.
211
+
212
+ <CodeBlocks>
213
+ ```python title="Python"
214
+ """
215
+ AgentMail Python Quickstart — copy into Cursor/Claude for instant setup.
216
+
217
+ Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
218
+
219
+ API reference:
220
+ - inboxes.create(username?, domain?, display_name?, client_id?) — client_id for idempotent retries
221
+ - messages.send(inbox_id, to, subject, text, html?, cc?, bcc?, reply_to?, attachments?)
222
+ - messages.list(inbox_id, limit?, page_token?, labels?) — receive emails; use extracted_text/extracted_html for reply content
223
+
224
+ Errors: SDK raises on 4xx/5xx. Inspect error.body.message or str(e).
225
+ Rate limit: 429 with Retry-After header. Implement exponential backoff for retries.
226
+ Idempotency: Pass client_id to inboxes.create() to safely retry without duplicates.
227
+ """
228
+ import os
229
+ from dotenv import load_dotenv
230
+ from agentmail import AgentMail
231
+
232
+ load_dotenv()
233
+ client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
234
+
235
+ # Create inbox (client_id enables safe retries)
236
+ inbox = client.inboxes.create(client_id="my-agent-inbox-v1")
237
+
238
+ # Send email
239
+ try:
240
+ client.inboxes.messages.send(
241
+ inbox.inbox_id,
242
+ to="recipient@example.com",
243
+ subject="Hello from AgentMail",
244
+ text="Plain text body",
245
+ html="<p>HTML body</p>",
246
+ )
247
+ except Exception as e:
248
+ # Handle validation, not found, rate limit (429), etc.
249
+ print(f"Send failed: {e}")
250
+ raise
251
+
252
+ # Receive messages
253
+ for msg in client.inboxes.messages.list(inbox.inbox_id, limit=10).messages:
254
+ print(msg.subject, msg.extracted_text or msg.text)
255
+ ```
256
+
257
+ ```typescript title="TypeScript"
258
+ /**
259
+ * AgentMail TypeScript Quickstart — copy into Cursor/Claude for instant setup.
260
+ *
261
+ * Setup: npm install agentmail dotenv. Set AGENTMAIL_API_KEY in .env.
262
+ *
263
+ * API reference:
264
+ * - inboxes.create({ username?, domain?, displayName?, clientId? }) — clientId for idempotent retries
265
+ * - messages.send(inboxId, { to, subject, text, html?, cc?, bcc?, replyTo?, attachments? })
266
+ * - messages.list(inboxId, { limit?, pageToken?, labels? }) — receive; use extractedText/extractedHtml for reply content
267
+ *
268
+ * Errors: SDK throws on 4xx/5xx. Check error.body?.message.
269
+ * Rate limit: 429 with Retry-After header. Use exponential backoff for retries.
270
+ * Idempotency: Pass clientId to inboxes.create() to safely retry without duplicates.
271
+ */
272
+ import { AgentMailClient } from "agentmail";
273
+ import "dotenv/config";
274
+
275
+ const client = new AgentMailClient({
276
+ apiKey: process.env.AGENTMAIL_API_KEY!,
277
+ });
278
+
279
+ async function main() {
280
+ // Create inbox (clientId enables safe retries)
281
+ const inbox = await client.inboxes.create({
282
+ clientId: "my-agent-inbox-v1",
283
+ });
284
+
285
+ try {
286
+ await client.inboxes.messages.send(inbox.inboxId, {
287
+ to: "recipient@example.com",
288
+ subject: "Hello from AgentMail",
289
+ text: "Plain text body",
290
+ html: "<p>HTML body</p>",
291
+ });
292
+ } catch (error: unknown) {
293
+ // Handle validation, not found, rate limit (429), etc.
294
+ const msg = (error as { body?: { message?: string } })?.body?.message ?? String(error);
295
+ throw new Error(`Send failed: ${msg}`);
296
+ }
297
+
298
+ // Receive messages
299
+ const res = await client.inboxes.messages.list(inbox.inboxId, { limit: 10 });
300
+ for (const msg of res.messages) {
301
+ console.log(msg.subject, msg.extractedText ?? msg.text);
302
+ }
303
+ }
304
+
305
+ main();
306
+ ```
307
+ </CodeBlocks>
308
+
309
+ <Tip>
310
+ When receiving emails, messages include `extracted_text` and `extracted_html`
311
+ for reply content without quoted history.
312
+ </Tip>
313
+
174
314
  This guide will walk you through installing the AgentMail SDK, authenticating with your API key, and creating your first email inbox.
175
315
 
176
316
  <Steps>
@@ -235,11 +375,10 @@ This guide will walk you through installing the AgentMail SDK, authenticating wi
235
375
  # Send Email
236
376
 
237
377
  client.inboxes.messages.send(
238
- inbox_id="your-email@example.com",
239
- to="contact@agentmail.to",
240
- subject="Hello from AgentMail!",
241
- text="This is my first email sent with the AgentMail API."
242
-
378
+ inbox.inbox_id,
379
+ to="your-email@example.com",
380
+ subject="Hello from AgentMail!",
381
+ text="This is my first email sent with the AgentMail API.",
243
382
  )
244
383
 
245
384
  ```
@@ -619,6 +758,8 @@ You can retrieve the details of any specific `Message` by providing its ID along
619
758
  ```
620
759
  </CodeBlocks>
621
760
 
761
+ When receiving replies or forwards, use `extracted_text` or `extracted_html` for just the new content—quoted history is stripped automatically.
762
+
622
763
  ### Crafting Your Message: HTML, Text, and CSS
623
764
 
624
765
  When sending a `Message`, you can provide the body in two formats: `text` for a plain-text version and `html` for a rich, styled version.
@@ -1180,6 +1321,99 @@ This is where `Labels` become truly powerful. You can list `Threads`, `Messages`
1180
1321
  </Callout>
1181
1322
 
1182
1323
 
1324
+ ***
1325
+
1326
+ title: Lists
1327
+ subtitle: Filter emails by allowing or blocking specific addresses and domains.
1328
+ slug: lists
1329
+ description: >-
1330
+ Learn how to use Lists to control which email addresses and domains your
1331
+ agents can send to or receive from.
1332
+ -----------------------------------
1333
+
1334
+ ## What are Lists?
1335
+
1336
+ `Lists` allow you to filter emails by allowing or blocking specific email addresses or domains. There are four list types based on two dimensions:
1337
+
1338
+ * **Direction**: `send` or `receive`
1339
+ * **Type**: `allow` or `block`
1340
+
1341
+ | List | Description |
1342
+ | ------------- | ---------------------------------------------------- |
1343
+ | Receive allow | Only accept emails from these addresses or domains |
1344
+ | Receive block | Reject emails from these addresses or domains |
1345
+ | Send allow | Only send emails to these addresses or domains |
1346
+ | Send block | Prevent sending emails to these addresses or domains |
1347
+
1348
+ Each entry can be either a full email address (e.g., `partner@example.com`) or an entire domain (e.g., `example.com`).
1349
+
1350
+ ## SDK examples
1351
+
1352
+ ### List entries
1353
+
1354
+ Retrieve entries from a list with optional pagination.
1355
+
1356
+ <CodeBlocks>
1357
+ ```python title="Python"
1358
+ entries = client.lists.list("receive", "allow", limit=10)
1359
+ ```
1360
+
1361
+ ```typescript title="TypeScript"
1362
+ const entries = await client.lists.list("receive", "allow", { limit: 10 });
1363
+ ```
1364
+ </CodeBlocks>
1365
+
1366
+ ### Create entry
1367
+
1368
+ Add an email address or domain to a list. The `reason` parameter is optional and available on block lists.
1369
+
1370
+ <CodeBlocks>
1371
+ ```python title="Python"
1372
+ # allow list - no reason needed
1373
+ client.lists.create("receive", "allow", entry="partner@example.com")
1374
+
1375
+ # block list - reason optional
1376
+ client.lists.create("receive", "block", entry="spam@example.com", reason="spam")
1377
+ ```
1378
+
1379
+ ```typescript title="TypeScript"
1380
+ // allow list - no reason needed
1381
+ await client.lists.create("receive", "allow", { entry: "partner@example.com" });
1382
+
1383
+ // block list - reason optional
1384
+ await client.lists.create("receive", "block", { entry: "spam@example.com", reason: "spam" });
1385
+ ```
1386
+ </CodeBlocks>
1387
+
1388
+ ### Get entry
1389
+
1390
+ Retrieve a specific entry from a list by its email address or domain.
1391
+
1392
+ <CodeBlocks>
1393
+ ```python title="Python"
1394
+ entry = client.lists.get("receive", "allow", entry="partner@example.com")
1395
+ ```
1396
+
1397
+ ```typescript title="TypeScript"
1398
+ const entry = await client.lists.get("receive", "allow", "partner@example.com");
1399
+ ```
1400
+ </CodeBlocks>
1401
+
1402
+ ### Delete entry
1403
+
1404
+ Remove an entry from a list.
1405
+
1406
+ <CodeBlocks>
1407
+ ```python title="Python"
1408
+ client.lists.delete("receive", "allow", entry="partner@example.com")
1409
+ ```
1410
+
1411
+ ```typescript title="TypeScript"
1412
+ await client.lists.delete("receive", "allow", "partner@example.com");
1413
+ ```
1414
+ </CodeBlocks>
1415
+
1416
+
1183
1417
  ***
1184
1418
 
1185
1419
  title: Attachments
@@ -1572,30 +1806,30 @@ title: Skills
1572
1806
  subtitle: Add AgentMail to AI coding assistants with the official skill
1573
1807
  slug: integrations/skills
1574
1808
  description: >-
1575
- AgentMail's official skill for Moltbot, Claude Code, Cursor, and other AI
1809
+ AgentMail's official skill for OpenClaw, Claude Code, Cursor, and other AI
1576
1810
  assistants
1577
1811
  ----------
1578
1812
 
1579
1813
  ## Getting started
1580
1814
 
1581
- AgentMail provides an official skill that can be installed on AI coding assistants and agents that support the [AgentSkills](https://skills.sh) format. This includes Moltbot, Claude Code, Cursor, Codex, and other compatible tools.
1815
+ AgentMail provides an official skill that can be installed on AI coding assistants and agents that support the [AgentSkills](https://skills.sh) format. This includes OpenClaw, Claude Code, Cursor, Codex, and other compatible tools.
1582
1816
 
1583
1817
  The skill is available at [skills.sh/agentmail-to/agentmail-skills/agentmail](https://skills.sh/agentmail-to/agentmail-skills/agentmail).
1584
1818
 
1585
1819
  ## Installation
1586
1820
 
1587
- ### Moltbot
1821
+ ### OpenClaw
1588
1822
 
1589
- Install the skill using the Moltbot CLI:
1823
+ Install the skill using the OpenClaw CLI:
1590
1824
 
1591
1825
  ```bash
1592
- moltbot skills install agentmail-to/agentmail-skills/agentmail
1826
+ openclaw skills install agentmail-to/agentmail-skills/agentmail
1593
1827
  ```
1594
1828
 
1595
- Or install via ClawdHub:
1829
+ Or install via ClawHub:
1596
1830
 
1597
1831
  ```bash
1598
- clawdhub install agentmail
1832
+ npx clawhub@latest install agentmail
1599
1833
  ```
1600
1834
 
1601
1835
  ### Claude Code
@@ -1634,9 +1868,9 @@ Set the `AGENTMAIL_API_KEY` environment variable:
1634
1868
  export AGENTMAIL_API_KEY="your-api-key-here"
1635
1869
  ```
1636
1870
 
1637
- ### Moltbot configuration
1871
+ ### OpenClaw configuration
1638
1872
 
1639
- Add the API key to `~/.clawdbot/moltbot.json`:
1873
+ Add the API key to `~/.openclaw/openclaw.json`:
1640
1874
 
1641
1875
  ```json
1642
1876
  {
@@ -1723,7 +1957,13 @@ The Model Context Protocol (MCP) is an open standard that enables AI application
1723
1957
 
1724
1958
  ### Setup
1725
1959
 
1726
- To get started with the AgentMail MCP server, visit [mcp.agentmail.to](https://mcp.agentmail.to) for installation instructions and configuration details.
1960
+ Install with:
1961
+
1962
+ ```bash
1963
+ npx @smithery/cli@latest mcp add agentmail
1964
+ ```
1965
+
1966
+ Configure your API key when prompted. Get your key from the [AgentMail Console](https://console.agentmail.to). For more details, visit [mcp.agentmail.to](https://mcp.agentmail.to).
1727
1967
 
1728
1968
  ## Features
1729
1969
 
@@ -1748,25 +1988,25 @@ For detailed setup instructions and available tools, visit [mcp.agentmail.to](ht
1748
1988
 
1749
1989
  ***
1750
1990
 
1751
- title: Openclaw
1752
- subtitle: Give your Openclaw agent its own email inbox
1991
+ title: OpenClaw
1992
+ subtitle: Give your OpenClaw agent its own email inbox
1753
1993
  slug: integrations/openclaw
1754
- description: AgentMail's Openclaw integration
1994
+ description: AgentMail's OpenClaw integration
1755
1995
  ---------------------------------------------
1756
1996
 
1757
1997
  ## Getting started
1758
1998
 
1759
- Openclaw (formerly Moltbot) is an open-source AI personal assistant that runs on your own devices and integrates with messaging platforms like WhatsApp, Telegram, Discord, and Slack. By adding AgentMail to Openclaw, your agent gains the ability to send and receive emails, enabling two-way email conversations alongside your existing chat channels.
1999
+ OpenClaw (formerly Moltbot) is an open-source AI personal assistant that runs on your own devices and integrates with messaging platforms like WhatsApp, Telegram, Discord, and Slack. By adding AgentMail to OpenClaw, your agent gains the ability to send and receive emails, enabling two-way email conversations alongside your existing chat channels.
1760
2000
 
1761
- There are two ways to integrate AgentMail with Openclaw: using the official AgentMail skill or creating a custom skill.
2001
+ There are two ways to integrate AgentMail with OpenClaw: using the official AgentMail skill or creating a custom skill.
1762
2002
 
1763
2003
  ## Option 1: Official AgentMail Skill (Recommended)
1764
2004
 
1765
- The easiest way to add email capabilities to Openclaw is by installing the official AgentMail skill from [skills.sh](https://skills.sh/agentmail-to/agentmail-skills/agentmail). This skill is maintained by the AgentMail team and provides comprehensive email functionality.
2005
+ The easiest way to add email capabilities to OpenClaw is by installing the official AgentMail skill from [skills.sh](https://skills.sh/agentmail-to/agentmail-skills/agentmail). This skill is maintained by the AgentMail team and provides comprehensive email functionality.
1766
2006
 
1767
2007
  ### Installation
1768
2008
 
1769
- Install the skill using the Openclaw CLI:
2009
+ Install the skill using the OpenClaw CLI:
1770
2010
 
1771
2011
  ```bash
1772
2012
  openclaw skills install agentmail-to/agentmail-skills/agentmail
@@ -1824,11 +2064,11 @@ You should see `agentmail` in the list of available skills.
1824
2064
 
1825
2065
  ## Option 2: Custom Skill
1826
2066
 
1827
- For more control over the integration, you can create a custom AgentMail skill. Skills are directories containing a `SKILL.md` file with instructions for Openclaw.
2067
+ For more control over the integration, you can create a custom AgentMail skill. Skills are directories containing a `SKILL.md` file with instructions for OpenClaw.
1828
2068
 
1829
2069
  ### Create the skill directory
1830
2070
 
1831
- Create a new skill in your Openclaw workspace:
2071
+ Create a new skill in your OpenClaw workspace:
1832
2072
 
1833
2073
  ```bash
1834
2074
  mkdir -p ~/.openclaw/skills/agentmail
@@ -1890,10 +2130,10 @@ curl -s -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \
1890
2130
  -H "Content-Type: application/json" \
1891
2131
  -d '{
1892
2132
  "to": ["recipient@example.com"],
1893
- "subject": "Hello from Openclaw",
2133
+ "subject": "Hello from OpenClaw",
1894
2134
  "text": "This email was sent by my AI assistant."
1895
2135
  }' \
1896
- https://api.agentmail.to/v0/inboxes/{inbox_id}/messages
2136
+ https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/send
1897
2137
  ```
1898
2138
 
1899
2139
  ### List messages in an inbox
@@ -1944,7 +2184,7 @@ You should see `agentmail` in the list of available skills.
1944
2184
 
1945
2185
  ## Example use cases
1946
2186
 
1947
- Once AgentMail is integrated with Openclaw, you can ask your agent to:
2187
+ Once AgentMail is integrated with OpenClaw, you can ask your agent to:
1948
2188
 
1949
2189
  * "Create a new email inbox for my project"
1950
2190
  * "Check my inbox for new emails"
@@ -1954,9 +2194,9 @@ Once AgentMail is integrated with Openclaw, you can ask your agent to:
1954
2194
 
1955
2195
  ## Real-time email notifications
1956
2196
 
1957
- For proactive email handling, you can combine AgentMail webhooks with Openclaw's webhook support. This allows Openclaw to notify you immediately when new emails arrive.
2197
+ For proactive email handling, you can combine AgentMail webhooks with OpenClaw's webhook support. This allows OpenClaw to notify you immediately when new emails arrive.
1958
2198
 
1959
- 1. Set up a webhook endpoint in Openclaw (see [Openclaw webhook documentation](https://docs.openclaw.ai/automation/webhook))
2199
+ 1. Set up a webhook endpoint in OpenClaw (see [OpenClaw webhook documentation](https://docs.openclaw.ai/automation/webhook))
1960
2200
 
1961
2201
  2. Register the webhook with AgentMail:
1962
2202
 
@@ -1970,14 +2210,14 @@ curl -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \
1970
2210
  https://api.agentmail.to/v0/webhooks
1971
2211
  ```
1972
2212
 
1973
- Now Openclaw will be notified whenever a new email arrives, allowing it to proactively inform you or take action.
2213
+ Now OpenClaw will be notified whenever a new email arrives, allowing it to proactively inform you or take action.
1974
2214
 
1975
2215
  ## Resources
1976
2216
 
1977
2217
  * [Official AgentMail Skill](https://skills.sh/agentmail-to/agentmail-skills/agentmail)
1978
2218
  * [AgentMail API Reference](/api-reference)
1979
- * [Openclaw Documentation](https://docs.openclaw.ai)
1980
- * [Openclaw Skills Guide](https://docs.openclaw.ai/tools/skills)
2219
+ * [OpenClaw Documentation](https://docs.openclaw.ai)
2220
+ * [OpenClaw Skills Guide](https://docs.openclaw.ai/tools/skills)
1981
2221
 
1982
2222
 
1983
2223
  ***
@@ -2196,6 +2436,164 @@ Email is critical to identity and communication on the internet. Much of the con
2196
2436
  These are just a few select verticals, but we have seen AgentMail be effective in automating any email task across every function. If a human does it with email, it can be automated with AgentMail.
2197
2437
 
2198
2438
 
2439
+ ***
2440
+
2441
+ title: x402
2442
+ subtitle: Pay-per-use AgentMail with the x402 payment protocol
2443
+ slug: integrations/x402
2444
+ description: AgentMail's x402 integration for HTTP-native payments
2445
+ ------------------------------------------------------------------
2446
+
2447
+ ## Getting started
2448
+
2449
+ [x402](https://www.x402.org/) is an open payment protocol that enables HTTP-native payments. By integrating x402 with AgentMail, your agents can pay for API usage directly over HTTP without managing API keys or subscriptions.
2450
+
2451
+ ### Base URLs
2452
+
2453
+ To authenticate with x402 instead of an API key, you must use the x402-specific base URLs below. These replace the default AgentMail base URLs and route requests through the x402 payment layer.
2454
+
2455
+ | Protocol | URL |
2456
+ | --------- | ----------------------- |
2457
+ | HTTP | `x402.api.agentmail.to` |
2458
+ | WebSocket | `x402.ws.agentmail.to` |
2459
+
2460
+ ### Prerequisites
2461
+
2462
+ * A crypto wallet with USDC funds (EVM-compatible wallet on Base, or a Solana wallet)
2463
+ * Node.js installed
2464
+
2465
+ ### Install dependencies
2466
+
2467
+ <CodeBlocks>
2468
+ ```bash title="EVM"
2469
+ npm install agentmail @x402/fetch @x402/evm viem
2470
+ ```
2471
+
2472
+ ```bash title="Solana"
2473
+ npm install agentmail @x402/fetch @x402/svm @solana/kit @scure/base
2474
+ ```
2475
+ </CodeBlocks>
2476
+
2477
+ ### Quickstart
2478
+
2479
+ <CodeBlocks>
2480
+ ```typescript title="EVM"
2481
+ import { privateKeyToAccount } from "viem/accounts";
2482
+ import { x402Client } from "@x402/fetch";
2483
+ import { ExactEvmScheme } from "@x402/evm/exact/client";
2484
+
2485
+ import { AgentMailClient } from "agentmail";
2486
+
2487
+
2488
+ // setup x402 client
2489
+
2490
+ const PRIVATE_KEY = "0x...";
2491
+
2492
+ const signer = privateKeyToAccount(PRIVATE_KEY);
2493
+
2494
+ const x402 = new x402Client();
2495
+ x402.register("eip155:*", new ExactEvmScheme(signer));
2496
+
2497
+
2498
+ // setup AgentMail client
2499
+
2500
+ export const client = new AgentMailClient({ x402 });
2501
+
2502
+
2503
+ // create inbox
2504
+
2505
+ const inboxRes = await client.inboxes.create({
2506
+ username: `x402-${Date.now()}`,
2507
+ });
2508
+ console.log("Created inbox: ", inboxRes.inboxId);
2509
+
2510
+
2511
+ // subscribe to inbox
2512
+
2513
+ const socket = await client.websockets.connect();
2514
+ console.log("Connected to websocket");
2515
+
2516
+ socket.on("message", async (event) => {
2517
+ if (event.type === "subscribed") {
2518
+ console.log("Subscribed to", event.inboxIds);
2519
+ } else if (event.type === "event" && event.eventType === "message.received") {
2520
+ console.log("Received message from: ", event.message.from);
2521
+ }
2522
+ });
2523
+
2524
+ socket.sendSubscribe({
2525
+ type: "subscribe",
2526
+ inboxIds: [inboxRes.inboxId],
2527
+ });
2528
+ ```
2529
+
2530
+ ```typescript title="Solana"
2531
+ import { createKeyPairSignerFromBytes } from "@solana/kit";
2532
+ import { base58 } from "@scure/base";
2533
+ import { x402Client } from "@x402/fetch";
2534
+ import { ExactSvmClient, toClientSvmSigner } from "@x402/svm";
2535
+
2536
+ import { AgentMailClient } from "agentmail";
2537
+
2538
+
2539
+ // setup x402 client
2540
+
2541
+ const PRIVATE_KEY = "base58-encoded-private-key...";
2542
+
2543
+ const keypair = await createKeyPairSignerFromBytes(
2544
+ base58.decode(PRIVATE_KEY)
2545
+ );
2546
+
2547
+ const x402 = new x402Client();
2548
+ x402.register("solana:*", new ExactSvmClient(toClientSvmSigner(keypair)));
2549
+
2550
+
2551
+ // setup AgentMail client
2552
+
2553
+ export const client = new AgentMailClient({ x402 });
2554
+
2555
+
2556
+ // create inbox
2557
+
2558
+ const inboxRes = await client.inboxes.create({
2559
+ username: `x402-${Date.now()}`,
2560
+ });
2561
+ console.log("Created inbox: ", inboxRes.inboxId);
2562
+
2563
+
2564
+ // subscribe to inbox
2565
+
2566
+ const socket = await client.websockets.connect();
2567
+ console.log("Connected to websocket");
2568
+
2569
+ socket.on("message", async (event) => {
2570
+ if (event.type === "subscribed") {
2571
+ console.log("Subscribed to", event.inboxIds);
2572
+ } else if (event.type === "event" && event.eventType === "message.received") {
2573
+ console.log("Received message from: ", event.message.from);
2574
+ }
2575
+ });
2576
+
2577
+ socket.sendSubscribe({
2578
+ type: "subscribe",
2579
+ inboxIds: [inboxRes.inboxId],
2580
+ });
2581
+ ```
2582
+ </CodeBlocks>
2583
+
2584
+ ## How it works
2585
+
2586
+ When you pass an `x402` client to `AgentMailClient`, the SDK automatically handles payment negotiation for each API request. If the server responds with a `402 Payment Required` status, the x402 client signs a payment using your wallet and retries the request with the payment attached.
2587
+
2588
+ This means your agent can use the full AgentMail API (inboxes, messages, threads, attachments) without needing a traditional API key. Payment happens per-request over HTTP.
2589
+
2590
+ ## Resources
2591
+
2592
+ * [x402 documentation](https://www.x402.org/)
2593
+ * [AgentMail API reference](/api-reference)
2594
+ * [WebSockets overview](/websockets)
2595
+
2596
+
2199
2597
  ***
2200
2598
 
2201
2599
  title: 'Guide: Sending & Receiving Email'
@@ -2289,6 +2687,11 @@ Here's the step-by-step logic for a polling-based conversational agent.
2289
2687
  const messageIdToReplyTo = lastMessage.message_id;
2290
2688
  ```
2291
2689
  </CodeBlocks>
2690
+
2691
+ <Tip>
2692
+ Use `last_message.extracted_text` (or `extracted_html`) when you need
2693
+ just the new reply content, without quoted history.
2694
+ </Tip>
2292
2695
  </Step>
2293
2696
 
2294
2697
  <Step title="3. Send the Reply and Update Labels">
@@ -3218,6 +3621,23 @@ This event-driven approach is more efficient and allows you to build fast, respo
3218
3621
  * **Real-Time Speed:** Build conversational agents that can reply to incoming emails in seconds.
3219
3622
  * **Efficiency:** Eliminates the need for constant polling, which saves you computational resources and simplifies your application logic.
3220
3623
 
3624
+ ## Available Events
3625
+
3626
+ AgentMail supports seven webhook event types. When creating a webhook, you can subscribe to specific events or receive all of them. See [Webhook Events](/events) for full payload details.
3627
+
3628
+ **Message events:**
3629
+
3630
+ * **`message.received`** — New email received and processed in one of your inboxes
3631
+ * **`message.sent`** — Message successfully sent from your inbox
3632
+ * **`message.delivered`** — Delivery confirmed by the recipient's mail server
3633
+ * **`message.bounced`** — Message failed to deliver and bounced back
3634
+ * **`message.complained`** — Recipient marked your message as spam
3635
+ * **`message.rejected`** — Message rejected before send (validation or policy)
3636
+
3637
+ **Domain events:**
3638
+
3639
+ * **`domain.verified`** — Custom domain successfully verified
3640
+
3221
3641
  ## The Webhook Workflow
3222
3642
 
3223
3643
  The process is straightforward:
@@ -3233,26 +3653,30 @@ The process is straightforward:
3233
3653
  <CodeBlocks>
3234
3654
  ```python
3235
3655
  client.webhooks.create(
3236
- url="https://<your-ngrok-url>.ngrok-free.app/webhooks"
3656
+ url="https://<your-ngrok-url>.ngrok-free.app/webhooks",
3657
+ events=["message.received", "message.sent"],
3237
3658
  )
3238
3659
  ```
3239
3660
 
3240
3661
  ```typescript
3241
3662
  await client.webhooks.create({
3242
3663
  url: "https://<your-ngrok-url>.ngrok-free.app/webhooks",
3664
+ events: ["message.received", "message.sent"],
3243
3665
  });
3244
3666
  ```
3245
3667
  </CodeBlocks>
3668
+
3669
+ Specify which events to receive; omit `events` to subscribe to all event types.
3246
3670
  </Step>
3247
3671
 
3248
3672
  <Step title="3. AgentMail Sends Events">
3249
- When a new message is received in one of your inboxes, AgentMail will immediately send a `POST` request with a JSON payload to your registered URL.
3673
+ When an event occurs (e.g. a new message is received, a message is delivered, or a domain is verified), AgentMail sends a `POST` request with a JSON payload to your registered URL.
3250
3674
  </Step>
3251
3675
  </Steps>
3252
3676
 
3253
3677
  ## Payload Structure
3254
3678
 
3255
- When AgentMail sends a webhook, the payload will have the following structure.
3679
+ When AgentMail sends a webhook, the payload includes `event_type` and `event_id`, plus event-specific data. The example below shows a `message.received` payload; other events use different top-level objects (`send`, `delivery`, `bounce`, etc.). See [Webhook Events](/events) for each event's payload shape.
3256
3680
 
3257
3681
  ```json Webhook Payload
3258
3682
  {
@@ -3294,7 +3718,7 @@ When AgentMail sends a webhook, the payload will have the following structure.
3294
3718
 
3295
3719
  ### Field Descriptions
3296
3720
 
3297
- * **`event_type`** (`string`): The name of the event. Currently, this will always be `message.received`.
3721
+ * **`event_type`** (`string`): The event type (e.g. `message.received`, `message.sent`, `message.delivered`). Payload structure varies by event—see [Webhook Events](/events) for each event's shape.
3298
3722
  * **`event_id`** (`string`): A unique identifier for this specific event delivery.
3299
3723
  * **`message`** (`object`): A dictionary containing the full details of the received email message.
3300
3724
  * **`from_`** (`array<string>`): The sender's email address. Note the trailing underscore to avoid conflict with the Python keyword.
@@ -3349,6 +3773,84 @@ All webhook payloads follow the same basic structure:
3349
3773
  }
3350
3774
  ```
3351
3775
 
3776
+ ## Parsing events with SDKs
3777
+
3778
+ The AgentMail SDKs export typed classes for each webhook event, so you can parse raw payloads into fully typed objects.
3779
+
3780
+ <CodeBlocks>
3781
+ ```typescript title="TypeScript"
3782
+ import { serialization } from "agentmail";
3783
+
3784
+ async function handleWebhook(payload: Record<string, unknown>) {
3785
+ const eventType = payload.event_type;
3786
+
3787
+ if (eventType === "message.received") {
3788
+ const event = await serialization.events.MessageReceivedEvent.parse(payload);
3789
+ // access typed fields
3790
+ console.log(event.message.subject);
3791
+ console.log(event.thread.messageCount);
3792
+ } else if (eventType === "message.sent") {
3793
+ const event = await serialization.events.MessageSentEvent.parse(payload);
3794
+ console.log(event.send.recipients);
3795
+ } else if (eventType === "message.bounced") {
3796
+ const event = await serialization.events.MessageBouncedEvent.parse(payload);
3797
+ console.log(event.bounce.type);
3798
+ } else if (eventType === "message.delivered") {
3799
+ const event = await serialization.events.MessageDeliveredEvent.parse(payload);
3800
+ console.log(event.delivery.recipients);
3801
+ } else if (eventType === "message.complained") {
3802
+ const event = await serialization.events.MessageComplainedEvent.parse(payload);
3803
+ console.log(event.complaint.type);
3804
+ } else if (eventType === "message.rejected") {
3805
+ const event = await serialization.events.MessageRejectedEvent.parse(payload);
3806
+ console.log(event.reject.reason);
3807
+ } else if (eventType === "domain.verified") {
3808
+ const event = await serialization.events.DomainVerifiedEvent.parse(payload);
3809
+ console.log(event.domain.status);
3810
+ }
3811
+ }
3812
+ ```
3813
+
3814
+ ```python title="Python"
3815
+ from agentmail import (
3816
+ MessageReceivedEvent,
3817
+ MessageSentEvent,
3818
+ MessageBouncedEvent,
3819
+ MessageDeliveredEvent,
3820
+ MessageComplainedEvent,
3821
+ MessageRejectedEvent,
3822
+ DomainVerifiedEvent,
3823
+ )
3824
+
3825
+ def handle_webhook(payload: dict):
3826
+ event_type = payload.get("event_type")
3827
+
3828
+ if event_type == "message.received":
3829
+ event = MessageReceivedEvent(**payload)
3830
+ # access typed fields
3831
+ print(event.message.subject)
3832
+ print(event.thread.message_count)
3833
+ elif event_type == "message.sent":
3834
+ event = MessageSentEvent(**payload)
3835
+ print(event.send.recipients)
3836
+ elif event_type == "message.bounced":
3837
+ event = MessageBouncedEvent(**payload)
3838
+ print(event.bounce.type)
3839
+ elif event_type == "message.delivered":
3840
+ event = MessageDeliveredEvent(**payload)
3841
+ print(event.delivery.recipients)
3842
+ elif event_type == "message.complained":
3843
+ event = MessageComplainedEvent(**payload)
3844
+ print(event.complaint.type)
3845
+ elif event_type == "message.rejected":
3846
+ event = MessageRejectedEvent(**payload)
3847
+ print(event.reject.reason)
3848
+ elif event_type == "domain.verified":
3849
+ event = DomainVerifiedEvent(**payload)
3850
+ print(event.domain.status)
3851
+ ```
3852
+ </CodeBlocks>
3853
+
3352
3854
  ## Message Events
3353
3855
 
3354
3856
  ### `message.received`
@@ -3375,26 +3877,30 @@ All webhook payloads follow the same basic structure:
3375
3877
  "message_id": "msg_123abc",
3376
3878
  "labels": ["received"],
3377
3879
  "timestamp": "2023-10-27T10:00:00Z",
3378
- "from": [
3379
- {
3380
- "name": "Jane Doe",
3381
- "email": "jane@example.com"
3382
- }
3383
- ],
3384
- "to": [
3385
- {
3386
- "name": "Support Agent",
3387
- "email": "support@agentmail.to"
3388
- }
3389
- ],
3880
+ "from": "Jane Doe <jane@example.com>",
3881
+ "to": ["Support Agent <support@agentmail.to>"],
3390
3882
  "subject": "Question about my account",
3391
3883
  "preview": "A short preview of the email text...",
3392
3884
  "text": "The full text body of the email.",
3393
3885
  "html": "<html>...</html>",
3886
+ "size": 2048,
3887
+ "updated_at": "2023-10-27T10:00:00Z",
3394
3888
  "created_at": "2023-10-27T10:00:00Z"
3395
3889
  },
3396
3890
  "thread": {
3397
- // ... thread properties
3891
+ "inbox_id": "inbox_456def",
3892
+ "thread_id": "thd_789ghi",
3893
+ "labels": ["received"],
3894
+ "timestamp": "2023-10-27T10:00:00Z",
3895
+ "senders": ["Jane Doe <jane@example.com>"],
3896
+ "recipients": ["Support Agent <support@agentmail.to>"],
3897
+ "subject": "Question about my account",
3898
+ "preview": "A short preview of the email text...",
3899
+ "last_message_id": "msg_123abc",
3900
+ "message_count": 1,
3901
+ "size": 2048,
3902
+ "updated_at": "2023-10-27T10:00:00Z",
3903
+ "created_at": "2023-10-27T10:00:00Z"
3398
3904
  }
3399
3905
  }
3400
3906
  ```
@@ -3699,6 +4205,7 @@ webhook_url = "https://your-subdomain.ngrok-free.app/webhooks"
3699
4205
 
3700
4206
  webhook = client.webhooks.create(
3701
4207
  url=webhook_url,
4208
+ events=["message.received"], # add others (e.g. message.sent) as needed
3702
4209
  client_id="webhook-demo-webhook" # Ensures idempotency
3703
4210
  )
3704
4211
 
@@ -3941,7 +4448,13 @@ The easiest way to verify webhooks is using the official Svix library, which han
3941
4448
  except WebhookVerificationError as e:
3942
4449
  return ('', 400)
3943
4450
 
3944
- # Do something with the message...
4451
+ # handle by event type (msg is the verified payload)
4452
+ if msg.get("event_type") == "message.received":
4453
+ # process incoming email...
4454
+ pass
4455
+ elif msg.get("event_type") == "domain.verified":
4456
+ # enable domain features...
4457
+ pass
3945
4458
 
3946
4459
  return ('', 204)
3947
4460
 
@@ -3975,8 +4488,12 @@ The easiest way to verify webhooks is using the official Svix library, which han
3975
4488
  const wh = new Webhook(secret);
3976
4489
  const msg = wh.verify(payload, headers);
3977
4490
 
3978
- // Do something with the message...
3979
- console.log("Webhook verified:", msg);
4491
+ // handle by event type (msg is the verified payload)
4492
+ if (msg.event_type === "message.received") {
4493
+ // process incoming email...
4494
+ } else if (msg.event_type === "domain.verified") {
4495
+ // enable domain features...
4496
+ }
3980
4497
 
3981
4498
  res.status(204).send();
3982
4499
  } catch (err) {
@@ -4031,7 +4548,13 @@ Create a webhook server file:
4031
4548
  print(f"Verification failed: {e}")
4032
4549
  return ('', 400)
4033
4550
 
4034
- # Do something with the message...
4551
+ # handle by event type (msg is the verified payload)
4552
+ if msg.get("event_type") == "message.received":
4553
+ # process incoming email...
4554
+ pass
4555
+ elif msg.get("event_type") == "domain.verified":
4556
+ # enable domain features...
4557
+ pass
4035
4558
 
4036
4559
  return ('', 204)
4037
4560
 
@@ -4064,8 +4587,12 @@ Create a webhook server file:
4064
4587
  const wh = new Webhook(secret);
4065
4588
  const msg = wh.verify(payload, headers);
4066
4589
 
4067
- // Do something with the message...
4068
- console.log("Webhook verified:", msg);
4590
+ // handle by event type (msg is the verified payload)
4591
+ if (msg.event_type === "message.received") {
4592
+ // process incoming email...
4593
+ } else if (msg.event_type === "domain.verified") {
4594
+ // enable domain features...
4595
+ }
4069
4596
 
4070
4597
  res.status(204).send();
4071
4598
  } catch (err) {
@@ -7634,6 +8161,11 @@ practices and security.
7634
8161
  [Webhooks Overview](/overview).
7635
8162
  </Accordion>
7636
8163
 
8164
+ <Accordion title="How do I get just the new content from a reply?">
8165
+ Use `extracted_text` or `extracted_html` on the Message object. AgentMail
8166
+ strips quoted text automatically, so you get only the new reply content.
8167
+ </Accordion>
8168
+
7637
8169
  <Accordion title="How do I make sure I don't end up in spam?">
7638
8170
  Email deliverability is a complex topic. We go in depth in our [Email
7639
8171
  Deliverability best practices guide](/email-deliverability).
@@ -8219,8 +8751,7 @@ and get support.
8219
8751
  </Callout>
8220
8752
 
8221
8753
 
8222
- ***
8223
-
8754
+  ---
8224
8755
  title: Support
8225
8756
  slug: support
8226
8757
  description: Get help with AgentMail through our support channels.
@@ -21862,37 +22393,34 @@ components:
21862
22393
 
21863
22394
  ## SDK Code Examples
21864
22395
 
21865
- ```python
21866
- import requests
21867
-
21868
- url = "https://api.agentmail.to/v0/lists/send/allow"
22396
+ ```typescript
22397
+ import { AgentMailClient } from "agentmail";
21869
22398
 
21870
- payload = { "entry": "entry" }
21871
- headers = {
21872
- "Authorization": "Bearer <api_key>",
21873
- "Content-Type": "application/json"
22399
+ async function main() {
22400
+ const client = new AgentMailClient({
22401
+ apiKey: "YOUR_TOKEN_HERE",
22402
+ });
22403
+ await client.lists.create("send", "allow", {
22404
+ entry: "entry",
22405
+ });
21874
22406
  }
22407
+ main();
21875
22408
 
21876
- response = requests.post(url, json=payload, headers=headers)
21877
-
21878
- print(response.json())
21879
22409
  ```
21880
22410
 
21881
- ```javascript
21882
- const url = 'https://api.agentmail.to/v0/lists/send/allow';
21883
- const options = {
21884
- method: 'POST',
21885
- headers: {Authorization: 'Bearer <api_key>', 'Content-Type': 'application/json'},
21886
- body: '{"entry":"entry"}'
21887
- };
22411
+ ```python
22412
+ from agentmail import AgentMail
22413
+
22414
+ client = AgentMail(
22415
+ api_key="YOUR_TOKEN_HERE"
22416
+ )
22417
+
22418
+ client.lists.create(
22419
+ direction="send",
22420
+ type="allow",
22421
+ entry="entry"
22422
+ )
21888
22423
 
21889
- try {
21890
- const response = await fetch(url, options);
21891
- const data = await response.json();
21892
- console.log(data);
21893
- } catch (error) {
21894
- console.error(error);
21895
- }
21896
22424
  ```
21897
22425
 
21898
22426
  ```go
@@ -22171,29 +22699,31 @@ components:
22171
22699
 
22172
22700
  ## SDK Code Examples
22173
22701
 
22174
- ```python
22175
- import requests
22702
+ ```typescript
22703
+ import { AgentMailClient } from "agentmail";
22176
22704
 
22177
- url = "https://api.agentmail.to/v0/lists/send/allow"
22705
+ async function main() {
22706
+ const client = new AgentMailClient({
22707
+ apiKey: "YOUR_TOKEN_HERE",
22708
+ });
22709
+ await client.lists.list("send", "allow", {});
22710
+ }
22711
+ main();
22178
22712
 
22179
- headers = {"Authorization": "Bearer <api_key>"}
22713
+ ```
22180
22714
 
22181
- response = requests.get(url, headers=headers)
22715
+ ```python
22716
+ from agentmail import AgentMail
22182
22717
 
22183
- print(response.json())
22184
- ```
22718
+ client = AgentMail(
22719
+ api_key="YOUR_TOKEN_HERE"
22720
+ )
22185
22721
 
22186
- ```javascript
22187
- const url = 'https://api.agentmail.to/v0/lists/send/allow';
22188
- const options = {method: 'GET', headers: {Authorization: 'Bearer <api_key>'}};
22722
+ client.lists.list(
22723
+ direction="send",
22724
+ type="allow"
22725
+ )
22189
22726
 
22190
- try {
22191
- const response = await fetch(url, options);
22192
- const data = await response.json();
22193
- console.log(data);
22194
- } catch (error) {
22195
- console.error(error);
22196
- }
22197
22727
  ```
22198
22728
 
22199
22729
  ```go
@@ -22442,29 +22972,32 @@ components:
22442
22972
 
22443
22973
  ## SDK Code Examples
22444
22974
 
22445
- ```python
22446
- import requests
22975
+ ```typescript
22976
+ import { AgentMailClient } from "agentmail";
22447
22977
 
22448
- url = "https://api.agentmail.to/v0/lists/send/allow/entry"
22978
+ async function main() {
22979
+ const client = new AgentMailClient({
22980
+ apiKey: "YOUR_TOKEN_HERE",
22981
+ });
22982
+ await client.lists.get("send", "allow", "entry");
22983
+ }
22984
+ main();
22449
22985
 
22450
- headers = {"Authorization": "Bearer <api_key>"}
22986
+ ```
22451
22987
 
22452
- response = requests.get(url, headers=headers)
22988
+ ```python
22989
+ from agentmail import AgentMail
22453
22990
 
22454
- print(response.json())
22455
- ```
22991
+ client = AgentMail(
22992
+ api_key="YOUR_TOKEN_HERE"
22993
+ )
22456
22994
 
22457
- ```javascript
22458
- const url = 'https://api.agentmail.to/v0/lists/send/allow/entry';
22459
- const options = {method: 'GET', headers: {Authorization: 'Bearer <api_key>'}};
22995
+ client.lists.get(
22996
+ direction="send",
22997
+ type="allow",
22998
+ entry="entry"
22999
+ )
22460
23000
 
22461
- try {
22462
- const response = await fetch(url, options);
22463
- const data = await response.json();
22464
- console.log(data);
22465
- } catch (error) {
22466
- console.error(error);
22467
- }
22468
23001
  ```
22469
23002
 
22470
23003
  ```go
@@ -22669,29 +23202,32 @@ components:
22669
23202
 
22670
23203
  ## SDK Code Examples
22671
23204
 
22672
- ```python
22673
- import requests
23205
+ ```typescript
23206
+ import { AgentMailClient } from "agentmail";
22674
23207
 
22675
- url = "https://api.agentmail.to/v0/lists/send/allow/entry"
23208
+ async function main() {
23209
+ const client = new AgentMailClient({
23210
+ apiKey: "YOUR_TOKEN_HERE",
23211
+ });
23212
+ await client.lists.delete("send", "allow", "entry");
23213
+ }
23214
+ main();
22676
23215
 
22677
- headers = {"Authorization": "Bearer <api_key>"}
23216
+ ```
22678
23217
 
22679
- response = requests.delete(url, headers=headers)
23218
+ ```python
23219
+ from agentmail import AgentMail
22680
23220
 
22681
- print(response.json())
22682
- ```
23221
+ client = AgentMail(
23222
+ api_key="YOUR_TOKEN_HERE"
23223
+ )
22683
23224
 
22684
- ```javascript
22685
- const url = 'https://api.agentmail.to/v0/lists/send/allow/entry';
22686
- const options = {method: 'DELETE', headers: {Authorization: 'Bearer <api_key>'}};
23225
+ client.lists.delete(
23226
+ direction="send",
23227
+ type="allow",
23228
+ entry="entry"
23229
+ )
22687
23230
 
22688
- try {
22689
- const response = await fetch(url, options);
22690
- const data = await response.json();
22691
- console.log(data);
22692
- } catch (error) {
22693
- console.error(error);
22694
- }
22695
23231
  ```
22696
23232
 
22697
23233
  ```go
@@ -33005,37 +33541,35 @@ components:
33005
33541
 
33006
33542
  ## SDK Code Examples
33007
33543
 
33008
- ```python
33009
- import requests
33010
-
33011
- url = "https://api.agentmail.to/v0/pods/pod_id/lists/send/allow"
33544
+ ```typescript
33545
+ import { AgentMailClient } from "agentmail";
33012
33546
 
33013
- payload = { "entry": "entry" }
33014
- headers = {
33015
- "Authorization": "Bearer <api_key>",
33016
- "Content-Type": "application/json"
33547
+ async function main() {
33548
+ const client = new AgentMailClient({
33549
+ apiKey: "YOUR_TOKEN_HERE",
33550
+ });
33551
+ await client.pods.lists.create("pod_id", "send", "allow", {
33552
+ entry: "entry",
33553
+ });
33017
33554
  }
33555
+ main();
33018
33556
 
33019
- response = requests.post(url, json=payload, headers=headers)
33020
-
33021
- print(response.json())
33022
33557
  ```
33023
33558
 
33024
- ```javascript
33025
- const url = 'https://api.agentmail.to/v0/pods/pod_id/lists/send/allow';
33026
- const options = {
33027
- method: 'POST',
33028
- headers: {Authorization: 'Bearer <api_key>', 'Content-Type': 'application/json'},
33029
- body: '{"entry":"entry"}'
33030
- };
33559
+ ```python
33560
+ from agentmail import AgentMail
33561
+
33562
+ client = AgentMail(
33563
+ api_key="YOUR_TOKEN_HERE"
33564
+ )
33565
+
33566
+ client.pods.lists.create(
33567
+ pod_id="pod_id",
33568
+ direction="send",
33569
+ type="allow",
33570
+ entry="entry"
33571
+ )
33031
33572
 
33032
- try {
33033
- const response = await fetch(url, options);
33034
- const data = await response.json();
33035
- console.log(data);
33036
- } catch (error) {
33037
- console.error(error);
33038
- }
33039
33573
  ```
33040
33574
 
33041
33575
  ```go
@@ -33330,29 +33864,32 @@ components:
33330
33864
 
33331
33865
  ## SDK Code Examples
33332
33866
 
33333
- ```python
33334
- import requests
33867
+ ```typescript
33868
+ import { AgentMailClient } from "agentmail";
33335
33869
 
33336
- url = "https://api.agentmail.to/v0/pods/pod_id/lists/send/allow"
33870
+ async function main() {
33871
+ const client = new AgentMailClient({
33872
+ apiKey: "YOUR_TOKEN_HERE",
33873
+ });
33874
+ await client.pods.lists.list("pod_id", "send", "allow", {});
33875
+ }
33876
+ main();
33337
33877
 
33338
- headers = {"Authorization": "Bearer <api_key>"}
33878
+ ```
33339
33879
 
33340
- response = requests.get(url, headers=headers)
33880
+ ```python
33881
+ from agentmail import AgentMail
33341
33882
 
33342
- print(response.json())
33343
- ```
33883
+ client = AgentMail(
33884
+ api_key="YOUR_TOKEN_HERE"
33885
+ )
33344
33886
 
33345
- ```javascript
33346
- const url = 'https://api.agentmail.to/v0/pods/pod_id/lists/send/allow';
33347
- const options = {method: 'GET', headers: {Authorization: 'Bearer <api_key>'}};
33887
+ client.pods.lists.list(
33888
+ pod_id="pod_id",
33889
+ direction="send",
33890
+ type="allow"
33891
+ )
33348
33892
 
33349
- try {
33350
- const response = await fetch(url, options);
33351
- const data = await response.json();
33352
- console.log(data);
33353
- } catch (error) {
33354
- console.error(error);
33355
- }
33356
33893
  ```
33357
33894
 
33358
33895
  ```go
@@ -33617,29 +34154,33 @@ components:
33617
34154
 
33618
34155
  ## SDK Code Examples
33619
34156
 
33620
- ```python
33621
- import requests
34157
+ ```typescript
34158
+ import { AgentMailClient } from "agentmail";
33622
34159
 
33623
- url = "https://api.agentmail.to/v0/pods/pod_id/lists/send/allow/entry"
34160
+ async function main() {
34161
+ const client = new AgentMailClient({
34162
+ apiKey: "YOUR_TOKEN_HERE",
34163
+ });
34164
+ await client.pods.lists.get("pod_id", "send", "allow", "entry");
34165
+ }
34166
+ main();
33624
34167
 
33625
- headers = {"Authorization": "Bearer <api_key>"}
34168
+ ```
33626
34169
 
33627
- response = requests.get(url, headers=headers)
34170
+ ```python
34171
+ from agentmail import AgentMail
33628
34172
 
33629
- print(response.json())
33630
- ```
34173
+ client = AgentMail(
34174
+ api_key="YOUR_TOKEN_HERE"
34175
+ )
33631
34176
 
33632
- ```javascript
33633
- const url = 'https://api.agentmail.to/v0/pods/pod_id/lists/send/allow/entry';
33634
- const options = {method: 'GET', headers: {Authorization: 'Bearer <api_key>'}};
34177
+ client.pods.lists.get(
34178
+ pod_id="pod_id",
34179
+ direction="send",
34180
+ type="allow",
34181
+ entry="entry"
34182
+ )
33635
34183
 
33636
- try {
33637
- const response = await fetch(url, options);
33638
- const data = await response.json();
33639
- console.log(data);
33640
- } catch (error) {
33641
- console.error(error);
33642
- }
33643
34184
  ```
33644
34185
 
33645
34186
  ```go
@@ -33853,29 +34394,33 @@ components:
33853
34394
 
33854
34395
  ## SDK Code Examples
33855
34396
 
33856
- ```python
33857
- import requests
34397
+ ```typescript
34398
+ import { AgentMailClient } from "agentmail";
33858
34399
 
33859
- url = "https://api.agentmail.to/v0/pods/pod_id/lists/send/allow/entry"
34400
+ async function main() {
34401
+ const client = new AgentMailClient({
34402
+ apiKey: "YOUR_TOKEN_HERE",
34403
+ });
34404
+ await client.pods.lists.delete("pod_id", "send", "allow", "entry");
34405
+ }
34406
+ main();
33860
34407
 
33861
- headers = {"Authorization": "Bearer <api_key>"}
34408
+ ```
33862
34409
 
33863
- response = requests.delete(url, headers=headers)
34410
+ ```python
34411
+ from agentmail import AgentMail
33864
34412
 
33865
- print(response.json())
33866
- ```
34413
+ client = AgentMail(
34414
+ api_key="YOUR_TOKEN_HERE"
34415
+ )
33867
34416
 
33868
- ```javascript
33869
- const url = 'https://api.agentmail.to/v0/pods/pod_id/lists/send/allow/entry';
33870
- const options = {method: 'DELETE', headers: {Authorization: 'Bearer <api_key>'}};
34417
+ client.pods.lists.delete(
34418
+ pod_id="pod_id",
34419
+ direction="send",
34420
+ type="allow",
34421
+ entry="entry"
34422
+ )
33871
34423
 
33872
- try {
33873
- const response = await fetch(url, options);
33874
- const data = await response.json();
33875
- console.log(data);
33876
- } catch (error) {
33877
- console.error(error);
33878
- }
33879
34424
  ```
33880
34425
 
33881
34426
  ```go