agentmail 0.3.9 → 0.4.1
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.
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/api/resources/apiKeys/client/Client.js +2 -1
- package/dist/cjs/api/resources/apiKeys/client/requests/ListApiKeysRequest.d.ts +1 -0
- package/dist/cjs/api/resources/apiKeys/types/ApiKey.d.ts +2 -0
- package/dist/cjs/api/resources/apiKeys/types/CreateApiKeyResponse.d.ts +2 -0
- package/dist/cjs/api/resources/domains/client/Client.js +2 -1
- package/dist/cjs/api/resources/domains/client/requests/ListDomainsRequest.d.ts +1 -0
- package/dist/cjs/api/resources/inboxes/client/Client.js +2 -1
- package/dist/cjs/api/resources/inboxes/client/requests/ListInboxesRequest.d.ts +1 -0
- package/dist/cjs/api/resources/inboxes/types/InboxId.d.ts +1 -1
- package/dist/cjs/api/resources/pods/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/pods/client/Client.js +17 -11
- package/dist/cjs/api/resources/pods/client/requests/ListPodsRequest.d.ts +1 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/Client.d.ts +52 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/Client.js +262 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/index.js +17 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/requests/ListApiKeysRequest.d.ts +9 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/requests/ListApiKeysRequest.js +3 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/index.d.ts +1 -0
- package/dist/cjs/api/resources/pods/resources/apiKeys/index.js +17 -0
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.js +2 -1
- package/dist/cjs/api/resources/pods/resources/domains/client/requests/ListDomainsRequest.d.ts +1 -0
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +2 -1
- package/dist/cjs/api/resources/pods/resources/inboxes/client/requests/ListInboxesRequest.d.ts +1 -0
- package/dist/cjs/api/resources/pods/resources/index.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/index.js +3 -1
- package/dist/cjs/api/resources/webhooks/client/Client.js +2 -1
- package/dist/cjs/api/resources/webhooks/client/requests/ListWebhooksRequest.d.ts +1 -0
- package/dist/cjs/serialization/resources/apiKeys/types/ApiKey.d.ts +1 -0
- package/dist/cjs/serialization/resources/apiKeys/types/ApiKey.js +1 -0
- package/dist/cjs/serialization/resources/apiKeys/types/CreateApiKeyResponse.d.ts +1 -0
- package/dist/cjs/serialization/resources/apiKeys/types/CreateApiKeyResponse.js +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/api/resources/apiKeys/client/Client.mjs +2 -1
- package/dist/esm/api/resources/apiKeys/client/requests/ListApiKeysRequest.d.mts +1 -0
- package/dist/esm/api/resources/apiKeys/types/ApiKey.d.mts +2 -0
- package/dist/esm/api/resources/apiKeys/types/CreateApiKeyResponse.d.mts +2 -0
- package/dist/esm/api/resources/domains/client/Client.mjs +2 -1
- package/dist/esm/api/resources/domains/client/requests/ListDomainsRequest.d.mts +1 -0
- package/dist/esm/api/resources/inboxes/client/Client.mjs +2 -1
- package/dist/esm/api/resources/inboxes/client/requests/ListInboxesRequest.d.mts +1 -0
- package/dist/esm/api/resources/inboxes/types/InboxId.d.mts +1 -1
- package/dist/esm/api/resources/pods/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/pods/client/Client.mjs +7 -1
- package/dist/esm/api/resources/pods/client/requests/ListPodsRequest.d.mts +1 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/Client.d.mts +52 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/Client.mjs +225 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/index.d.mts +1 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/index.mjs +1 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/requests/ListApiKeysRequest.d.mts +9 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/requests/ListApiKeysRequest.mjs +2 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/index.d.mts +1 -0
- package/dist/esm/api/resources/pods/resources/apiKeys/index.mjs +1 -0
- package/dist/esm/api/resources/pods/resources/domains/client/Client.mjs +2 -1
- package/dist/esm/api/resources/pods/resources/domains/client/requests/ListDomainsRequest.d.mts +1 -0
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +2 -1
- package/dist/esm/api/resources/pods/resources/inboxes/client/requests/ListInboxesRequest.d.mts +1 -0
- package/dist/esm/api/resources/pods/resources/index.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/index.mjs +2 -0
- package/dist/esm/api/resources/webhooks/client/Client.mjs +2 -1
- package/dist/esm/api/resources/webhooks/client/requests/ListWebhooksRequest.d.mts +1 -0
- package/dist/esm/serialization/resources/apiKeys/types/ApiKey.d.mts +1 -0
- package/dist/esm/serialization/resources/apiKeys/types/ApiKey.mjs +1 -0
- package/dist/esm/serialization/resources/apiKeys/types/CreateApiKeyResponse.d.mts +1 -0
- package/dist/esm/serialization/resources/apiKeys/types/CreateApiKeyResponse.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/llms-full.txt +1770 -73
- package/dist/llms.txt +4 -2
- package/package.json +1 -1
- package/reference.md +174 -0
package/dist/llms-full.txt
CHANGED
|
@@ -205,6 +205,107 @@ Get your API key from the [Console](https://console.agentmail.to) and replace `a
|
|
|
205
205
|
```
|
|
206
206
|
</CodeBlocks>
|
|
207
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
|
+
|
|
208
309
|
<Tip>
|
|
209
310
|
When receiving emails, messages include `extracted_text` and `extracted_html`
|
|
210
311
|
for reply content without quoted history.
|
|
@@ -308,7 +409,10 @@ This guide will walk you through installing the AgentMail SDK, authenticating wi
|
|
|
308
409
|
console.log("Email sent successfully!");
|
|
309
410
|
}
|
|
310
411
|
|
|
311
|
-
main()
|
|
412
|
+
main().catch((error) => {
|
|
413
|
+
console.error(error);
|
|
414
|
+
process.exit(1);
|
|
415
|
+
});
|
|
312
416
|
```
|
|
313
417
|
</CodeBlocks>
|
|
314
418
|
|
|
@@ -477,6 +581,72 @@ Here at AgentMail we've now made an `Inbox` an API resource, meaning you can per
|
|
|
477
581
|
domains](/guides/domains/managing-domains) to learn more.
|
|
478
582
|
</Tip>
|
|
479
583
|
|
|
584
|
+
## Copy for Cursor / Claude
|
|
585
|
+
|
|
586
|
+
Copy one of the blocks below into Cursor or Claude for complete Inboxes API knowledge in one shot.
|
|
587
|
+
|
|
588
|
+
<CodeBlocks>
|
|
589
|
+
```python title="Python"
|
|
590
|
+
"""
|
|
591
|
+
AgentMail Inboxes — copy into Cursor/Claude.
|
|
592
|
+
|
|
593
|
+
Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
594
|
+
|
|
595
|
+
API reference:
|
|
596
|
+
- inboxes.create(username?, domain?, display_name?, client_id?) — client_id for idempotent retries
|
|
597
|
+
- inboxes.get(inbox_id)
|
|
598
|
+
- inboxes.list(limit?, page_token?)
|
|
599
|
+
- inboxes.update(inbox_id, display_name)
|
|
600
|
+
- inboxes.delete(inbox_id)
|
|
601
|
+
|
|
602
|
+
Errors: SDK raises on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
603
|
+
"""
|
|
604
|
+
import os
|
|
605
|
+
from dotenv import load_dotenv
|
|
606
|
+
from agentmail import AgentMail
|
|
607
|
+
|
|
608
|
+
load_dotenv()
|
|
609
|
+
client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
610
|
+
|
|
611
|
+
# Create (client_id for idempotent retries)
|
|
612
|
+
inbox = client.inboxes.create(client_id="my-inbox-v1")
|
|
613
|
+
|
|
614
|
+
# Get, list
|
|
615
|
+
retrieved = client.inboxes.get(inbox.inbox_id)
|
|
616
|
+
all_inboxes = client.inboxes.list(limit=20)
|
|
617
|
+
print(f"Total: {all_inboxes.count}")
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
```typescript title="TypeScript"
|
|
621
|
+
/**
|
|
622
|
+
* AgentMail Inboxes — copy into Cursor/Claude.
|
|
623
|
+
*
|
|
624
|
+
* Setup: npm install agentmail dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
625
|
+
*
|
|
626
|
+
* API reference:
|
|
627
|
+
* - inboxes.create({ username?, domain?, displayName?, clientId? })
|
|
628
|
+
* - inboxes.get(inboxId)
|
|
629
|
+
* - inboxes.list({ limit?, pageToken? })
|
|
630
|
+
* - inboxes.update(inboxId, { displayName })
|
|
631
|
+
* - inboxes.delete(inboxId)
|
|
632
|
+
*
|
|
633
|
+
* Errors: SDK throws on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
634
|
+
*/
|
|
635
|
+
import { AgentMailClient } from "agentmail";
|
|
636
|
+
import "dotenv/config";
|
|
637
|
+
|
|
638
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY! });
|
|
639
|
+
|
|
640
|
+
async function main() {
|
|
641
|
+
const inbox = await client.inboxes.create({ clientId: "my-inbox-v1" });
|
|
642
|
+
const retrieved = await client.inboxes.get(inbox.inboxId);
|
|
643
|
+
const allInboxes = await client.inboxes.list({ limit: 20 });
|
|
644
|
+
console.log("Total:", allInboxes.count);
|
|
645
|
+
}
|
|
646
|
+
main();
|
|
647
|
+
```
|
|
648
|
+
</CodeBlocks>
|
|
649
|
+
|
|
480
650
|
|
|
481
651
|
***
|
|
482
652
|
|
|
@@ -659,6 +829,100 @@ You can retrieve the details of any specific `Message` by providing its ID along
|
|
|
659
829
|
|
|
660
830
|
When receiving replies or forwards, use `extracted_text` or `extracted_html` for just the new content—quoted history is stripped automatically.
|
|
661
831
|
|
|
832
|
+
## Copy for Cursor / Claude
|
|
833
|
+
|
|
834
|
+
Copy one of the blocks below into Cursor or Claude for complete Messages API knowledge in one shot.
|
|
835
|
+
|
|
836
|
+
<CodeBlocks>
|
|
837
|
+
```python title="Python"
|
|
838
|
+
"""
|
|
839
|
+
AgentMail Messages — copy into Cursor/Claude.
|
|
840
|
+
|
|
841
|
+
Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
842
|
+
|
|
843
|
+
API reference:
|
|
844
|
+
- messages.send(inbox_id, to, subject, text, html?, cc?, bcc?, reply_to?, labels?, attachments?)
|
|
845
|
+
- messages.list(inbox_id, limit?, page_token?, labels?)
|
|
846
|
+
- messages.get(inbox_id, message_id)
|
|
847
|
+
- messages.reply(inbox_id, message_id, text, html?, attachments?, reply_all?)
|
|
848
|
+
- messages.forward(inbox_id, message_id, to, subject?, text?, html?)
|
|
849
|
+
- messages.update(inbox_id, message_id, add_labels?, remove_labels?)
|
|
850
|
+
- messages.get_attachment(inbox_id, message_id, attachment_id)
|
|
851
|
+
- messages.get_raw(inbox_id, message_id)
|
|
852
|
+
|
|
853
|
+
Reply content: use extracted_text/extracted_html for new content without quoted history.
|
|
854
|
+
Errors: SDK raises on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
855
|
+
"""
|
|
856
|
+
import os
|
|
857
|
+
from dotenv import load_dotenv
|
|
858
|
+
from agentmail import AgentMail
|
|
859
|
+
|
|
860
|
+
load_dotenv()
|
|
861
|
+
client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
862
|
+
|
|
863
|
+
inbox_id = "agent@agentmail.to"
|
|
864
|
+
|
|
865
|
+
# Send
|
|
866
|
+
sent = client.inboxes.messages.send(inbox_id, to="user@example.com", subject="Hi", text="Body", labels=["outreach"])
|
|
867
|
+
print(sent.message_id, sent.thread_id)
|
|
868
|
+
|
|
869
|
+
# List, get
|
|
870
|
+
res = client.inboxes.messages.list(inbox_id, limit=10)
|
|
871
|
+
for msg in res.messages:
|
|
872
|
+
content = msg.extracted_text or msg.text
|
|
873
|
+
msg = client.inboxes.messages.get(inbox_id, res.messages[0].message_id)
|
|
874
|
+
|
|
875
|
+
# Reply
|
|
876
|
+
reply = client.inboxes.messages.reply(inbox_id, msg.message_id, text="Thanks!")
|
|
877
|
+
```
|
|
878
|
+
|
|
879
|
+
```typescript title="TypeScript"
|
|
880
|
+
/**
|
|
881
|
+
* AgentMail Messages — copy into Cursor/Claude.
|
|
882
|
+
*
|
|
883
|
+
* Setup: npm install agentmail dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
884
|
+
*
|
|
885
|
+
* API reference:
|
|
886
|
+
* - messages.send(inboxId, { to, subject, text, html?, cc?, bcc?, replyTo?, labels?, attachments? })
|
|
887
|
+
* - messages.list(inboxId, { limit?, pageToken?, labels? })
|
|
888
|
+
* - messages.get(inboxId, messageId)
|
|
889
|
+
* - messages.reply(inboxId, messageId, { text, html?, attachments?, replyAll? })
|
|
890
|
+
* - messages.forward(inboxId, messageId, { to, subject?, text?, html? })
|
|
891
|
+
* - messages.update(inboxId, messageId, { addLabels?, removeLabels? })
|
|
892
|
+
* - messages.getAttachment(inboxId, messageId, attachmentId)
|
|
893
|
+
* - messages.getRaw(inboxId, messageId)
|
|
894
|
+
*
|
|
895
|
+
* Reply content: use extractedText/extractedHtml for new content without quoted history.
|
|
896
|
+
* Errors: SDK throws on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
897
|
+
*/
|
|
898
|
+
import { AgentMailClient } from "agentmail";
|
|
899
|
+
import "dotenv/config";
|
|
900
|
+
|
|
901
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY! });
|
|
902
|
+
|
|
903
|
+
async function main() {
|
|
904
|
+
const inboxId = "agent@agentmail.to";
|
|
905
|
+
|
|
906
|
+
const sent = await client.inboxes.messages.send(inboxId, {
|
|
907
|
+
to: "user@example.com",
|
|
908
|
+
subject: "Hi",
|
|
909
|
+
text: "Body",
|
|
910
|
+
labels: ["outreach"],
|
|
911
|
+
});
|
|
912
|
+
console.log(sent.messageId, sent.threadId);
|
|
913
|
+
|
|
914
|
+
const res = await client.inboxes.messages.list(inboxId, { limit: 10 });
|
|
915
|
+
for (const msg of res.messages) {
|
|
916
|
+
const content = msg.extractedText ?? msg.text;
|
|
917
|
+
}
|
|
918
|
+
const msg = await client.inboxes.messages.get(inboxId, res.messages[0].messageId);
|
|
919
|
+
|
|
920
|
+
await client.inboxes.messages.reply(inboxId, msg.messageId, { text: "Thanks!" });
|
|
921
|
+
}
|
|
922
|
+
main();
|
|
923
|
+
```
|
|
924
|
+
</CodeBlocks>
|
|
925
|
+
|
|
662
926
|
### Crafting Your Message: HTML, Text, and CSS
|
|
663
927
|
|
|
664
928
|
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.
|
|
@@ -929,6 +1193,89 @@ You can also retrieve a single `Thread` by its ID. This will return the `Thread`
|
|
|
929
1193
|
```
|
|
930
1194
|
</CodeBlocks>
|
|
931
1195
|
|
|
1196
|
+
## Copy for Cursor / Claude
|
|
1197
|
+
|
|
1198
|
+
Copy one of the blocks below into Cursor or Claude for complete Threads API knowledge in one shot.
|
|
1199
|
+
|
|
1200
|
+
<CodeBlocks>
|
|
1201
|
+
```python title="Python"
|
|
1202
|
+
"""
|
|
1203
|
+
AgentMail Threads — copy into Cursor/Claude.
|
|
1204
|
+
|
|
1205
|
+
Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
1206
|
+
|
|
1207
|
+
API reference:
|
|
1208
|
+
- inboxes.threads.list(inbox_id, limit?, page_token?, labels?, before?, after?, ascending?)
|
|
1209
|
+
- inboxes.threads.get(inbox_id, thread_id)
|
|
1210
|
+
- inboxes.threads.get_attachment(inbox_id, thread_id, attachment_id)
|
|
1211
|
+
- inboxes.threads.delete(inbox_id, thread_id)
|
|
1212
|
+
- threads.list(limit?, page_token?, labels?) — org-wide, all inboxes
|
|
1213
|
+
- threads.get(thread_id) — org-wide
|
|
1214
|
+
- threads.get_attachment(thread_id, attachment_id)
|
|
1215
|
+
|
|
1216
|
+
Errors: SDK raises on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
1217
|
+
"""
|
|
1218
|
+
import os
|
|
1219
|
+
from dotenv import load_dotenv
|
|
1220
|
+
from agentmail import AgentMail
|
|
1221
|
+
|
|
1222
|
+
load_dotenv()
|
|
1223
|
+
client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
1224
|
+
|
|
1225
|
+
inbox_id = "agent@agentmail.to"
|
|
1226
|
+
|
|
1227
|
+
# Per-inbox threads
|
|
1228
|
+
inbox_threads = client.inboxes.threads.list(inbox_id=inbox_id, limit=20)
|
|
1229
|
+
if inbox_threads.threads:
|
|
1230
|
+
thread = client.inboxes.threads.get(inbox_id, inbox_threads.threads[0].thread_id)
|
|
1231
|
+
|
|
1232
|
+
# Org-wide threads
|
|
1233
|
+
all_threads = client.threads.list(limit=50)
|
|
1234
|
+
if all_threads.threads:
|
|
1235
|
+
single = client.threads.get(all_threads.threads[0].thread_id)
|
|
1236
|
+
print(f"Thread has {len(single.messages)} messages")
|
|
1237
|
+
```
|
|
1238
|
+
|
|
1239
|
+
```typescript title="TypeScript"
|
|
1240
|
+
/**
|
|
1241
|
+
* AgentMail Threads — copy into Cursor/Claude.
|
|
1242
|
+
*
|
|
1243
|
+
* Setup: npm install agentmail dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
1244
|
+
*
|
|
1245
|
+
* API reference:
|
|
1246
|
+
* - inboxes.threads.list(inboxId, { limit?, pageToken?, labels?, before?, after?, ascending? })
|
|
1247
|
+
* - inboxes.threads.get(inboxId, threadId)
|
|
1248
|
+
* - inboxes.threads.getAttachment(inboxId, threadId, attachmentId)
|
|
1249
|
+
* - inboxes.threads.delete(inboxId, threadId)
|
|
1250
|
+
* - threads.list({ limit?, pageToken?, labels? }) — org-wide
|
|
1251
|
+
* - threads.get(threadId) — org-wide
|
|
1252
|
+
* - threads.getAttachment(threadId, attachmentId)
|
|
1253
|
+
*
|
|
1254
|
+
* Errors: SDK throws on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
1255
|
+
*/
|
|
1256
|
+
import { AgentMailClient } from "agentmail";
|
|
1257
|
+
import "dotenv/config";
|
|
1258
|
+
|
|
1259
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY! });
|
|
1260
|
+
|
|
1261
|
+
async function main() {
|
|
1262
|
+
const inboxId = "agent@agentmail.to";
|
|
1263
|
+
|
|
1264
|
+
const inboxThreads = await client.inboxes.threads.list(inboxId, { limit: 20 });
|
|
1265
|
+
if (inboxThreads.threads.length > 0) {
|
|
1266
|
+
const thread = await client.inboxes.threads.get(inboxId, inboxThreads.threads[0].threadId);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
const allThreads = await client.threads.list({ limit: 50 });
|
|
1270
|
+
if (allThreads.threads.length > 0) {
|
|
1271
|
+
const single = await client.threads.get(allThreads.threads[0].threadId);
|
|
1272
|
+
console.log("Thread has", single.messages.length, "messages");
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
main();
|
|
1276
|
+
```
|
|
1277
|
+
</CodeBlocks>
|
|
1278
|
+
|
|
932
1279
|
|
|
933
1280
|
***
|
|
934
1281
|
|
|
@@ -1059,6 +1406,84 @@ Similar to `Threads`, you can list all `Drafts` across your entire `Organization
|
|
|
1059
1406
|
```
|
|
1060
1407
|
</CodeBlocks>
|
|
1061
1408
|
|
|
1409
|
+
## Copy for Cursor / Claude
|
|
1410
|
+
|
|
1411
|
+
Copy one of the blocks below into Cursor or Claude for complete Drafts API knowledge in one shot.
|
|
1412
|
+
|
|
1413
|
+
<CodeBlocks>
|
|
1414
|
+
```python title="Python"
|
|
1415
|
+
"""
|
|
1416
|
+
AgentMail Drafts — copy into Cursor/Claude.
|
|
1417
|
+
|
|
1418
|
+
Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
1419
|
+
|
|
1420
|
+
API reference:
|
|
1421
|
+
- inboxes.drafts.create(inbox_id, to, subject?, text?, html?, cc?, bcc?, reply_to?, attachments?)
|
|
1422
|
+
- inboxes.drafts.get(inbox_id, draft_id)
|
|
1423
|
+
- inboxes.drafts.update(inbox_id, draft_id, to?, subject?, text?, html?, ...)
|
|
1424
|
+
- inboxes.drafts.send(inbox_id, draft_id) — converts to Message, deletes draft
|
|
1425
|
+
- inboxes.drafts.delete(inbox_id, draft_id)
|
|
1426
|
+
- inboxes.drafts.list(inbox_id, limit?, page_token?, labels?)
|
|
1427
|
+
- drafts.list(limit?, page_token?) — org-wide
|
|
1428
|
+
|
|
1429
|
+
Errors: SDK raises on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
1430
|
+
"""
|
|
1431
|
+
import os
|
|
1432
|
+
from dotenv import load_dotenv
|
|
1433
|
+
from agentmail import AgentMail
|
|
1434
|
+
|
|
1435
|
+
load_dotenv()
|
|
1436
|
+
client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
1437
|
+
|
|
1438
|
+
inbox_id = "agent@agentmail.to"
|
|
1439
|
+
|
|
1440
|
+
draft = client.inboxes.drafts.create(inbox_id, to=["review@example.com"], subject="[REVIEW] Proposed reply")
|
|
1441
|
+
retrieved = client.inboxes.drafts.get(inbox_id, draft.draft_id)
|
|
1442
|
+
sent = client.inboxes.drafts.send(inbox_id, draft.draft_id)
|
|
1443
|
+
print(sent.message_id)
|
|
1444
|
+
|
|
1445
|
+
all_drafts = client.drafts.list()
|
|
1446
|
+
```
|
|
1447
|
+
|
|
1448
|
+
```typescript title="TypeScript"
|
|
1449
|
+
/**
|
|
1450
|
+
* AgentMail Drafts — copy into Cursor/Claude.
|
|
1451
|
+
*
|
|
1452
|
+
* Setup: npm install agentmail dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
1453
|
+
*
|
|
1454
|
+
* API reference:
|
|
1455
|
+
* - inboxes.drafts.create(inboxId, { to, subject?, text?, html?, cc?, bcc?, replyTo?, attachments? })
|
|
1456
|
+
* - inboxes.drafts.get(inboxId, draftId)
|
|
1457
|
+
* - inboxes.drafts.update(inboxId, draftId, { to?, subject?, text?, html?, ... })
|
|
1458
|
+
* - inboxes.drafts.send(inboxId, draftId) — converts to Message, deletes draft
|
|
1459
|
+
* - inboxes.drafts.delete(inboxId, draftId)
|
|
1460
|
+
* - inboxes.drafts.list(inboxId, { limit?, pageToken?, labels? })
|
|
1461
|
+
* - drafts.list({ limit?, pageToken? }) — org-wide
|
|
1462
|
+
*
|
|
1463
|
+
* Errors: SDK throws on 4xx/5xx. Rate limit: 429 with Retry-After.
|
|
1464
|
+
*/
|
|
1465
|
+
import { AgentMailClient } from "agentmail";
|
|
1466
|
+
import "dotenv/config";
|
|
1467
|
+
|
|
1468
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY! });
|
|
1469
|
+
|
|
1470
|
+
async function main() {
|
|
1471
|
+
const inboxId = "agent@agentmail.to";
|
|
1472
|
+
|
|
1473
|
+
const draft = await client.inboxes.drafts.create(inboxId, {
|
|
1474
|
+
to: ["review@example.com"],
|
|
1475
|
+
subject: "[REVIEW] Proposed reply",
|
|
1476
|
+
});
|
|
1477
|
+
const retrieved = await client.inboxes.drafts.get(inboxId, draft.draftId);
|
|
1478
|
+
const sent = await client.inboxes.drafts.send(inboxId, draft.draftId);
|
|
1479
|
+
console.log(sent.messageId);
|
|
1480
|
+
|
|
1481
|
+
const allDrafts = await client.drafts.list();
|
|
1482
|
+
}
|
|
1483
|
+
main();
|
|
1484
|
+
```
|
|
1485
|
+
</CodeBlocks>
|
|
1486
|
+
|
|
1062
1487
|
|
|
1063
1488
|
***
|
|
1064
1489
|
|
|
@@ -1206,6 +1631,70 @@ This is where `Labels` become truly powerful. You can list `Threads`, `Messages`
|
|
|
1206
1631
|
```
|
|
1207
1632
|
</CodeBlocks>
|
|
1208
1633
|
|
|
1634
|
+
## Copy for Cursor / Claude
|
|
1635
|
+
|
|
1636
|
+
Copy one of the blocks below into Cursor or Claude for complete Labels usage in one shot.
|
|
1637
|
+
|
|
1638
|
+
<CodeBlocks>
|
|
1639
|
+
```python title="Python"
|
|
1640
|
+
"""
|
|
1641
|
+
AgentMail Labels — copy into Cursor/Claude.
|
|
1642
|
+
|
|
1643
|
+
Labels are string tags on Messages and Threads for state, campaigns, triage.
|
|
1644
|
+
|
|
1645
|
+
- Send: messages.send(..., labels=["campaign", "follow-up"])
|
|
1646
|
+
- Update: inboxes.messages.update(inbox_id, message_id, add_labels=[...], remove_labels=[...])
|
|
1647
|
+
- Filter: messages.list(inbox_id, labels=[...]), threads.list(inbox_id, labels=[...]), drafts.list(inbox_id, labels=[...])
|
|
1648
|
+
|
|
1649
|
+
Use kebab-case or snake_case consistently.
|
|
1650
|
+
"""
|
|
1651
|
+
from agentmail import AgentMail
|
|
1652
|
+
|
|
1653
|
+
client = AgentMail(api_key="YOUR_API_KEY")
|
|
1654
|
+
|
|
1655
|
+
# Send with labels
|
|
1656
|
+
client.inboxes.messages.send("out@agentmail.to", to="user@example.com", subject="Hi", text="Body", labels=["q4-campaign"])
|
|
1657
|
+
|
|
1658
|
+
# Update labels
|
|
1659
|
+
client.inboxes.messages.update("out@agentmail.to", "msg_123", add_labels=["resolved"], remove_labels=["pending"])
|
|
1660
|
+
|
|
1661
|
+
# Filter by labels
|
|
1662
|
+
threads = client.inboxes.threads.list("out@agentmail.to", labels=["q4-campaign", "follow-up"])
|
|
1663
|
+
```
|
|
1664
|
+
|
|
1665
|
+
```typescript title="TypeScript"
|
|
1666
|
+
/**
|
|
1667
|
+
* AgentMail Labels — copy into Cursor/Claude.
|
|
1668
|
+
*
|
|
1669
|
+
* Labels are string tags on Messages and Threads for state, campaigns, triage.
|
|
1670
|
+
*
|
|
1671
|
+
* - Send: messages.send(inboxId, { ..., labels: ["campaign", "follow-up"] })
|
|
1672
|
+
* - Update: messages.update(inboxId, messageId, { addLabels: [...], removeLabels: [...] })
|
|
1673
|
+
* - Filter: messages.list(inboxId, { labels: [...] }), threads.list(inboxId, { labels: [...] }), drafts.list(inboxId, { labels: [...] })
|
|
1674
|
+
*
|
|
1675
|
+
* Use kebab-case or camelCase consistently.
|
|
1676
|
+
*/
|
|
1677
|
+
import { AgentMailClient } from "agentmail";
|
|
1678
|
+
|
|
1679
|
+
const client = new AgentMailClient({ apiKey: "YOUR_API_KEY" });
|
|
1680
|
+
|
|
1681
|
+
async function main() {
|
|
1682
|
+
await client.inboxes.messages.send("out@agentmail.to", {
|
|
1683
|
+
to: "user@example.com",
|
|
1684
|
+
subject: "Hi",
|
|
1685
|
+
text: "Body",
|
|
1686
|
+
labels: ["q4-campaign"],
|
|
1687
|
+
});
|
|
1688
|
+
await client.inboxes.messages.update("out@agentmail.to", "msg_123", {
|
|
1689
|
+
addLabels: ["resolved"],
|
|
1690
|
+
removeLabels: ["pending"],
|
|
1691
|
+
});
|
|
1692
|
+
const threads = await client.inboxes.threads.list("out@agentmail.to", { labels: ["q4-campaign", "follow-up"] });
|
|
1693
|
+
}
|
|
1694
|
+
main();
|
|
1695
|
+
```
|
|
1696
|
+
</CodeBlocks>
|
|
1697
|
+
|
|
1209
1698
|
## Best Practices
|
|
1210
1699
|
|
|
1211
1700
|
* **Be Consistent:** Establish a clear and consistent naming convention for your labels (e.g., `kebab-case`, `snake_case`).
|
|
@@ -1312,6 +1801,65 @@ Remove an entry from a list.
|
|
|
1312
1801
|
```
|
|
1313
1802
|
</CodeBlocks>
|
|
1314
1803
|
|
|
1804
|
+
## Copy for Cursor / Claude
|
|
1805
|
+
|
|
1806
|
+
Copy one of the blocks below into Cursor or Claude for complete Lists API knowledge in one shot.
|
|
1807
|
+
|
|
1808
|
+
<CodeBlocks>
|
|
1809
|
+
```python title="Python"
|
|
1810
|
+
"""
|
|
1811
|
+
AgentMail Lists — copy into Cursor/Claude.
|
|
1812
|
+
|
|
1813
|
+
Filter emails by allow/block for send/receive. Types: receive|send × allow|block.
|
|
1814
|
+
|
|
1815
|
+
API reference:
|
|
1816
|
+
- lists.list(direction, type, limit?, page_token?)
|
|
1817
|
+
- lists.create(direction, type, entry, reason?) — reason only for block lists
|
|
1818
|
+
- lists.get(direction, type, entry)
|
|
1819
|
+
- lists.delete(direction, type, entry)
|
|
1820
|
+
|
|
1821
|
+
Entry: full email (user@domain.com) or domain (example.com).
|
|
1822
|
+
"""
|
|
1823
|
+
from agentmail import AgentMail
|
|
1824
|
+
|
|
1825
|
+
client = AgentMail(api_key="YOUR_API_KEY")
|
|
1826
|
+
|
|
1827
|
+
entries = client.lists.list("receive", "allow", limit=10)
|
|
1828
|
+
client.lists.create("receive", "allow", entry="partner@example.com")
|
|
1829
|
+
client.lists.create("receive", "block", entry="spam@example.com", reason="spam")
|
|
1830
|
+
e = client.lists.get("receive", "allow", entry="partner@example.com")
|
|
1831
|
+
client.lists.delete("receive", "allow", entry="partner@example.com")
|
|
1832
|
+
```
|
|
1833
|
+
|
|
1834
|
+
```typescript title="TypeScript"
|
|
1835
|
+
/**
|
|
1836
|
+
* AgentMail Lists — copy into Cursor/Claude.
|
|
1837
|
+
*
|
|
1838
|
+
* Filter emails by allow/block for send/receive. Types: receive|send × allow|block.
|
|
1839
|
+
*
|
|
1840
|
+
* API reference:
|
|
1841
|
+
* - lists.list(direction, type, { limit?, pageToken? })
|
|
1842
|
+
* - lists.create(direction, type, { entry, reason? }) — reason only for block
|
|
1843
|
+
* - lists.get(direction, type, entry)
|
|
1844
|
+
* - lists.delete(direction, type, entry)
|
|
1845
|
+
*
|
|
1846
|
+
* Entry: full email or domain.
|
|
1847
|
+
*/
|
|
1848
|
+
import { AgentMailClient } from "agentmail";
|
|
1849
|
+
|
|
1850
|
+
const client = new AgentMailClient({ apiKey: "YOUR_API_KEY" });
|
|
1851
|
+
|
|
1852
|
+
async function main() {
|
|
1853
|
+
const entries = await client.lists.list("receive", "allow", { limit: 10 });
|
|
1854
|
+
await client.lists.create("receive", "allow", { entry: "partner@example.com" });
|
|
1855
|
+
await client.lists.create("receive", "block", { entry: "spam@example.com", reason: "spam" });
|
|
1856
|
+
const e = await client.lists.get("receive", "allow", "partner@example.com");
|
|
1857
|
+
await client.lists.delete("receive", "allow", "partner@example.com");
|
|
1858
|
+
}
|
|
1859
|
+
main();
|
|
1860
|
+
```
|
|
1861
|
+
</CodeBlocks>
|
|
1862
|
+
|
|
1315
1863
|
|
|
1316
1864
|
***
|
|
1317
1865
|
|
|
@@ -1458,6 +2006,66 @@ Similarly, you can retrieve an `Attachment` if you know the `Thread` it's in, wh
|
|
|
1458
2006
|
```
|
|
1459
2007
|
</CodeBlocks>
|
|
1460
2008
|
|
|
2009
|
+
## Copy for Cursor / Claude
|
|
2010
|
+
|
|
2011
|
+
Copy one of the blocks below into Cursor or Claude for complete Attachments usage in one shot.
|
|
2012
|
+
|
|
2013
|
+
<CodeBlocks>
|
|
2014
|
+
```python title="Python"
|
|
2015
|
+
"""
|
|
2016
|
+
AgentMail Attachments — copy into Cursor/Claude.
|
|
2017
|
+
|
|
2018
|
+
Send: attachments=[{ content: base64_string, filename?, content_type? }] in messages.send/reply.
|
|
2019
|
+
Get attachment_id from message.attachments or thread.attachments.
|
|
2020
|
+
|
|
2021
|
+
- messages.get_attachment(inbox_id, message_id, attachment_id) → bytes
|
|
2022
|
+
- threads.get_attachment(inbox_id, thread_id, attachment_id) → bytes
|
|
2023
|
+
"""
|
|
2024
|
+
import base64
|
|
2025
|
+
from agentmail import AgentMail
|
|
2026
|
+
|
|
2027
|
+
client = AgentMail(api_key="YOUR_API_KEY")
|
|
2028
|
+
|
|
2029
|
+
encoded = base64.b64encode(b"file content").decode()
|
|
2030
|
+
client.inboxes.messages.send(
|
|
2031
|
+
"agent@agentmail.to",
|
|
2032
|
+
to="user@example.com",
|
|
2033
|
+
subject="Report",
|
|
2034
|
+
text="See attachment",
|
|
2035
|
+
attachments=[{"content": encoded, "filename": "report.txt", "content_type": "text/plain"}],
|
|
2036
|
+
)
|
|
2037
|
+
|
|
2038
|
+
data = client.inboxes.messages.get_attachment("inbox@am.to", "msg_123", "att_456")
|
|
2039
|
+
with open("downloaded.pdf", "wb") as f:
|
|
2040
|
+
f.write(data)
|
|
2041
|
+
```
|
|
2042
|
+
|
|
2043
|
+
```typescript title="TypeScript"
|
|
2044
|
+
/**
|
|
2045
|
+
* AgentMail Attachments — copy into Cursor/Claude.
|
|
2046
|
+
*
|
|
2047
|
+
* Send: attachments: [{ content: base64String, filename?, contentType? }] in messages.send/reply.
|
|
2048
|
+
* Get attachmentId from message.attachments or thread.attachments.
|
|
2049
|
+
*
|
|
2050
|
+
* - messages.get_attachment(inboxId, messageId, attachmentId) → Buffer/Blob
|
|
2051
|
+
* - threads.get_attachment(inboxId, threadId, attachmentId) → Buffer/Blob
|
|
2052
|
+
*/
|
|
2053
|
+
import { AgentMailClient } from "agentmail";
|
|
2054
|
+
|
|
2055
|
+
const client = new AgentMailClient({ apiKey: "YOUR_API_KEY" });
|
|
2056
|
+
|
|
2057
|
+
const encoded = Buffer.from("file content").toString("base64");
|
|
2058
|
+
await client.inboxes.messages.send("agent@agentmail.to", {
|
|
2059
|
+
to: "user@example.com",
|
|
2060
|
+
subject: "Report",
|
|
2061
|
+
text: "See attachment",
|
|
2062
|
+
attachments: [{ content: encoded, filename: "report.txt", contentType: "text/plain" }],
|
|
2063
|
+
});
|
|
2064
|
+
|
|
2065
|
+
const data = await client.inboxes.messages.get_attachment("inbox@am.to", "msg_123", "att_456");
|
|
2066
|
+
```
|
|
2067
|
+
</CodeBlocks>
|
|
2068
|
+
|
|
1461
2069
|
|
|
1462
2070
|
***
|
|
1463
2071
|
|
|
@@ -1559,6 +2167,61 @@ This gives you a unified view of all activity within a customer's workspace, mak
|
|
|
1559
2167
|
* "List all threads across all of Customer Y's team inboxes"
|
|
1560
2168
|
* "Display all pending drafts for Customer Z"
|
|
1561
2169
|
|
|
2170
|
+
## Copy for Cursor / Claude
|
|
2171
|
+
|
|
2172
|
+
Copy one of the blocks below into Cursor or Claude for complete Pods API knowledge in one shot.
|
|
2173
|
+
|
|
2174
|
+
<CodeBlocks>
|
|
2175
|
+
```python title="Python"
|
|
2176
|
+
"""
|
|
2177
|
+
AgentMail Pods — copy into Cursor/Claude. Multi-tenant isolation.
|
|
2178
|
+
|
|
2179
|
+
API reference:
|
|
2180
|
+
- pods.create(client_id?) — client_id for idempotent mapping to your tenant IDs
|
|
2181
|
+
- pods.get(pod_id), pods.list(limit?, page_token?), pods.delete(pod_id)
|
|
2182
|
+
- pods.inboxes.list(pod_id, ...), pods.inboxes.create(pod_id, ...), pods.inboxes.delete(pod_id, inbox_id)
|
|
2183
|
+
- pods.domains.list(pod_id, ...), pods.domains.create(pod_id, ...), pods.domains.delete(pod_id, domain_id)
|
|
2184
|
+
- pods.threads.list(pod_id, ...), pods.drafts.list(pod_id, ...)
|
|
2185
|
+
|
|
2186
|
+
Delete order: inboxes + domains first, then pod. Deleting inbox/domain cascades to messages/threads.
|
|
2187
|
+
"""
|
|
2188
|
+
from agentmail import AgentMail
|
|
2189
|
+
|
|
2190
|
+
client = AgentMail(api_key="YOUR_API_KEY")
|
|
2191
|
+
|
|
2192
|
+
pod = client.pods.create(client_id="tenant-acme-1")
|
|
2193
|
+
inboxes = client.pods.inboxes.list(pod.pod_id)
|
|
2194
|
+
inbox = client.pods.inboxes.create(pod.pod_id, username="support", display_name="Support")
|
|
2195
|
+
threads = client.pods.threads.list(pod.pod_id, limit=20)
|
|
2196
|
+
```
|
|
2197
|
+
|
|
2198
|
+
```typescript title="TypeScript"
|
|
2199
|
+
/**
|
|
2200
|
+
* AgentMail Pods — copy into Cursor/Claude. Multi-tenant isolation.
|
|
2201
|
+
*
|
|
2202
|
+
* API reference:
|
|
2203
|
+
* - pods.create({ clientId? })
|
|
2204
|
+
* - pods.get(podId), pods.list({ limit?, pageToken? }), pods.delete(podId)
|
|
2205
|
+
* - pods.inboxes.list(podId, ...), pods.inboxes.create(podId, ...), pods.inboxes.delete(podId, inboxId)
|
|
2206
|
+
* - pods.domains.list(podId, ...), pods.domains.create(podId, ...), pods.domains.delete(podId, domainId)
|
|
2207
|
+
* - pods.threads.list(podId, ...), pods.drafts.list(podId, ...)
|
|
2208
|
+
*
|
|
2209
|
+
* Delete order: inboxes + domains first, then pod.
|
|
2210
|
+
*/
|
|
2211
|
+
import { AgentMailClient } from "agentmail";
|
|
2212
|
+
|
|
2213
|
+
const client = new AgentMailClient({ apiKey: "YOUR_API_KEY" });
|
|
2214
|
+
|
|
2215
|
+
async function main() {
|
|
2216
|
+
const pod = await client.pods.create({ clientId: "tenant-acme-1" });
|
|
2217
|
+
const inboxes = await client.pods.inboxes.list(pod.podId);
|
|
2218
|
+
const inbox = await client.pods.inboxes.create(pod.podId, { username: "support", displayName: "Support" });
|
|
2219
|
+
const threads = await client.pods.threads.list(pod.podId, { limit: 20 });
|
|
2220
|
+
}
|
|
2221
|
+
main();
|
|
2222
|
+
```
|
|
2223
|
+
</CodeBlocks>
|
|
2224
|
+
|
|
1562
2225
|
## Important Considerations
|
|
1563
2226
|
|
|
1564
2227
|
### Pod Deletion Constraints
|
|
@@ -1699,36 +2362,318 @@ Pod: "Marketing-Agent"
|
|
|
1699
2362
|
* Explore [Domains](/custom-domains) to set up custom email domains for your pods
|
|
1700
2363
|
|
|
1701
2364
|
|
|
2365
|
+
***
|
|
2366
|
+
|
|
2367
|
+
title: AI Onboarding
|
|
2368
|
+
subtitle: Everything you need to onboard your AI agent to AgentMail
|
|
2369
|
+
slug: ai-onboarding
|
|
2370
|
+
description: >-
|
|
2371
|
+
Resources for AI coding assistants, MCP servers, skills, and agent-friendly
|
|
2372
|
+
documentation.
|
|
2373
|
+
--------------
|
|
2374
|
+
|
|
2375
|
+
> Everything you need to onboard your AI agent to AgentMail — the email platform built for AI agents.
|
|
2376
|
+
|
|
2377
|
+
If you're developing with AI, AgentMail offers several resources to improve your experience.
|
|
2378
|
+
|
|
2379
|
+
## Prerequisite: Create an API Key
|
|
2380
|
+
|
|
2381
|
+
You'll need a human to create an AgentMail account at [console.agentmail.to](https://console.agentmail.to). Once you have an account, create an API key from the dashboard. With an API key, your agent can create inboxes, send and receive emails, manage threads, and more.
|
|
2382
|
+
|
|
2383
|
+
<Info>
|
|
2384
|
+
AgentMail's free tier includes 3 inboxes and 3,000 emails/month. Your agent can start building immediately.
|
|
2385
|
+
</Info>
|
|
2386
|
+
|
|
2387
|
+
## AgentMail MCP Server
|
|
2388
|
+
|
|
2389
|
+
MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs. The AgentMail MCP server gives your AI agent tools to create inboxes, send emails, manage threads, and more.
|
|
2390
|
+
|
|
2391
|
+
### Setup
|
|
2392
|
+
|
|
2393
|
+
Add this to your MCP client configuration (Claude Code, Cursor, Codex, etc.):
|
|
2394
|
+
|
|
2395
|
+
```json
|
|
2396
|
+
{
|
|
2397
|
+
"mcpServers": {
|
|
2398
|
+
"AgentMail": {
|
|
2399
|
+
"command": "npx",
|
|
2400
|
+
"args": ["-y", "agentmail-mcp"],
|
|
2401
|
+
"env": {
|
|
2402
|
+
"AGENTMAIL_API_KEY": "YOUR_API_KEY"
|
|
2403
|
+
}
|
|
2404
|
+
}
|
|
2405
|
+
}
|
|
2406
|
+
}
|
|
2407
|
+
```
|
|
2408
|
+
|
|
2409
|
+
You can selectively enable specific tools using the `--tools` argument:
|
|
2410
|
+
|
|
2411
|
+
```json
|
|
2412
|
+
{
|
|
2413
|
+
"mcpServers": {
|
|
2414
|
+
"AgentMail": {
|
|
2415
|
+
"command": "npx",
|
|
2416
|
+
"args": ["-y", "agentmail-mcp", "--tools", "get_message,send_message,reply_to_message"],
|
|
2417
|
+
"env": {
|
|
2418
|
+
"AGENTMAIL_API_KEY": "YOUR_API_KEY"
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
```
|
|
2424
|
+
|
|
2425
|
+
### Available MCP Tools
|
|
2426
|
+
|
|
2427
|
+
| Tool | Description |
|
|
2428
|
+
| ------------------ | ------------------------------------- |
|
|
2429
|
+
| `create_inbox` | Create a new email inbox for an agent |
|
|
2430
|
+
| `list_inboxes` | List all inboxes in your account |
|
|
2431
|
+
| `get_inbox` | Get details of a specific inbox |
|
|
2432
|
+
| `delete_inbox` | Delete an inbox |
|
|
2433
|
+
| `send_message` | Send an email from an agent inbox |
|
|
2434
|
+
| `reply_to_message` | Reply to an email in a thread |
|
|
2435
|
+
| `forward_message` | Forward an email |
|
|
2436
|
+
| `update_message` | Update message labels or status |
|
|
2437
|
+
| `list_threads` | List email threads in an inbox |
|
|
2438
|
+
| `get_thread` | Get a full email thread with messages |
|
|
2439
|
+
| `get_attachment` | Download an email attachment |
|
|
2440
|
+
|
|
2441
|
+
<Card title="MCP Server on GitHub" icon="fa-brands fa-github" href="https://github.com/agentmail-to/agentmail-smithery-mcp">
|
|
2442
|
+
View the source code, contribute, or report issues.
|
|
2443
|
+
</Card>
|
|
2444
|
+
|
|
2445
|
+
## AgentMail Docs for Agents
|
|
2446
|
+
|
|
2447
|
+
You can give your agent current docs in three ways:
|
|
2448
|
+
|
|
2449
|
+
1. **Full documentation index**
|
|
2450
|
+
|
|
2451
|
+
A structured index of every doc page with descriptions:
|
|
2452
|
+
|
|
2453
|
+
```
|
|
2454
|
+
https://docs.agentmail.to/llms.txt
|
|
2455
|
+
```
|
|
2456
|
+
2. **Complete docs in one file**
|
|
2457
|
+
|
|
2458
|
+
Every doc page concatenated into a single file for full context:
|
|
2459
|
+
|
|
2460
|
+
```
|
|
2461
|
+
https://docs.agentmail.to/llms-full.txt
|
|
2462
|
+
```
|
|
2463
|
+
3. **Markdown versions of any page**
|
|
2464
|
+
|
|
2465
|
+
Every doc page is available as Markdown. Append `.md` to any page URL:
|
|
2466
|
+
|
|
2467
|
+
```
|
|
2468
|
+
https://docs.agentmail.to/quickstart.md
|
|
2469
|
+
```
|
|
2470
|
+
|
|
2471
|
+
## AgentMail Skills
|
|
2472
|
+
|
|
2473
|
+
Skills give AI agents specialized knowledge for specific tasks. Install the AgentMail skill to give your coding assistant full email capabilities:
|
|
2474
|
+
|
|
2475
|
+
### Claude Code
|
|
2476
|
+
|
|
2477
|
+
```bash
|
|
2478
|
+
claude-code skills install agentmail-to/agentmail-skills/agentmail
|
|
2479
|
+
```
|
|
2480
|
+
|
|
2481
|
+
### Cursor
|
|
2482
|
+
|
|
2483
|
+
```bash
|
|
2484
|
+
cursor skills install agentmail-to/agentmail-skills/agentmail
|
|
2485
|
+
```
|
|
2486
|
+
|
|
2487
|
+
### Codex
|
|
2488
|
+
|
|
2489
|
+
```bash
|
|
2490
|
+
codex skills install agentmail-to/agentmail-skills/agentmail
|
|
2491
|
+
```
|
|
2492
|
+
|
|
2493
|
+
### Manual Installation
|
|
2494
|
+
|
|
2495
|
+
```bash
|
|
2496
|
+
git clone https://github.com/agentmail-to/agentmail-skills.git ~/.skills/agentmail
|
|
2497
|
+
```
|
|
2498
|
+
|
|
2499
|
+
Then set your API key:
|
|
2500
|
+
|
|
2501
|
+
```bash
|
|
2502
|
+
export AGENTMAIL_API_KEY="your-api-key-here"
|
|
2503
|
+
```
|
|
2504
|
+
|
|
2505
|
+
<Card title="Skills on GitHub" icon="fa-brands fa-github" href="https://github.com/agentmail-to/agentmail-skills">
|
|
2506
|
+
View the skill source and full documentation.
|
|
2507
|
+
</Card>
|
|
2508
|
+
|
|
2509
|
+
## Quick Start for Agents
|
|
2510
|
+
|
|
2511
|
+
Create an inbox and send your first email in a few lines:
|
|
2512
|
+
|
|
2513
|
+
<CodeBlocks>
|
|
2514
|
+
```python title="Python"
|
|
2515
|
+
from agentmail import AgentMail
|
|
2516
|
+
|
|
2517
|
+
client = AgentMail(api_key="am_...")
|
|
2518
|
+
inbox = client.inboxes.create(display_name="My AI Agent")
|
|
2519
|
+
print(f"Agent email: {inbox.inbox_id}")
|
|
2520
|
+
|
|
2521
|
+
# Send an email
|
|
2522
|
+
client.inboxes.messages.send(
|
|
2523
|
+
inbox.inbox_id,
|
|
2524
|
+
to="user@example.com",
|
|
2525
|
+
subject="Hello from my AI agent",
|
|
2526
|
+
text="Hi! I'm an AI agent with my own email address."
|
|
2527
|
+
)
|
|
2528
|
+
```
|
|
2529
|
+
|
|
2530
|
+
```typescript title="TypeScript"
|
|
2531
|
+
import { AgentMailClient } from "agentmail";
|
|
2532
|
+
|
|
2533
|
+
const client = new AgentMailClient({ apiKey: "am_..." });
|
|
2534
|
+
const inbox = await client.inboxes.create({ displayName: "My AI Agent" });
|
|
2535
|
+
console.log(`Agent email: ${inbox.inboxId}`);
|
|
2536
|
+
|
|
2537
|
+
// Send an email
|
|
2538
|
+
await client.inboxes.messages.send(inbox.inboxId, {
|
|
2539
|
+
to: "user@example.com",
|
|
2540
|
+
subject: "Hello from my AI agent",
|
|
2541
|
+
text: "Hi! I'm an AI agent with my own email address."
|
|
2542
|
+
});
|
|
2543
|
+
```
|
|
2544
|
+
</CodeBlocks>
|
|
2545
|
+
|
|
2546
|
+
### Receive and reply to emails
|
|
2547
|
+
|
|
2548
|
+
<CodeBlocks>
|
|
2549
|
+
```python title="Python"
|
|
2550
|
+
# List threads in the inbox
|
|
2551
|
+
threads = client.inboxes.threads.list(inbox_id=inbox.inbox_id)
|
|
2552
|
+
|
|
2553
|
+
# Get the latest thread
|
|
2554
|
+
thread = client.inboxes.threads.get(
|
|
2555
|
+
inbox_id=inbox.inbox_id,
|
|
2556
|
+
thread_id=threads.threads[0].thread_id
|
|
2557
|
+
)
|
|
2558
|
+
|
|
2559
|
+
# Reply to the latest message
|
|
2560
|
+
latest_message = thread.messages[-1]
|
|
2561
|
+
client.inboxes.messages.reply(
|
|
2562
|
+
inbox_id=inbox.inbox_id,
|
|
2563
|
+
message_id=latest_message.message_id,
|
|
2564
|
+
to=[latest_message.from_],
|
|
2565
|
+
text="Thanks for your email! I'll look into this."
|
|
2566
|
+
)
|
|
2567
|
+
```
|
|
2568
|
+
|
|
2569
|
+
```typescript title="TypeScript"
|
|
2570
|
+
// List threads in the inbox
|
|
2571
|
+
const threads = await client.inboxes.threads.list(inbox.inboxId);
|
|
2572
|
+
|
|
2573
|
+
// Get the latest thread
|
|
2574
|
+
const thread = await client.inboxes.threads.get(
|
|
2575
|
+
inbox.inboxId,
|
|
2576
|
+
threads.threads[0].threadId
|
|
2577
|
+
);
|
|
2578
|
+
|
|
2579
|
+
// Reply to the latest message
|
|
2580
|
+
const latestMessage = thread.messages[thread.messages.length - 1];
|
|
2581
|
+
await client.inboxes.messages.reply(
|
|
2582
|
+
inbox.inboxId,
|
|
2583
|
+
latestMessage.messageId,
|
|
2584
|
+
{ to: [latestMessage.from], text: "Thanks for your email! I'll look into this." }
|
|
2585
|
+
);
|
|
2586
|
+
```
|
|
2587
|
+
</CodeBlocks>
|
|
2588
|
+
|
|
2589
|
+
## AI Builder Integrations
|
|
2590
|
+
|
|
2591
|
+
AgentMail integrates with popular AI development platforms:
|
|
2592
|
+
|
|
2593
|
+
<CardGroup cols={2}>
|
|
2594
|
+
<Card title="Replit" icon="fa-solid fa-code" href="/integrations/replit">
|
|
2595
|
+
Build email agents on Replit with our template.
|
|
2596
|
+
</Card>
|
|
2597
|
+
|
|
2598
|
+
<Card title="LiveKit" icon="fa-solid fa-microphone" href="/integrate-livekit-agents">
|
|
2599
|
+
Add email to LiveKit voice agents.
|
|
2600
|
+
</Card>
|
|
2601
|
+
|
|
2602
|
+
<Card title="OpenClaw" icon="fa-solid fa-robot" href="/integrations/openclaw">
|
|
2603
|
+
Use AgentMail with OpenClaw agents.
|
|
2604
|
+
</Card>
|
|
2605
|
+
|
|
2606
|
+
<Card title="WebSockets" icon="fa-solid fa-bolt" href="/websockets">
|
|
2607
|
+
Real-time email events without webhooks.
|
|
2608
|
+
</Card>
|
|
2609
|
+
</CardGroup>
|
|
2610
|
+
|
|
2611
|
+
## What Makes AgentMail Different?
|
|
2612
|
+
|
|
2613
|
+
Unlike traditional email APIs (SendGrid, Resend, Mailgun) that are built for one-way transactional email, AgentMail is built for **two-way agent communication**:
|
|
2614
|
+
|
|
2615
|
+
| Feature | AgentMail | Traditional Email APIs |
|
|
2616
|
+
| ---------------------- | -------------------------- | ------------------------- |
|
|
2617
|
+
| Per-agent inboxes | ✅ Create thousands via API | ❌ Shared sending domains |
|
|
2618
|
+
| Receive & parse emails | ✅ Native with threads | ⚠️ Limited or add-on |
|
|
2619
|
+
| Threaded conversations | ✅ First-class API support | ❌ Not supported |
|
|
2620
|
+
| Allowlists/blocklists | ✅ Per-inbox controls | ❌ Not available |
|
|
2621
|
+
| Multi-tenant (Pods) | ✅ Built-in isolation | ❌ Build it yourself |
|
|
2622
|
+
| WebSocket events | ✅ Real-time streaming | ❌ Webhooks only |
|
|
2623
|
+
| IMAP/SMTP access | ✅ Full protocol support | ❌ API-only |
|
|
2624
|
+
| Usage-based pricing | ✅ Pay per email | ❌ Per-inbox subscriptions |
|
|
2625
|
+
|
|
2626
|
+
## Next Steps
|
|
2627
|
+
|
|
2628
|
+
<CardGroup>
|
|
2629
|
+
<Card title="Full Quickstart Guide" icon="fa-solid fa-rocket" href="/quickstart">
|
|
2630
|
+
Step-by-step setup with environment variables and best practices.
|
|
2631
|
+
</Card>
|
|
2632
|
+
|
|
2633
|
+
<Card title="API Reference" icon="fa-solid fa-code" href="/api-reference">
|
|
2634
|
+
Full interactive API documentation.
|
|
2635
|
+
</Card>
|
|
2636
|
+
|
|
2637
|
+
<Card title="Example: Auto-Reply Agent" icon="fa-solid fa-bolt" href="/examples/auto-reply-agent">
|
|
2638
|
+
Build an agent that responds to emails in real-time.
|
|
2639
|
+
</Card>
|
|
2640
|
+
|
|
2641
|
+
<Card title="FAQ" icon="fa-solid fa-book" href="/resources/faq">
|
|
2642
|
+
Answers to common questions about email, deliverability, and agent patterns.
|
|
2643
|
+
</Card>
|
|
2644
|
+
</CardGroup>
|
|
2645
|
+
|
|
2646
|
+
|
|
1702
2647
|
***
|
|
1703
2648
|
|
|
1704
2649
|
title: Skills
|
|
1705
2650
|
subtitle: Add AgentMail to AI coding assistants with the official skill
|
|
1706
2651
|
slug: integrations/skills
|
|
1707
2652
|
description: >-
|
|
1708
|
-
AgentMail's official skill for
|
|
2653
|
+
AgentMail's official skill for OpenClaw, Claude Code, Cursor, and other AI
|
|
1709
2654
|
assistants
|
|
1710
2655
|
----------
|
|
1711
2656
|
|
|
1712
2657
|
## Getting started
|
|
1713
2658
|
|
|
1714
|
-
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
|
|
2659
|
+
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.
|
|
1715
2660
|
|
|
1716
2661
|
The skill is available at [skills.sh/agentmail-to/agentmail-skills/agentmail](https://skills.sh/agentmail-to/agentmail-skills/agentmail).
|
|
1717
2662
|
|
|
1718
2663
|
## Installation
|
|
1719
2664
|
|
|
1720
|
-
###
|
|
2665
|
+
### OpenClaw
|
|
1721
2666
|
|
|
1722
|
-
Install the skill using the
|
|
2667
|
+
Install the skill using the OpenClaw CLI:
|
|
1723
2668
|
|
|
1724
2669
|
```bash
|
|
1725
|
-
|
|
2670
|
+
openclaw skills install agentmail-to/agentmail-skills/agentmail
|
|
1726
2671
|
```
|
|
1727
2672
|
|
|
1728
|
-
Or install via
|
|
2673
|
+
Or install via ClawHub:
|
|
1729
2674
|
|
|
1730
2675
|
```bash
|
|
1731
|
-
|
|
2676
|
+
npx clawhub@latest install agentmail
|
|
1732
2677
|
```
|
|
1733
2678
|
|
|
1734
2679
|
### Claude Code
|
|
@@ -1767,9 +2712,9 @@ Set the `AGENTMAIL_API_KEY` environment variable:
|
|
|
1767
2712
|
export AGENTMAIL_API_KEY="your-api-key-here"
|
|
1768
2713
|
```
|
|
1769
2714
|
|
|
1770
|
-
###
|
|
2715
|
+
### OpenClaw configuration
|
|
1771
2716
|
|
|
1772
|
-
Add the API key to `~/.
|
|
2717
|
+
Add the API key to `~/.openclaw/openclaw.json`:
|
|
1773
2718
|
|
|
1774
2719
|
```json
|
|
1775
2720
|
{
|
|
@@ -1856,7 +2801,13 @@ The Model Context Protocol (MCP) is an open standard that enables AI application
|
|
|
1856
2801
|
|
|
1857
2802
|
### Setup
|
|
1858
2803
|
|
|
1859
|
-
|
|
2804
|
+
Install with:
|
|
2805
|
+
|
|
2806
|
+
```bash
|
|
2807
|
+
npx @smithery/cli@latest mcp add agentmail
|
|
2808
|
+
```
|
|
2809
|
+
|
|
2810
|
+
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).
|
|
1860
2811
|
|
|
1861
2812
|
## Features
|
|
1862
2813
|
|
|
@@ -1881,25 +2832,25 @@ For detailed setup instructions and available tools, visit [mcp.agentmail.to](ht
|
|
|
1881
2832
|
|
|
1882
2833
|
***
|
|
1883
2834
|
|
|
1884
|
-
title:
|
|
1885
|
-
subtitle: Give your
|
|
2835
|
+
title: OpenClaw
|
|
2836
|
+
subtitle: Give your OpenClaw agent its own email inbox
|
|
1886
2837
|
slug: integrations/openclaw
|
|
1887
|
-
description: AgentMail's
|
|
2838
|
+
description: AgentMail's OpenClaw integration
|
|
1888
2839
|
---------------------------------------------
|
|
1889
2840
|
|
|
1890
2841
|
## Getting started
|
|
1891
2842
|
|
|
1892
|
-
|
|
2843
|
+
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.
|
|
1893
2844
|
|
|
1894
|
-
There are two ways to integrate AgentMail with
|
|
2845
|
+
There are two ways to integrate AgentMail with OpenClaw: using the official AgentMail skill or creating a custom skill.
|
|
1895
2846
|
|
|
1896
2847
|
## Option 1: Official AgentMail Skill (Recommended)
|
|
1897
2848
|
|
|
1898
|
-
The easiest way to add email capabilities to
|
|
2849
|
+
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.
|
|
1899
2850
|
|
|
1900
2851
|
### Installation
|
|
1901
2852
|
|
|
1902
|
-
Install the skill using the
|
|
2853
|
+
Install the skill using the OpenClaw CLI:
|
|
1903
2854
|
|
|
1904
2855
|
```bash
|
|
1905
2856
|
openclaw skills install agentmail-to/agentmail-skills/agentmail
|
|
@@ -1957,11 +2908,11 @@ You should see `agentmail` in the list of available skills.
|
|
|
1957
2908
|
|
|
1958
2909
|
## Option 2: Custom Skill
|
|
1959
2910
|
|
|
1960
|
-
For more control over the integration, you can create a custom AgentMail skill. Skills are directories containing a `SKILL.md` file with instructions for
|
|
2911
|
+
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.
|
|
1961
2912
|
|
|
1962
2913
|
### Create the skill directory
|
|
1963
2914
|
|
|
1964
|
-
Create a new skill in your
|
|
2915
|
+
Create a new skill in your OpenClaw workspace:
|
|
1965
2916
|
|
|
1966
2917
|
```bash
|
|
1967
2918
|
mkdir -p ~/.openclaw/skills/agentmail
|
|
@@ -2023,10 +2974,10 @@ curl -s -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \
|
|
|
2023
2974
|
-H "Content-Type: application/json" \
|
|
2024
2975
|
-d '{
|
|
2025
2976
|
"to": ["recipient@example.com"],
|
|
2026
|
-
"subject": "Hello from
|
|
2977
|
+
"subject": "Hello from OpenClaw",
|
|
2027
2978
|
"text": "This email was sent by my AI assistant."
|
|
2028
2979
|
}' \
|
|
2029
|
-
https://api.agentmail.to/v0/inboxes/{inbox_id}/messages
|
|
2980
|
+
https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/send
|
|
2030
2981
|
```
|
|
2031
2982
|
|
|
2032
2983
|
### List messages in an inbox
|
|
@@ -2077,7 +3028,7 @@ You should see `agentmail` in the list of available skills.
|
|
|
2077
3028
|
|
|
2078
3029
|
## Example use cases
|
|
2079
3030
|
|
|
2080
|
-
Once AgentMail is integrated with
|
|
3031
|
+
Once AgentMail is integrated with OpenClaw, you can ask your agent to:
|
|
2081
3032
|
|
|
2082
3033
|
* "Create a new email inbox for my project"
|
|
2083
3034
|
* "Check my inbox for new emails"
|
|
@@ -2087,9 +3038,9 @@ Once AgentMail is integrated with Openclaw, you can ask your agent to:
|
|
|
2087
3038
|
|
|
2088
3039
|
## Real-time email notifications
|
|
2089
3040
|
|
|
2090
|
-
For proactive email handling, you can combine AgentMail webhooks with
|
|
3041
|
+
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.
|
|
2091
3042
|
|
|
2092
|
-
1. Set up a webhook endpoint in
|
|
3043
|
+
1. Set up a webhook endpoint in OpenClaw (see [OpenClaw webhook documentation](https://docs.openclaw.ai/automation/webhook))
|
|
2093
3044
|
|
|
2094
3045
|
2. Register the webhook with AgentMail:
|
|
2095
3046
|
|
|
@@ -2103,14 +3054,14 @@ curl -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \
|
|
|
2103
3054
|
https://api.agentmail.to/v0/webhooks
|
|
2104
3055
|
```
|
|
2105
3056
|
|
|
2106
|
-
Now
|
|
3057
|
+
Now OpenClaw will be notified whenever a new email arrives, allowing it to proactively inform you or take action.
|
|
2107
3058
|
|
|
2108
3059
|
## Resources
|
|
2109
3060
|
|
|
2110
3061
|
* [Official AgentMail Skill](https://skills.sh/agentmail-to/agentmail-skills/agentmail)
|
|
2111
3062
|
* [AgentMail API Reference](/api-reference)
|
|
2112
|
-
* [
|
|
2113
|
-
* [
|
|
3063
|
+
* [OpenClaw Documentation](https://docs.openclaw.ai)
|
|
3064
|
+
* [OpenClaw Skills Guide](https://docs.openclaw.ai/tools/skills)
|
|
2114
3065
|
|
|
2115
3066
|
|
|
2116
3067
|
***
|
|
@@ -2641,6 +3592,10 @@ Configure IMAP and SMTP to access your AgentMail inboxes using email clients
|
|
|
2641
3592
|
or programmatic access.
|
|
2642
3593
|
-----------------------
|
|
2643
3594
|
|
|
3595
|
+
<Callout intent="warn" title="IMAP is Under Development">
|
|
3596
|
+
IMAP support is currently under development and will be available in the coming weeks. The documentation below describes the planned functionality. SMTP is fully available today.
|
|
3597
|
+
</Callout>
|
|
3598
|
+
|
|
2644
3599
|
AgentMail supports standard IMAP and SMTP protocols, allowing you to connect using traditional email clients or integrate with existing systems that rely on these protocols.
|
|
2645
3600
|
|
|
2646
3601
|
## What are IMAP and SMTP?
|
|
@@ -3627,6 +4582,73 @@ When AgentMail sends a webhook, the payload includes `event_type` and `event_id`
|
|
|
3627
4582
|
* **`attachments`** (`array<object>`): A list of attachments, each with its own `attachment_id`, `filename`, `content_type`, `size`, and `inline` status.
|
|
3628
4583
|
* **`in_reply_to`** (`string`): The `message_id` of the email this message is a reply to, if applicable.
|
|
3629
4584
|
|
|
4585
|
+
## Copy for Cursor / Claude
|
|
4586
|
+
|
|
4587
|
+
Copy one of the blocks below into Cursor or Claude for complete Webhooks API knowledge in one shot.
|
|
4588
|
+
|
|
4589
|
+
<CodeBlocks>
|
|
4590
|
+
```python title="Python"
|
|
4591
|
+
"""
|
|
4592
|
+
AgentMail Webhooks — copy into Cursor/Claude.
|
|
4593
|
+
|
|
4594
|
+
Setup: pip install agentmail python-dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
4595
|
+
Return 200 immediately; process payload in background.
|
|
4596
|
+
|
|
4597
|
+
API reference:
|
|
4598
|
+
- webhooks.create(url, events?, inbox_ids?, pod_ids?, client_id?)
|
|
4599
|
+
- webhooks.get(webhook_id), webhooks.list(limit?, page_token?)
|
|
4600
|
+
- webhooks.update(webhook_id, add_inbox_ids?, remove_inbox_ids?, add_pod_ids?, remove_pod_ids?)
|
|
4601
|
+
- webhooks.delete(webhook_id)
|
|
4602
|
+
|
|
4603
|
+
Events: message.received, message.sent, message.delivered, message.bounced, message.complained, message.rejected, domain.verified
|
|
4604
|
+
Payload: event_type, event_id, plus message/send/delivery/bounce/complaint/reject/domain. Verify with Svix (webhook.secret).
|
|
4605
|
+
"""
|
|
4606
|
+
import os
|
|
4607
|
+
from dotenv import load_dotenv
|
|
4608
|
+
from agentmail import AgentMail
|
|
4609
|
+
|
|
4610
|
+
load_dotenv()
|
|
4611
|
+
client = AgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
4612
|
+
|
|
4613
|
+
wh = client.webhooks.create(url="https://your-server.com/webhooks", events=["message.received"], client_id="my-webhook-v1")
|
|
4614
|
+
all_wh = client.webhooks.list()
|
|
4615
|
+
secret = client.webhooks.get(wh.webhook_id).secret
|
|
4616
|
+
```
|
|
4617
|
+
|
|
4618
|
+
```typescript title="TypeScript"
|
|
4619
|
+
/**
|
|
4620
|
+
* AgentMail Webhooks — copy into Cursor/Claude.
|
|
4621
|
+
*
|
|
4622
|
+
* Setup: npm install agentmail dotenv. Set AGENTMAIL_API_KEY in .env.
|
|
4623
|
+
* Return 200 immediately; process payload in background.
|
|
4624
|
+
*
|
|
4625
|
+
* API reference:
|
|
4626
|
+
* - webhooks.create({ url, eventTypes?, inboxIds?, podIds?, clientId? })
|
|
4627
|
+
* - webhooks.get(webhookId), webhooks.list({ limit?, pageToken? })
|
|
4628
|
+
* - webhooks.update(webhookId, { addInboxIds?, removeInboxIds?, addPodIds?, removePodIds? })
|
|
4629
|
+
* - webhooks.delete(webhookId)
|
|
4630
|
+
*
|
|
4631
|
+
* Events: message.received, message.sent, message.delivered, message.bounced, message.complained, message.rejected, domain.verified
|
|
4632
|
+
* Verify with Svix using webhook.secret. Use express.raw() for body—signature needs raw payload.
|
|
4633
|
+
*/
|
|
4634
|
+
import { AgentMailClient } from "agentmail";
|
|
4635
|
+
import "dotenv/config";
|
|
4636
|
+
|
|
4637
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY! });
|
|
4638
|
+
|
|
4639
|
+
async function main() {
|
|
4640
|
+
const wh = await client.webhooks.create({
|
|
4641
|
+
url: "https://your-server.com/webhooks",
|
|
4642
|
+
eventTypes: ["message.received"],
|
|
4643
|
+
clientId: "my-webhook-v1",
|
|
4644
|
+
});
|
|
4645
|
+
const allWh = await client.webhooks.list();
|
|
4646
|
+
const secret = (await client.webhooks.get(wh.webhookId)).secret;
|
|
4647
|
+
}
|
|
4648
|
+
main();
|
|
4649
|
+
```
|
|
4650
|
+
</CodeBlocks>
|
|
4651
|
+
|
|
3630
4652
|
## Next Steps
|
|
3631
4653
|
|
|
3632
4654
|
<CardGroup>
|
|
@@ -3744,6 +4766,72 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3744
4766
|
```
|
|
3745
4767
|
</CodeBlocks>
|
|
3746
4768
|
|
|
4769
|
+
## Copy for Cursor / Claude
|
|
4770
|
+
|
|
4771
|
+
Copy one of the blocks below into Cursor or Claude for webhook event parsing in one shot.
|
|
4772
|
+
|
|
4773
|
+
<CodeBlocks>
|
|
4774
|
+
```python title="Python"
|
|
4775
|
+
"""
|
|
4776
|
+
AgentMail Webhook Events — copy into Cursor/Claude.
|
|
4777
|
+
|
|
4778
|
+
Parse typed events: MessageReceivedEvent (has message+thread), MessageSentEvent (send), MessageBouncedEvent (bounce),
|
|
4779
|
+
MessageDeliveredEvent (delivery), MessageComplainedEvent (complaint), MessageRejectedEvent (reject), DomainVerifiedEvent (domain).
|
|
4780
|
+
Only message.received includes full message+thread; others have send/delivery/bounce/complaint/reject/domain.
|
|
4781
|
+
"""
|
|
4782
|
+
from agentmail import (
|
|
4783
|
+
MessageReceivedEvent, MessageSentEvent, MessageBouncedEvent,
|
|
4784
|
+
MessageDeliveredEvent, MessageComplainedEvent, MessageRejectedEvent, DomainVerifiedEvent,
|
|
4785
|
+
)
|
|
4786
|
+
|
|
4787
|
+
def handle(payload: dict):
|
|
4788
|
+
t = payload.get("event_type")
|
|
4789
|
+
if t == "message.received": e = MessageReceivedEvent(**payload); print(e.message.subject, e.thread.message_count)
|
|
4790
|
+
elif t == "message.sent": e = MessageSentEvent(**payload); print(e.send.recipients)
|
|
4791
|
+
elif t == "message.bounced": e = MessageBouncedEvent(**payload); print(e.bounce.type)
|
|
4792
|
+
elif t == "message.delivered": e = MessageDeliveredEvent(**payload)
|
|
4793
|
+
elif t == "message.complained": e = MessageComplainedEvent(**payload)
|
|
4794
|
+
elif t == "message.rejected": e = MessageRejectedEvent(**payload); print(e.reject.reason)
|
|
4795
|
+
elif t == "domain.verified": e = DomainVerifiedEvent(**payload); print(e.domain.status)
|
|
4796
|
+
```
|
|
4797
|
+
|
|
4798
|
+
```typescript title="TypeScript"
|
|
4799
|
+
/**
|
|
4800
|
+
* AgentMail Webhook Events — copy into Cursor/Claude.
|
|
4801
|
+
*
|
|
4802
|
+
* Parse with serialization.events.MessageReceivedEvent.parse(payload), etc.
|
|
4803
|
+
* Only message.received has message+thread; others have send/delivery/bounce/complaint/reject/domain.
|
|
4804
|
+
*/
|
|
4805
|
+
import { serialization } from "agentmail";
|
|
4806
|
+
|
|
4807
|
+
async function handle(payload: Record<string, unknown>) {
|
|
4808
|
+
const t = payload.event_type;
|
|
4809
|
+
if (t === "message.received") {
|
|
4810
|
+
const e = await serialization.events.MessageReceivedEvent.parse(payload);
|
|
4811
|
+
console.log(e.message.subject, e.thread.messageCount);
|
|
4812
|
+
} else if (t === "message.sent") {
|
|
4813
|
+
const e = await serialization.events.MessageSentEvent.parse(payload);
|
|
4814
|
+
console.log(e.send.recipients);
|
|
4815
|
+
} else if (t === "message.bounced") {
|
|
4816
|
+
const e = await serialization.events.MessageBouncedEvent.parse(payload);
|
|
4817
|
+
console.log(e.bounce.type);
|
|
4818
|
+
} else if (t === "message.delivered") {
|
|
4819
|
+
const e = await serialization.events.MessageDeliveredEvent.parse(payload);
|
|
4820
|
+
console.log(e.delivery);
|
|
4821
|
+
} else if (t === "message.complained") {
|
|
4822
|
+
const e = await serialization.events.MessageComplainedEvent.parse(payload);
|
|
4823
|
+
console.log(e.complaint);
|
|
4824
|
+
} else if (t === "message.rejected") {
|
|
4825
|
+
const e = await serialization.events.MessageRejectedEvent.parse(payload);
|
|
4826
|
+
console.log(e.reject);
|
|
4827
|
+
} else if (t === "domain.verified") {
|
|
4828
|
+
const e = await serialization.events.DomainVerifiedEvent.parse(payload);
|
|
4829
|
+
console.log(e.domain);
|
|
4830
|
+
}
|
|
4831
|
+
}
|
|
4832
|
+
```
|
|
4833
|
+
</CodeBlocks>
|
|
4834
|
+
|
|
3747
4835
|
## Message Events
|
|
3748
4836
|
|
|
3749
4837
|
### `message.received`
|
|
@@ -4219,6 +5307,63 @@ To test your webhook setup:
|
|
|
4219
5307
|
</Accordion>
|
|
4220
5308
|
</AccordionGroup>
|
|
4221
5309
|
|
|
5310
|
+
## Copy for Cursor / Claude
|
|
5311
|
+
|
|
5312
|
+
Copy one of the blocks below into Cursor or Claude for webhook setup in one shot.
|
|
5313
|
+
|
|
5314
|
+
<CodeBlocks>
|
|
5315
|
+
```python title="Python"
|
|
5316
|
+
"""
|
|
5317
|
+
AgentMail Webhook Setup — copy into Cursor/Claude.
|
|
5318
|
+
|
|
5319
|
+
Flow: 1) ngrok http 3000 → copy URL. 2) inboxes.create(client_id=...) 3) webhooks.create(url=ngrok+/webhooks, events=[...], client_id=...)
|
|
5320
|
+
4) Flask POST /webhooks: return 200 immediately, process request.json in background.
|
|
5321
|
+
Local: use http://127.0.0.1:3000 in browser, not ngrok URL.
|
|
5322
|
+
"""
|
|
5323
|
+
from flask import Flask, request, Response
|
|
5324
|
+
from agentmail import AgentMail
|
|
5325
|
+
|
|
5326
|
+
app = Flask(__name__)
|
|
5327
|
+
client = AgentMail()
|
|
5328
|
+
|
|
5329
|
+
inbox = client.inboxes.create(username="webhook-demo", client_id="webhook-demo-inbox")
|
|
5330
|
+
wh = client.webhooks.create(url="https://YOUR_NGROK.ngrok-free.app/webhooks", events=["message.received"], client_id="webhook-demo-webhook")
|
|
5331
|
+
|
|
5332
|
+
@app.route("/webhooks", methods=["POST"])
|
|
5333
|
+
def receive():
|
|
5334
|
+
payload = request.json
|
|
5335
|
+
print(payload.get("event_type"), payload.get("message", {}).get("subject"))
|
|
5336
|
+
return Response(status=200)
|
|
5337
|
+
```
|
|
5338
|
+
|
|
5339
|
+
```typescript title="TypeScript"
|
|
5340
|
+
/**
|
|
5341
|
+
* AgentMail Webhook Setup — copy into Cursor/Claude.
|
|
5342
|
+
*
|
|
5343
|
+
* Flow: 1) ngrok http 3000. 2) inboxes.create({ clientId }). 3) webhooks.create({ url, eventTypes, clientId })
|
|
5344
|
+
* 4) Express POST /webhooks: res.status(200).send(), process req.body async.
|
|
5345
|
+
* Use express.raw() if you add Svix verification later.
|
|
5346
|
+
*/
|
|
5347
|
+
import express from "express";
|
|
5348
|
+
import { AgentMailClient } from "agentmail";
|
|
5349
|
+
|
|
5350
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY! });
|
|
5351
|
+
const inbox = await client.inboxes.create({ username: "webhook-demo", clientId: "webhook-demo-inbox" });
|
|
5352
|
+
await client.webhooks.create({
|
|
5353
|
+
url: "https://YOUR_NGROK.ngrok-free.app/webhooks",
|
|
5354
|
+
eventTypes: ["message.received"],
|
|
5355
|
+
clientId: "webhook-demo-webhook",
|
|
5356
|
+
});
|
|
5357
|
+
|
|
5358
|
+
const app = express();
|
|
5359
|
+
app.post("/webhooks", express.json(), (req, res) => {
|
|
5360
|
+
console.log(req.body.event_type, req.body.message?.subject);
|
|
5361
|
+
res.status(200).send();
|
|
5362
|
+
});
|
|
5363
|
+
app.listen(3000);
|
|
5364
|
+
```
|
|
5365
|
+
</CodeBlocks>
|
|
5366
|
+
|
|
4222
5367
|
## Production Considerations
|
|
4223
5368
|
|
|
4224
5369
|
For production deployments:
|
|
@@ -4406,6 +5551,65 @@ The easiest way to verify webhooks is using the official Svix library, which han
|
|
|
4406
5551
|
Signature verification requires the exact request body. If you're using body-parsing middleware (like `express.json()`), make sure to capture the raw body before parsing, or use `express.raw()` for your webhook endpoint.
|
|
4407
5552
|
</Callout>
|
|
4408
5553
|
|
|
5554
|
+
## Copy for Cursor / Claude
|
|
5555
|
+
|
|
5556
|
+
Copy one of the blocks below into Cursor or Claude for webhook verification in one shot.
|
|
5557
|
+
|
|
5558
|
+
<CodeBlocks>
|
|
5559
|
+
```python title="Python"
|
|
5560
|
+
"""
|
|
5561
|
+
AgentMail Webhook Verification — copy into Cursor/Claude.
|
|
5562
|
+
|
|
5563
|
+
Use Svix: pip install svix. Get secret from webhooks.get(webhook_id).secret (starts whsec_).
|
|
5564
|
+
Headers: svix-id, svix-timestamp, svix-signature. Use request.get_data() (raw body), not request.json.
|
|
5565
|
+
"""
|
|
5566
|
+
from flask import Flask, request
|
|
5567
|
+
from svix.webhooks import Webhook, WebhookVerificationError
|
|
5568
|
+
|
|
5569
|
+
app = Flask(__name__)
|
|
5570
|
+
secret = "whsec_..." # from client.webhooks.get(id).secret
|
|
5571
|
+
|
|
5572
|
+
@app.route("/webhooks", methods=["POST"])
|
|
5573
|
+
def handler():
|
|
5574
|
+
try:
|
|
5575
|
+
wh = Webhook(secret)
|
|
5576
|
+
msg = wh.verify(request.get_data(), request.headers)
|
|
5577
|
+
if msg.get("event_type") == "message.received":
|
|
5578
|
+
pass # process
|
|
5579
|
+
return "", 204
|
|
5580
|
+
except WebhookVerificationError:
|
|
5581
|
+
return "", 400
|
|
5582
|
+
```
|
|
5583
|
+
|
|
5584
|
+
```typescript title="TypeScript"
|
|
5585
|
+
/**
|
|
5586
|
+
* AgentMail Webhook Verification — copy into Cursor/Claude.
|
|
5587
|
+
*
|
|
5588
|
+
* Use Svix: npm install svix. Secret from webhooks.get(id).secret.
|
|
5589
|
+
* Use express.raw({ type: "application/json" }) — NOT express.json(). Verify before parsing.
|
|
5590
|
+
*/
|
|
5591
|
+
import express from "express";
|
|
5592
|
+
import { Webhook } from "svix";
|
|
5593
|
+
|
|
5594
|
+
const app = express();
|
|
5595
|
+
const secret = process.env.AGENTMAIL_WEBHOOK_SECRET;
|
|
5596
|
+
if (!secret) {
|
|
5597
|
+
throw new Error("AGENTMAIL_WEBHOOK_SECRET environment variable is required");
|
|
5598
|
+
}
|
|
5599
|
+
|
|
5600
|
+
app.post("/webhooks", express.raw({ type: "application/json" }), (req, res) => {
|
|
5601
|
+
try {
|
|
5602
|
+
const wh = new Webhook(secret);
|
|
5603
|
+
const msg = wh.verify(req.body, req.headers as Record<string, string>);
|
|
5604
|
+
if (msg.event_type === "message.received") { /* process */ }
|
|
5605
|
+
res.status(204).send();
|
|
5606
|
+
} catch {
|
|
5607
|
+
res.status(400).send();
|
|
5608
|
+
}
|
|
5609
|
+
});
|
|
5610
|
+
```
|
|
5611
|
+
</CodeBlocks>
|
|
5612
|
+
|
|
4409
5613
|
## Testing Locally with ngrok
|
|
4410
5614
|
|
|
4411
5615
|
During development, you'll need a way for AgentMail to reach your local server. [ngrok](https://ngrok.com/) creates a public URL that tunnels to your local machine.
|
|
@@ -5012,6 +6216,57 @@ main();
|
|
|
5012
6216
|
|
|
5013
6217
|
***
|
|
5014
6218
|
|
|
6219
|
+
## Copy for Cursor / Claude
|
|
6220
|
+
|
|
6221
|
+
Copy one of the blocks below into Cursor or Claude for WebSockets in one shot.
|
|
6222
|
+
|
|
6223
|
+
<CodeBlocks>
|
|
6224
|
+
```python title="Python"
|
|
6225
|
+
"""
|
|
6226
|
+
AgentMail WebSockets — copy into Cursor/Claude. Real-time events, no public URL needed.
|
|
6227
|
+
|
|
6228
|
+
Sync: with client.websockets.connect() as socket: socket.send_subscribe(Subscribe(inbox_ids=[...])); for event in socket: ...
|
|
6229
|
+
Async: async with client.websockets.connect() as socket: await socket.send_subscribe(...); async for event in socket: ...
|
|
6230
|
+
Subscribe(inbox_ids=[...], pod_ids=[...], event_types=[...])
|
|
6231
|
+
Event types: Subscribed, MessageReceivedEvent, MessageSentEvent, MessageDeliveredEvent, MessageBouncedEvent, MessageComplainedEvent, MessageRejectedEvent, DomainVerifiedEvent
|
|
6232
|
+
"""
|
|
6233
|
+
from agentmail import AgentMail, Subscribe, Subscribed, MessageReceivedEvent
|
|
6234
|
+
|
|
6235
|
+
client = AgentMail(api_key="YOUR_API_KEY")
|
|
6236
|
+
with client.websockets.connect() as socket:
|
|
6237
|
+
socket.send_subscribe(Subscribe(inbox_ids=["agent@agentmail.to"]))
|
|
6238
|
+
for event in socket:
|
|
6239
|
+
if isinstance(event, Subscribed): print(event.inbox_ids)
|
|
6240
|
+
elif isinstance(event, MessageReceivedEvent): print(event.message.subject)
|
|
6241
|
+
```
|
|
6242
|
+
|
|
6243
|
+
```typescript title="TypeScript"
|
|
6244
|
+
/**
|
|
6245
|
+
* AgentMail WebSockets — copy into Cursor/Claude. Real-time events, no public URL.
|
|
6246
|
+
*
|
|
6247
|
+
* const socket = await client.websockets.connect();
|
|
6248
|
+
* socket.on("open", () => socket.sendSubscribe({ type: "subscribe", inboxIds: [...] }));
|
|
6249
|
+
* socket.on("message", (e) => { if (e.type === "subscribed") ...; if (e.type === "message_received") ... });
|
|
6250
|
+
* socket.on("close" | "error", ...);
|
|
6251
|
+
*/
|
|
6252
|
+
import { AgentMailClient } from "agentmail";
|
|
6253
|
+
|
|
6254
|
+
const client = new AgentMailClient({ apiKey: process.env.AGENTMAIL_API_KEY });
|
|
6255
|
+
|
|
6256
|
+
async function main() {
|
|
6257
|
+
const socket = await client.websockets.connect();
|
|
6258
|
+
socket.on("open", () => socket.sendSubscribe({ type: "subscribe", inboxIds: ["agent@agentmail.to"] }));
|
|
6259
|
+
socket.on("message", (e) => {
|
|
6260
|
+
if (e.type === "subscribed") console.log(e.inboxIds);
|
|
6261
|
+
if (e.type === "message_received") console.log(e.message.subject);
|
|
6262
|
+
});
|
|
6263
|
+
}
|
|
6264
|
+
main().catch(console.error);
|
|
6265
|
+
```
|
|
6266
|
+
</CodeBlocks>
|
|
6267
|
+
|
|
6268
|
+
***
|
|
6269
|
+
|
|
5015
6270
|
|
|
5016
6271
|
***
|
|
5017
6272
|
|
|
@@ -5020,6 +6275,46 @@ subtitle: Get started with real-time email event streaming
|
|
|
5020
6275
|
slug: websockets/quickstart
|
|
5021
6276
|
---------------------------
|
|
5022
6277
|
|
|
6278
|
+
## Copy for Cursor / Claude
|
|
6279
|
+
|
|
6280
|
+
Copy one of the blocks below into Cursor or Claude for instant WebSocket setup.
|
|
6281
|
+
|
|
6282
|
+
<CodeBlocks>
|
|
6283
|
+
```python title="Python"
|
|
6284
|
+
"""
|
|
6285
|
+
AgentMail WebSockets Quickstart — copy into Cursor/Claude.
|
|
6286
|
+
client.websockets.connect() → socket.send_subscribe(Subscribe(inbox_ids=[...])) → iterate socket for events.
|
|
6287
|
+
"""
|
|
6288
|
+
from agentmail import AgentMail, Subscribe, Subscribed, MessageReceivedEvent
|
|
6289
|
+
|
|
6290
|
+
client = AgentMail()
|
|
6291
|
+
with client.websockets.connect() as socket:
|
|
6292
|
+
socket.send_subscribe(Subscribe(inbox_ids=["my-agent@agentmail.to"]))
|
|
6293
|
+
for event in socket:
|
|
6294
|
+
if isinstance(event, Subscribed): print(f"Subscribed to {event.inbox_ids}")
|
|
6295
|
+
elif isinstance(event, MessageReceivedEvent): print(f"Received from: {event.message.from_}")
|
|
6296
|
+
```
|
|
6297
|
+
|
|
6298
|
+
```typescript title="TypeScript"
|
|
6299
|
+
/**
|
|
6300
|
+
* AgentMail WebSockets Quickstart — copy into Cursor/Claude.
|
|
6301
|
+
* client.websockets.connect() → sendSubscribe({ type: "subscribe", inboxIds }) → on("message", ...)
|
|
6302
|
+
*/
|
|
6303
|
+
import { AgentMailClient } from "agentmail";
|
|
6304
|
+
|
|
6305
|
+
const client = new AgentMailClient();
|
|
6306
|
+
const socket = await client.websockets.connect();
|
|
6307
|
+
socket.on("message", async (e) => {
|
|
6308
|
+
if (e.type === "subscribed") console.log("Subscribed to", e.inboxIds);
|
|
6309
|
+
else if (e.type === "event" && e.eventType === "message.received") console.log("Received from:", e.message?.from);
|
|
6310
|
+
});
|
|
6311
|
+
await socket.waitForOpen();
|
|
6312
|
+
socket.sendSubscribe({ type: "subscribe", inboxIds: ["my-agent@agentmail.to"] });
|
|
6313
|
+
```
|
|
6314
|
+
</CodeBlocks>
|
|
6315
|
+
|
|
6316
|
+
## SDK Examples
|
|
6317
|
+
|
|
5023
6318
|
```typescript title="TypeScript"
|
|
5024
6319
|
import { AgentMailClient } from "agentmail";
|
|
5025
6320
|
|
|
@@ -9006,6 +10301,11 @@ paths:
|
|
|
9006
10301
|
required: false
|
|
9007
10302
|
schema:
|
|
9008
10303
|
$ref: '#/components/schemas/type_:PageToken'
|
|
10304
|
+
- name: ascending
|
|
10305
|
+
in: query
|
|
10306
|
+
required: false
|
|
10307
|
+
schema:
|
|
10308
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
9009
10309
|
- name: Authorization
|
|
9010
10310
|
in: header
|
|
9011
10311
|
description: Bearer authentication
|
|
@@ -9034,6 +10334,10 @@ components:
|
|
|
9034
10334
|
type: string
|
|
9035
10335
|
description: Page token for pagination.
|
|
9036
10336
|
title: PageToken
|
|
10337
|
+
type_:Ascending:
|
|
10338
|
+
type: boolean
|
|
10339
|
+
description: Sort in ascending temporal order.
|
|
10340
|
+
title: Ascending
|
|
9037
10341
|
type_:Count:
|
|
9038
10342
|
type: integer
|
|
9039
10343
|
description: Number of items returned.
|
|
@@ -9044,7 +10348,7 @@ components:
|
|
|
9044
10348
|
title: PodId
|
|
9045
10349
|
type_inboxes:InboxId:
|
|
9046
10350
|
type: string
|
|
9047
|
-
description: ID of inbox.
|
|
10351
|
+
description: The ID of the inbox.
|
|
9048
10352
|
title: InboxId
|
|
9049
10353
|
type_inboxes:DisplayName:
|
|
9050
10354
|
type: string
|
|
@@ -9285,7 +10589,7 @@ components:
|
|
|
9285
10589
|
schemas:
|
|
9286
10590
|
type_inboxes:InboxId:
|
|
9287
10591
|
type: string
|
|
9288
|
-
description: ID of inbox.
|
|
10592
|
+
description: The ID of the inbox.
|
|
9289
10593
|
title: InboxId
|
|
9290
10594
|
type_pods:PodId:
|
|
9291
10595
|
type: string
|
|
@@ -9562,7 +10866,7 @@ components:
|
|
|
9562
10866
|
title: PodId
|
|
9563
10867
|
type_inboxes:InboxId:
|
|
9564
10868
|
type: string
|
|
9565
|
-
description: ID of inbox.
|
|
10869
|
+
description: The ID of the inbox.
|
|
9566
10870
|
title: InboxId
|
|
9567
10871
|
type_inboxes:Inbox:
|
|
9568
10872
|
type: object
|
|
@@ -9806,7 +11110,7 @@ components:
|
|
|
9806
11110
|
schemas:
|
|
9807
11111
|
type_inboxes:InboxId:
|
|
9808
11112
|
type: string
|
|
9809
|
-
description: ID of inbox.
|
|
11113
|
+
description: The ID of the inbox.
|
|
9810
11114
|
title: InboxId
|
|
9811
11115
|
type_inboxes:DisplayName:
|
|
9812
11116
|
type: string
|
|
@@ -10082,7 +11386,7 @@ components:
|
|
|
10082
11386
|
schemas:
|
|
10083
11387
|
type_inboxes:InboxId:
|
|
10084
11388
|
type: string
|
|
10085
|
-
description: ID of inbox.
|
|
11389
|
+
description: The ID of the inbox.
|
|
10086
11390
|
title: InboxId
|
|
10087
11391
|
type_:ErrorName:
|
|
10088
11392
|
type: string
|
|
@@ -10305,6 +11609,11 @@ paths:
|
|
|
10305
11609
|
required: false
|
|
10306
11610
|
schema:
|
|
10307
11611
|
$ref: '#/components/schemas/type_:IncludeBlocked'
|
|
11612
|
+
- name: include_trash
|
|
11613
|
+
in: query
|
|
11614
|
+
required: false
|
|
11615
|
+
schema:
|
|
11616
|
+
$ref: '#/components/schemas/type_:IncludeTrash'
|
|
10308
11617
|
- name: Authorization
|
|
10309
11618
|
in: header
|
|
10310
11619
|
description: Bearer authentication
|
|
@@ -10333,7 +11642,7 @@ components:
|
|
|
10333
11642
|
schemas:
|
|
10334
11643
|
type_inboxes:InboxId:
|
|
10335
11644
|
type: string
|
|
10336
|
-
description: ID of inbox.
|
|
11645
|
+
description: The ID of the inbox.
|
|
10337
11646
|
title: InboxId
|
|
10338
11647
|
type_:Limit:
|
|
10339
11648
|
type: integer
|
|
@@ -10371,6 +11680,10 @@ components:
|
|
|
10371
11680
|
type: boolean
|
|
10372
11681
|
description: Include blocked in results.
|
|
10373
11682
|
title: IncludeBlocked
|
|
11683
|
+
type_:IncludeTrash:
|
|
11684
|
+
type: boolean
|
|
11685
|
+
description: Include trash in results.
|
|
11686
|
+
title: IncludeTrash
|
|
10374
11687
|
type_:Count:
|
|
10375
11688
|
type: integer
|
|
10376
11689
|
description: Number of items returned.
|
|
@@ -10778,7 +12091,7 @@ components:
|
|
|
10778
12091
|
schemas:
|
|
10779
12092
|
type_inboxes:InboxId:
|
|
10780
12093
|
type: string
|
|
10781
|
-
description: ID of inbox.
|
|
12094
|
+
description: The ID of the inbox.
|
|
10782
12095
|
title: InboxId
|
|
10783
12096
|
type_threads:ThreadId:
|
|
10784
12097
|
type: string
|
|
@@ -11342,7 +12655,7 @@ components:
|
|
|
11342
12655
|
schemas:
|
|
11343
12656
|
type_inboxes:InboxId:
|
|
11344
12657
|
type: string
|
|
11345
|
-
description: ID of inbox.
|
|
12658
|
+
description: The ID of the inbox.
|
|
11346
12659
|
title: InboxId
|
|
11347
12660
|
type_threads:ThreadId:
|
|
11348
12661
|
type: string
|
|
@@ -11615,7 +12928,7 @@ components:
|
|
|
11615
12928
|
schemas:
|
|
11616
12929
|
type_inboxes:InboxId:
|
|
11617
12930
|
type: string
|
|
11618
|
-
description: ID of inbox.
|
|
12931
|
+
description: The ID of the inbox.
|
|
11619
12932
|
title: InboxId
|
|
11620
12933
|
type_threads:ThreadId:
|
|
11621
12934
|
type: string
|
|
@@ -11843,6 +13156,11 @@ paths:
|
|
|
11843
13156
|
required: false
|
|
11844
13157
|
schema:
|
|
11845
13158
|
$ref: '#/components/schemas/type_:IncludeBlocked'
|
|
13159
|
+
- name: include_trash
|
|
13160
|
+
in: query
|
|
13161
|
+
required: false
|
|
13162
|
+
schema:
|
|
13163
|
+
$ref: '#/components/schemas/type_:IncludeTrash'
|
|
11846
13164
|
- name: Authorization
|
|
11847
13165
|
in: header
|
|
11848
13166
|
description: Bearer authentication
|
|
@@ -11871,7 +13189,7 @@ components:
|
|
|
11871
13189
|
schemas:
|
|
11872
13190
|
type_inboxes:InboxId:
|
|
11873
13191
|
type: string
|
|
11874
|
-
description: ID of inbox.
|
|
13192
|
+
description: The ID of the inbox.
|
|
11875
13193
|
title: InboxId
|
|
11876
13194
|
type_:Limit:
|
|
11877
13195
|
type: integer
|
|
@@ -11909,6 +13227,10 @@ components:
|
|
|
11909
13227
|
type: boolean
|
|
11910
13228
|
description: Include blocked in results.
|
|
11911
13229
|
title: IncludeBlocked
|
|
13230
|
+
type_:IncludeTrash:
|
|
13231
|
+
type: boolean
|
|
13232
|
+
description: Include trash in results.
|
|
13233
|
+
title: IncludeTrash
|
|
11912
13234
|
type_:Count:
|
|
11913
13235
|
type: integer
|
|
11914
13236
|
description: Number of items returned.
|
|
@@ -12335,7 +13657,7 @@ components:
|
|
|
12335
13657
|
schemas:
|
|
12336
13658
|
type_inboxes:InboxId:
|
|
12337
13659
|
type: string
|
|
12338
|
-
description: ID of inbox.
|
|
13660
|
+
description: The ID of the inbox.
|
|
12339
13661
|
title: InboxId
|
|
12340
13662
|
type_messages:MessageId:
|
|
12341
13663
|
type: string
|
|
@@ -12772,7 +14094,7 @@ components:
|
|
|
12772
14094
|
schemas:
|
|
12773
14095
|
type_inboxes:InboxId:
|
|
12774
14096
|
type: string
|
|
12775
|
-
description: ID of inbox.
|
|
14097
|
+
description: The ID of the inbox.
|
|
12776
14098
|
title: InboxId
|
|
12777
14099
|
type_messages:MessageId:
|
|
12778
14100
|
type: string
|
|
@@ -13050,7 +14372,7 @@ components:
|
|
|
13050
14372
|
schemas:
|
|
13051
14373
|
type_inboxes:InboxId:
|
|
13052
14374
|
type: string
|
|
13053
|
-
description: ID of inbox.
|
|
14375
|
+
description: The ID of the inbox.
|
|
13054
14376
|
title: InboxId
|
|
13055
14377
|
type_messages:MessageId:
|
|
13056
14378
|
type: string
|
|
@@ -13284,7 +14606,7 @@ components:
|
|
|
13284
14606
|
schemas:
|
|
13285
14607
|
type_inboxes:InboxId:
|
|
13286
14608
|
type: string
|
|
13287
|
-
description: ID of inbox.
|
|
14609
|
+
description: The ID of the inbox.
|
|
13288
14610
|
title: InboxId
|
|
13289
14611
|
type_messages:MessageLabels:
|
|
13290
14612
|
type: array
|
|
@@ -13681,7 +15003,7 @@ components:
|
|
|
13681
15003
|
schemas:
|
|
13682
15004
|
type_inboxes:InboxId:
|
|
13683
15005
|
type: string
|
|
13684
|
-
description: ID of inbox.
|
|
15006
|
+
description: The ID of the inbox.
|
|
13685
15007
|
title: InboxId
|
|
13686
15008
|
type_messages:MessageId:
|
|
13687
15009
|
type: string
|
|
@@ -14079,7 +15401,7 @@ components:
|
|
|
14079
15401
|
schemas:
|
|
14080
15402
|
type_inboxes:InboxId:
|
|
14081
15403
|
type: string
|
|
14082
|
-
description: ID of inbox.
|
|
15404
|
+
description: The ID of the inbox.
|
|
14083
15405
|
title: InboxId
|
|
14084
15406
|
type_messages:MessageId:
|
|
14085
15407
|
type: string
|
|
@@ -14453,7 +15775,7 @@ components:
|
|
|
14453
15775
|
schemas:
|
|
14454
15776
|
type_inboxes:InboxId:
|
|
14455
15777
|
type: string
|
|
14456
|
-
description: ID of inbox.
|
|
15778
|
+
description: The ID of the inbox.
|
|
14457
15779
|
title: InboxId
|
|
14458
15780
|
type_messages:MessageId:
|
|
14459
15781
|
type: string
|
|
@@ -14845,7 +16167,7 @@ components:
|
|
|
14845
16167
|
schemas:
|
|
14846
16168
|
type_inboxes:InboxId:
|
|
14847
16169
|
type: string
|
|
14848
|
-
description: ID of inbox.
|
|
16170
|
+
description: The ID of the inbox.
|
|
14849
16171
|
title: InboxId
|
|
14850
16172
|
type_messages:MessageId:
|
|
14851
16173
|
type: string
|
|
@@ -15346,7 +16668,7 @@ components:
|
|
|
15346
16668
|
schemas:
|
|
15347
16669
|
type_inboxes:InboxId:
|
|
15348
16670
|
type: string
|
|
15349
|
-
description: ID of inbox.
|
|
16671
|
+
description: The ID of the inbox.
|
|
15350
16672
|
title: InboxId
|
|
15351
16673
|
type_:Limit:
|
|
15352
16674
|
type: integer
|
|
@@ -15764,7 +17086,7 @@ components:
|
|
|
15764
17086
|
schemas:
|
|
15765
17087
|
type_inboxes:InboxId:
|
|
15766
17088
|
type: string
|
|
15767
|
-
description: ID of inbox.
|
|
17089
|
+
description: The ID of the inbox.
|
|
15768
17090
|
title: InboxId
|
|
15769
17091
|
type_drafts:DraftId:
|
|
15770
17092
|
type: string
|
|
@@ -16182,7 +17504,7 @@ components:
|
|
|
16182
17504
|
schemas:
|
|
16183
17505
|
type_inboxes:InboxId:
|
|
16184
17506
|
type: string
|
|
16185
|
-
description: ID of inbox.
|
|
17507
|
+
description: The ID of the inbox.
|
|
16186
17508
|
title: InboxId
|
|
16187
17509
|
type_drafts:DraftId:
|
|
16188
17510
|
type: string
|
|
@@ -16460,7 +17782,7 @@ components:
|
|
|
16460
17782
|
schemas:
|
|
16461
17783
|
type_inboxes:InboxId:
|
|
16462
17784
|
type: string
|
|
16463
|
-
description: ID of inbox.
|
|
17785
|
+
description: The ID of the inbox.
|
|
16464
17786
|
title: InboxId
|
|
16465
17787
|
type_drafts:DraftLabels:
|
|
16466
17788
|
type: array
|
|
@@ -16946,7 +18268,7 @@ components:
|
|
|
16946
18268
|
schemas:
|
|
16947
18269
|
type_inboxes:InboxId:
|
|
16948
18270
|
type: string
|
|
16949
|
-
description: ID of inbox.
|
|
18271
|
+
description: The ID of the inbox.
|
|
16950
18272
|
title: InboxId
|
|
16951
18273
|
type_drafts:DraftId:
|
|
16952
18274
|
type: string
|
|
@@ -17416,7 +18738,7 @@ components:
|
|
|
17416
18738
|
schemas:
|
|
17417
18739
|
type_inboxes:InboxId:
|
|
17418
18740
|
type: string
|
|
17419
|
-
description: ID of inbox.
|
|
18741
|
+
description: The ID of the inbox.
|
|
17420
18742
|
title: InboxId
|
|
17421
18743
|
type_drafts:DraftId:
|
|
17422
18744
|
type: string
|
|
@@ -17696,7 +19018,7 @@ components:
|
|
|
17696
19018
|
schemas:
|
|
17697
19019
|
type_inboxes:InboxId:
|
|
17698
19020
|
type: string
|
|
17699
|
-
description: ID of inbox.
|
|
19021
|
+
description: The ID of the inbox.
|
|
17700
19022
|
title: InboxId
|
|
17701
19023
|
type_drafts:DraftId:
|
|
17702
19024
|
type: string
|
|
@@ -17933,7 +19255,7 @@ components:
|
|
|
17933
19255
|
schemas:
|
|
17934
19256
|
type_inboxes:InboxId:
|
|
17935
19257
|
type: string
|
|
17936
|
-
description: ID of inbox.
|
|
19258
|
+
description: The ID of the inbox.
|
|
17937
19259
|
title: InboxId
|
|
17938
19260
|
type_metrics:MetricEventType:
|
|
17939
19261
|
type: string
|
|
@@ -18315,7 +19637,7 @@ components:
|
|
|
18315
19637
|
title: Count
|
|
18316
19638
|
type_inboxes:InboxId:
|
|
18317
19639
|
type: string
|
|
18318
|
-
description: ID of inbox.
|
|
19640
|
+
description: The ID of the inbox.
|
|
18319
19641
|
title: InboxId
|
|
18320
19642
|
type_threads:ThreadId:
|
|
18321
19643
|
type: string
|
|
@@ -18717,7 +20039,7 @@ components:
|
|
|
18717
20039
|
title: ThreadId
|
|
18718
20040
|
type_inboxes:InboxId:
|
|
18719
20041
|
type: string
|
|
18720
|
-
description: ID of inbox.
|
|
20042
|
+
description: The ID of the inbox.
|
|
18721
20043
|
title: InboxId
|
|
18722
20044
|
type_threads:ThreadLabels:
|
|
18723
20045
|
type: array
|
|
@@ -19595,7 +20917,7 @@ components:
|
|
|
19595
20917
|
title: Count
|
|
19596
20918
|
type_inboxes:InboxId:
|
|
19597
20919
|
type: string
|
|
19598
|
-
description: ID of inbox.
|
|
20920
|
+
description: The ID of the inbox.
|
|
19599
20921
|
title: InboxId
|
|
19600
20922
|
type_threads:ThreadId:
|
|
19601
20923
|
type: string
|
|
@@ -19978,7 +21300,7 @@ components:
|
|
|
19978
21300
|
title: DraftId
|
|
19979
21301
|
type_inboxes:InboxId:
|
|
19980
21302
|
type: string
|
|
19981
|
-
description: ID of inbox.
|
|
21303
|
+
description: The ID of the inbox.
|
|
19982
21304
|
title: InboxId
|
|
19983
21305
|
type_threads:ThreadId:
|
|
19984
21306
|
type: string
|
|
@@ -20630,6 +21952,11 @@ paths:
|
|
|
20630
21952
|
required: false
|
|
20631
21953
|
schema:
|
|
20632
21954
|
$ref: '#/components/schemas/type_:PageToken'
|
|
21955
|
+
- name: ascending
|
|
21956
|
+
in: query
|
|
21957
|
+
required: false
|
|
21958
|
+
schema:
|
|
21959
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
20633
21960
|
- name: Authorization
|
|
20634
21961
|
in: header
|
|
20635
21962
|
description: Bearer authentication
|
|
@@ -20658,6 +21985,10 @@ components:
|
|
|
20658
21985
|
type: string
|
|
20659
21986
|
description: Page token for pagination.
|
|
20660
21987
|
title: PageToken
|
|
21988
|
+
type_:Ascending:
|
|
21989
|
+
type: boolean
|
|
21990
|
+
description: Sort in ascending temporal order.
|
|
21991
|
+
title: Ascending
|
|
20661
21992
|
type_:Count:
|
|
20662
21993
|
type: integer
|
|
20663
21994
|
description: Number of items returned.
|
|
@@ -23256,6 +24587,11 @@ paths:
|
|
|
23256
24587
|
required: false
|
|
23257
24588
|
schema:
|
|
23258
24589
|
$ref: '#/components/schemas/type_:PageToken'
|
|
24590
|
+
- name: ascending
|
|
24591
|
+
in: query
|
|
24592
|
+
required: false
|
|
24593
|
+
schema:
|
|
24594
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
23259
24595
|
- name: Authorization
|
|
23260
24596
|
in: header
|
|
23261
24597
|
description: Bearer authentication
|
|
@@ -23284,6 +24620,10 @@ components:
|
|
|
23284
24620
|
type: string
|
|
23285
24621
|
description: Page token for pagination.
|
|
23286
24622
|
title: PageToken
|
|
24623
|
+
type_:Ascending:
|
|
24624
|
+
type: boolean
|
|
24625
|
+
description: Sort in ascending temporal order.
|
|
24626
|
+
title: Ascending
|
|
23287
24627
|
type_:Count:
|
|
23288
24628
|
type: integer
|
|
23289
24629
|
description: Number of items returned.
|
|
@@ -24754,7 +26094,7 @@ components:
|
|
|
24754
26094
|
title: EventId
|
|
24755
26095
|
type_inboxes:InboxId:
|
|
24756
26096
|
type: string
|
|
24757
|
-
description: ID of inbox.
|
|
26097
|
+
description: The ID of the inbox.
|
|
24758
26098
|
title: InboxId
|
|
24759
26099
|
type_threads:ThreadId:
|
|
24760
26100
|
type: string
|
|
@@ -25183,7 +26523,7 @@ components:
|
|
|
25183
26523
|
title: EventId
|
|
25184
26524
|
type_inboxes:InboxId:
|
|
25185
26525
|
type: string
|
|
25186
|
-
description: ID of inbox.
|
|
26526
|
+
description: The ID of the inbox.
|
|
25187
26527
|
title: InboxId
|
|
25188
26528
|
type_threads:ThreadId:
|
|
25189
26529
|
type: string
|
|
@@ -25309,7 +26649,7 @@ components:
|
|
|
25309
26649
|
title: EventId
|
|
25310
26650
|
type_inboxes:InboxId:
|
|
25311
26651
|
type: string
|
|
25312
|
-
description: ID of inbox.
|
|
26652
|
+
description: The ID of the inbox.
|
|
25313
26653
|
title: InboxId
|
|
25314
26654
|
type_threads:ThreadId:
|
|
25315
26655
|
type: string
|
|
@@ -25435,7 +26775,7 @@ components:
|
|
|
25435
26775
|
title: EventId
|
|
25436
26776
|
type_inboxes:InboxId:
|
|
25437
26777
|
type: string
|
|
25438
|
-
description: ID of inbox.
|
|
26778
|
+
description: The ID of the inbox.
|
|
25439
26779
|
title: InboxId
|
|
25440
26780
|
type_threads:ThreadId:
|
|
25441
26781
|
type: string
|
|
@@ -25582,7 +26922,7 @@ components:
|
|
|
25582
26922
|
title: EventId
|
|
25583
26923
|
type_inboxes:InboxId:
|
|
25584
26924
|
type: string
|
|
25585
|
-
description: ID of inbox.
|
|
26925
|
+
description: The ID of the inbox.
|
|
25586
26926
|
title: InboxId
|
|
25587
26927
|
type_threads:ThreadId:
|
|
25588
26928
|
type: string
|
|
@@ -25716,7 +27056,7 @@ components:
|
|
|
25716
27056
|
title: EventId
|
|
25717
27057
|
type_inboxes:InboxId:
|
|
25718
27058
|
type: string
|
|
25719
|
-
description: ID of inbox.
|
|
27059
|
+
description: The ID of the inbox.
|
|
25720
27060
|
title: InboxId
|
|
25721
27061
|
type_threads:ThreadId:
|
|
25722
27062
|
type: string
|
|
@@ -26117,7 +27457,7 @@ components:
|
|
|
26117
27457
|
title: EventId
|
|
26118
27458
|
type_inboxes:InboxId:
|
|
26119
27459
|
type: string
|
|
26120
|
-
description: ID of inbox.
|
|
27460
|
+
description: The ID of the inbox.
|
|
26121
27461
|
title: InboxId
|
|
26122
27462
|
type_threads:ThreadId:
|
|
26123
27463
|
type: string
|
|
@@ -27226,6 +28566,11 @@ paths:
|
|
|
27226
28566
|
required: false
|
|
27227
28567
|
schema:
|
|
27228
28568
|
$ref: '#/components/schemas/type_:PageToken'
|
|
28569
|
+
- name: ascending
|
|
28570
|
+
in: query
|
|
28571
|
+
required: false
|
|
28572
|
+
schema:
|
|
28573
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
27229
28574
|
- name: Authorization
|
|
27230
28575
|
in: header
|
|
27231
28576
|
description: Bearer authentication
|
|
@@ -27254,6 +28599,10 @@ components:
|
|
|
27254
28599
|
type: string
|
|
27255
28600
|
description: Page token for pagination.
|
|
27256
28601
|
title: PageToken
|
|
28602
|
+
type_:Ascending:
|
|
28603
|
+
type: boolean
|
|
28604
|
+
description: Sort in ascending temporal order.
|
|
28605
|
+
title: Ascending
|
|
27257
28606
|
type_:Count:
|
|
27258
28607
|
type: integer
|
|
27259
28608
|
description: Number of items returned.
|
|
@@ -27957,6 +29306,11 @@ paths:
|
|
|
27957
29306
|
required: false
|
|
27958
29307
|
schema:
|
|
27959
29308
|
$ref: '#/components/schemas/type_:PageToken'
|
|
29309
|
+
- name: ascending
|
|
29310
|
+
in: query
|
|
29311
|
+
required: false
|
|
29312
|
+
schema:
|
|
29313
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
27960
29314
|
- name: Authorization
|
|
27961
29315
|
in: header
|
|
27962
29316
|
description: Bearer authentication
|
|
@@ -27985,6 +29339,10 @@ components:
|
|
|
27985
29339
|
type: string
|
|
27986
29340
|
description: Page token for pagination.
|
|
27987
29341
|
title: PageToken
|
|
29342
|
+
type_:Ascending:
|
|
29343
|
+
type: boolean
|
|
29344
|
+
description: Sort in ascending temporal order.
|
|
29345
|
+
title: Ascending
|
|
27988
29346
|
type_:Count:
|
|
27989
29347
|
type: integer
|
|
27990
29348
|
description: Number of items returned.
|
|
@@ -28925,6 +30283,11 @@ paths:
|
|
|
28925
30283
|
required: false
|
|
28926
30284
|
schema:
|
|
28927
30285
|
$ref: '#/components/schemas/type_:PageToken'
|
|
30286
|
+
- name: ascending
|
|
30287
|
+
in: query
|
|
30288
|
+
required: false
|
|
30289
|
+
schema:
|
|
30290
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
28928
30291
|
- name: Authorization
|
|
28929
30292
|
in: header
|
|
28930
30293
|
description: Bearer authentication
|
|
@@ -28963,13 +30326,17 @@ components:
|
|
|
28963
30326
|
type: string
|
|
28964
30327
|
description: Page token for pagination.
|
|
28965
30328
|
title: PageToken
|
|
30329
|
+
type_:Ascending:
|
|
30330
|
+
type: boolean
|
|
30331
|
+
description: Sort in ascending temporal order.
|
|
30332
|
+
title: Ascending
|
|
28966
30333
|
type_:Count:
|
|
28967
30334
|
type: integer
|
|
28968
30335
|
description: Number of items returned.
|
|
28969
30336
|
title: Count
|
|
28970
30337
|
type_inboxes:InboxId:
|
|
28971
30338
|
type: string
|
|
28972
|
-
description: ID of inbox.
|
|
30339
|
+
description: The ID of the inbox.
|
|
28973
30340
|
title: InboxId
|
|
28974
30341
|
type_inboxes:DisplayName:
|
|
28975
30342
|
type: string
|
|
@@ -29240,7 +30607,7 @@ components:
|
|
|
29240
30607
|
title: PodId
|
|
29241
30608
|
type_inboxes:InboxId:
|
|
29242
30609
|
type: string
|
|
29243
|
-
description: ID of inbox.
|
|
30610
|
+
description: The ID of the inbox.
|
|
29244
30611
|
title: InboxId
|
|
29245
30612
|
type_inboxes:DisplayName:
|
|
29246
30613
|
type: string
|
|
@@ -29519,7 +30886,7 @@ components:
|
|
|
29519
30886
|
title: CreateInboxRequest
|
|
29520
30887
|
type_inboxes:InboxId:
|
|
29521
30888
|
type: string
|
|
29522
|
-
description: ID of inbox.
|
|
30889
|
+
description: The ID of the inbox.
|
|
29523
30890
|
title: InboxId
|
|
29524
30891
|
type_inboxes:Inbox:
|
|
29525
30892
|
type: object
|
|
@@ -29775,7 +31142,7 @@ components:
|
|
|
29775
31142
|
title: PodId
|
|
29776
31143
|
type_inboxes:InboxId:
|
|
29777
31144
|
type: string
|
|
29778
|
-
description: ID of inbox.
|
|
31145
|
+
description: The ID of the inbox.
|
|
29779
31146
|
title: InboxId
|
|
29780
31147
|
type_:ErrorName:
|
|
29781
31148
|
type: string
|
|
@@ -29999,6 +31366,11 @@ paths:
|
|
|
29999
31366
|
required: false
|
|
30000
31367
|
schema:
|
|
30001
31368
|
$ref: '#/components/schemas/type_:IncludeBlocked'
|
|
31369
|
+
- name: include_trash
|
|
31370
|
+
in: query
|
|
31371
|
+
required: false
|
|
31372
|
+
schema:
|
|
31373
|
+
$ref: '#/components/schemas/type_:IncludeTrash'
|
|
30002
31374
|
- name: Authorization
|
|
30003
31375
|
in: header
|
|
30004
31376
|
description: Bearer authentication
|
|
@@ -30065,13 +31437,17 @@ components:
|
|
|
30065
31437
|
type: boolean
|
|
30066
31438
|
description: Include blocked in results.
|
|
30067
31439
|
title: IncludeBlocked
|
|
31440
|
+
type_:IncludeTrash:
|
|
31441
|
+
type: boolean
|
|
31442
|
+
description: Include trash in results.
|
|
31443
|
+
title: IncludeTrash
|
|
30068
31444
|
type_:Count:
|
|
30069
31445
|
type: integer
|
|
30070
31446
|
description: Number of items returned.
|
|
30071
31447
|
title: Count
|
|
30072
31448
|
type_inboxes:InboxId:
|
|
30073
31449
|
type: string
|
|
30074
|
-
description: ID of inbox.
|
|
31450
|
+
description: The ID of the inbox.
|
|
30075
31451
|
title: InboxId
|
|
30076
31452
|
type_threads:ThreadId:
|
|
30077
31453
|
type: string
|
|
@@ -30484,7 +31860,7 @@ components:
|
|
|
30484
31860
|
title: ThreadId
|
|
30485
31861
|
type_inboxes:InboxId:
|
|
30486
31862
|
type: string
|
|
30487
|
-
description: ID of inbox.
|
|
31863
|
+
description: The ID of the inbox.
|
|
30488
31864
|
title: InboxId
|
|
30489
31865
|
type_threads:ThreadLabels:
|
|
30490
31866
|
type: array
|
|
@@ -31382,7 +32758,7 @@ components:
|
|
|
31382
32758
|
title: Count
|
|
31383
32759
|
type_inboxes:InboxId:
|
|
31384
32760
|
type: string
|
|
31385
|
-
description: ID of inbox.
|
|
32761
|
+
description: The ID of the inbox.
|
|
31386
32762
|
title: InboxId
|
|
31387
32763
|
type_threads:ThreadId:
|
|
31388
32764
|
type: string
|
|
@@ -31776,7 +33152,7 @@ components:
|
|
|
31776
33152
|
title: DraftId
|
|
31777
33153
|
type_inboxes:InboxId:
|
|
31778
33154
|
type: string
|
|
31779
|
-
description: ID of inbox.
|
|
33155
|
+
description: The ID of the inbox.
|
|
31780
33156
|
title: InboxId
|
|
31781
33157
|
type_threads:ThreadId:
|
|
31782
33158
|
type: string
|
|
@@ -32444,6 +33820,11 @@ paths:
|
|
|
32444
33820
|
required: false
|
|
32445
33821
|
schema:
|
|
32446
33822
|
$ref: '#/components/schemas/type_:PageToken'
|
|
33823
|
+
- name: ascending
|
|
33824
|
+
in: query
|
|
33825
|
+
required: false
|
|
33826
|
+
schema:
|
|
33827
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
32447
33828
|
- name: Authorization
|
|
32448
33829
|
in: header
|
|
32449
33830
|
description: Bearer authentication
|
|
@@ -32482,6 +33863,10 @@ components:
|
|
|
32482
33863
|
type: string
|
|
32483
33864
|
description: Page token for pagination.
|
|
32484
33865
|
title: PageToken
|
|
33866
|
+
type_:Ascending:
|
|
33867
|
+
type: boolean
|
|
33868
|
+
description: Sort in ascending temporal order.
|
|
33869
|
+
title: Ascending
|
|
32485
33870
|
type_:Count:
|
|
32486
33871
|
type: integer
|
|
32487
33872
|
description: Number of items returned.
|
|
@@ -33049,6 +34434,318 @@ let dataTask = session.dataTask(with: request as URLRequest, completionHandler:
|
|
|
33049
34434
|
dataTask.resume()
|
|
33050
34435
|
```
|
|
33051
34436
|
|
|
34437
|
+
# Get Domain
|
|
34438
|
+
|
|
34439
|
+
GET https://api.agentmail.to/v0/pods/{pod_id}/domains/{domain_id}
|
|
34440
|
+
|
|
34441
|
+
Reference: https://docs.agentmail.to/api-reference/pods/domains/get
|
|
34442
|
+
|
|
34443
|
+
## OpenAPI Specification
|
|
34444
|
+
|
|
34445
|
+
```yaml
|
|
34446
|
+
openapi: 3.1.0
|
|
34447
|
+
info:
|
|
34448
|
+
title: api
|
|
34449
|
+
version: 1.0.0
|
|
34450
|
+
paths:
|
|
34451
|
+
/v0/pods/{pod_id}/domains/{domain_id}:
|
|
34452
|
+
get:
|
|
34453
|
+
operationId: get
|
|
34454
|
+
summary: Get Domain
|
|
34455
|
+
tags:
|
|
34456
|
+
- subpackage_pods.subpackage_pods/domains
|
|
34457
|
+
parameters:
|
|
34458
|
+
- name: pod_id
|
|
34459
|
+
in: path
|
|
34460
|
+
required: true
|
|
34461
|
+
schema:
|
|
34462
|
+
$ref: '#/components/schemas/type_pods:PodId'
|
|
34463
|
+
- name: domain_id
|
|
34464
|
+
in: path
|
|
34465
|
+
required: true
|
|
34466
|
+
schema:
|
|
34467
|
+
$ref: '#/components/schemas/type_domains:DomainId'
|
|
34468
|
+
- name: Authorization
|
|
34469
|
+
in: header
|
|
34470
|
+
description: Bearer authentication
|
|
34471
|
+
required: true
|
|
34472
|
+
schema:
|
|
34473
|
+
type: string
|
|
34474
|
+
responses:
|
|
34475
|
+
'200':
|
|
34476
|
+
description: Response with status 200
|
|
34477
|
+
content:
|
|
34478
|
+
application/json:
|
|
34479
|
+
schema:
|
|
34480
|
+
$ref: '#/components/schemas/type_domains:Domain'
|
|
34481
|
+
'404':
|
|
34482
|
+
description: Error response with status 404
|
|
34483
|
+
content:
|
|
34484
|
+
application/json:
|
|
34485
|
+
schema:
|
|
34486
|
+
$ref: '#/components/schemas/type_:ErrorResponse'
|
|
34487
|
+
servers:
|
|
34488
|
+
- url: https://api.agentmail.to
|
|
34489
|
+
- url: https://x402.api.agentmail.to
|
|
34490
|
+
- url: https://mpp.api.agentmail.to
|
|
34491
|
+
- url: https://api.agentmail.eu
|
|
34492
|
+
components:
|
|
34493
|
+
schemas:
|
|
34494
|
+
type_pods:PodId:
|
|
34495
|
+
type: string
|
|
34496
|
+
description: ID of pod.
|
|
34497
|
+
title: PodId
|
|
34498
|
+
type_domains:DomainId:
|
|
34499
|
+
type: string
|
|
34500
|
+
description: The name of the domain. (e.g., " your-domain.com")
|
|
34501
|
+
title: DomainId
|
|
34502
|
+
type_domains:VerificationStatus:
|
|
34503
|
+
type: string
|
|
34504
|
+
enum:
|
|
34505
|
+
- NOT_STARTED
|
|
34506
|
+
- PENDING
|
|
34507
|
+
- INVALID
|
|
34508
|
+
- FAILED
|
|
34509
|
+
- VERIFYING
|
|
34510
|
+
- VERIFIED
|
|
34511
|
+
title: VerificationStatus
|
|
34512
|
+
type_domains:FeedbackEnabled:
|
|
34513
|
+
type: boolean
|
|
34514
|
+
description: Bounce and complaint notifications are sent to your inboxes.
|
|
34515
|
+
title: FeedbackEnabled
|
|
34516
|
+
type_domains:RecordType:
|
|
34517
|
+
type: string
|
|
34518
|
+
enum:
|
|
34519
|
+
- TXT
|
|
34520
|
+
- CNAME
|
|
34521
|
+
- MX
|
|
34522
|
+
title: RecordType
|
|
34523
|
+
type_domains:RecordStatus:
|
|
34524
|
+
type: string
|
|
34525
|
+
enum:
|
|
34526
|
+
- MISSING
|
|
34527
|
+
- INVALID
|
|
34528
|
+
- VALID
|
|
34529
|
+
title: RecordStatus
|
|
34530
|
+
type_domains:VerificationRecord:
|
|
34531
|
+
type: object
|
|
34532
|
+
properties:
|
|
34533
|
+
type:
|
|
34534
|
+
$ref: '#/components/schemas/type_domains:RecordType'
|
|
34535
|
+
description: The type of the DNS record.
|
|
34536
|
+
name:
|
|
34537
|
+
type: string
|
|
34538
|
+
description: The name or host of the record.
|
|
34539
|
+
value:
|
|
34540
|
+
type: string
|
|
34541
|
+
description: The value of the record.
|
|
34542
|
+
status:
|
|
34543
|
+
$ref: '#/components/schemas/type_domains:RecordStatus'
|
|
34544
|
+
description: The verification status of this specific record.
|
|
34545
|
+
priority:
|
|
34546
|
+
type: integer
|
|
34547
|
+
description: The priority of the MX record.
|
|
34548
|
+
required:
|
|
34549
|
+
- type
|
|
34550
|
+
- name
|
|
34551
|
+
- value
|
|
34552
|
+
- status
|
|
34553
|
+
title: VerificationRecord
|
|
34554
|
+
type_domains:ClientId:
|
|
34555
|
+
type: string
|
|
34556
|
+
description: Client ID of domain.
|
|
34557
|
+
title: ClientId
|
|
34558
|
+
type_domains:Domain:
|
|
34559
|
+
type: object
|
|
34560
|
+
properties:
|
|
34561
|
+
pod_id:
|
|
34562
|
+
$ref: '#/components/schemas/type_pods:PodId'
|
|
34563
|
+
domain_id:
|
|
34564
|
+
$ref: '#/components/schemas/type_domains:DomainId'
|
|
34565
|
+
status:
|
|
34566
|
+
$ref: '#/components/schemas/type_domains:VerificationStatus'
|
|
34567
|
+
description: The verification status of the domain.
|
|
34568
|
+
feedback_enabled:
|
|
34569
|
+
$ref: '#/components/schemas/type_domains:FeedbackEnabled'
|
|
34570
|
+
records:
|
|
34571
|
+
type: array
|
|
34572
|
+
items:
|
|
34573
|
+
$ref: '#/components/schemas/type_domains:VerificationRecord'
|
|
34574
|
+
description: A list of DNS records required to verify the domain.
|
|
34575
|
+
client_id:
|
|
34576
|
+
$ref: '#/components/schemas/type_domains:ClientId'
|
|
34577
|
+
updated_at:
|
|
34578
|
+
type: string
|
|
34579
|
+
format: date-time
|
|
34580
|
+
description: Time at which the domain was last updated.
|
|
34581
|
+
created_at:
|
|
34582
|
+
type: string
|
|
34583
|
+
format: date-time
|
|
34584
|
+
description: Time at which the domain was created.
|
|
34585
|
+
required:
|
|
34586
|
+
- domain_id
|
|
34587
|
+
- status
|
|
34588
|
+
- feedback_enabled
|
|
34589
|
+
- records
|
|
34590
|
+
- updated_at
|
|
34591
|
+
- created_at
|
|
34592
|
+
title: Domain
|
|
34593
|
+
type_:ErrorName:
|
|
34594
|
+
type: string
|
|
34595
|
+
description: Name of error.
|
|
34596
|
+
title: ErrorName
|
|
34597
|
+
type_:ErrorMessage:
|
|
34598
|
+
type: string
|
|
34599
|
+
description: Error message.
|
|
34600
|
+
title: ErrorMessage
|
|
34601
|
+
type_:ErrorResponse:
|
|
34602
|
+
type: object
|
|
34603
|
+
properties:
|
|
34604
|
+
name:
|
|
34605
|
+
$ref: '#/components/schemas/type_:ErrorName'
|
|
34606
|
+
message:
|
|
34607
|
+
$ref: '#/components/schemas/type_:ErrorMessage'
|
|
34608
|
+
required:
|
|
34609
|
+
- name
|
|
34610
|
+
- message
|
|
34611
|
+
title: ErrorResponse
|
|
34612
|
+
securitySchemes:
|
|
34613
|
+
Bearer:
|
|
34614
|
+
type: http
|
|
34615
|
+
scheme: bearer
|
|
34616
|
+
|
|
34617
|
+
```
|
|
34618
|
+
|
|
34619
|
+
## SDK Code Examples
|
|
34620
|
+
|
|
34621
|
+
```typescript
|
|
34622
|
+
import { AgentMailClient } from "agentmail";
|
|
34623
|
+
|
|
34624
|
+
async function main() {
|
|
34625
|
+
const client = new AgentMailClient({
|
|
34626
|
+
apiKey: "YOUR_TOKEN_HERE",
|
|
34627
|
+
});
|
|
34628
|
+
await client.pods.domains.get("pod_id", "domain_id");
|
|
34629
|
+
}
|
|
34630
|
+
main();
|
|
34631
|
+
|
|
34632
|
+
```
|
|
34633
|
+
|
|
34634
|
+
```python
|
|
34635
|
+
from agentmail import AgentMail
|
|
34636
|
+
|
|
34637
|
+
client = AgentMail(
|
|
34638
|
+
api_key="YOUR_TOKEN_HERE"
|
|
34639
|
+
)
|
|
34640
|
+
|
|
34641
|
+
client.pods.domains.get(
|
|
34642
|
+
pod_id="pod_id",
|
|
34643
|
+
domain_id="domain_id"
|
|
34644
|
+
)
|
|
34645
|
+
|
|
34646
|
+
```
|
|
34647
|
+
|
|
34648
|
+
```go
|
|
34649
|
+
package main
|
|
34650
|
+
|
|
34651
|
+
import (
|
|
34652
|
+
"fmt"
|
|
34653
|
+
"net/http"
|
|
34654
|
+
"io"
|
|
34655
|
+
)
|
|
34656
|
+
|
|
34657
|
+
func main() {
|
|
34658
|
+
|
|
34659
|
+
url := "https://api.agentmail.to/v0/pods/pod_id/domains/domain_id"
|
|
34660
|
+
|
|
34661
|
+
req, _ := http.NewRequest("GET", url, nil)
|
|
34662
|
+
|
|
34663
|
+
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
34664
|
+
|
|
34665
|
+
res, _ := http.DefaultClient.Do(req)
|
|
34666
|
+
|
|
34667
|
+
defer res.Body.Close()
|
|
34668
|
+
body, _ := io.ReadAll(res.Body)
|
|
34669
|
+
|
|
34670
|
+
fmt.Println(res)
|
|
34671
|
+
fmt.Println(string(body))
|
|
34672
|
+
|
|
34673
|
+
}
|
|
34674
|
+
```
|
|
34675
|
+
|
|
34676
|
+
```ruby
|
|
34677
|
+
require 'uri'
|
|
34678
|
+
require 'net/http'
|
|
34679
|
+
|
|
34680
|
+
url = URI("https://api.agentmail.to/v0/pods/pod_id/domains/domain_id")
|
|
34681
|
+
|
|
34682
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
34683
|
+
http.use_ssl = true
|
|
34684
|
+
|
|
34685
|
+
request = Net::HTTP::Get.new(url)
|
|
34686
|
+
request["Authorization"] = 'Bearer <api_key>'
|
|
34687
|
+
|
|
34688
|
+
response = http.request(request)
|
|
34689
|
+
puts response.read_body
|
|
34690
|
+
```
|
|
34691
|
+
|
|
34692
|
+
```java
|
|
34693
|
+
import com.mashape.unirest.http.HttpResponse;
|
|
34694
|
+
import com.mashape.unirest.http.Unirest;
|
|
34695
|
+
|
|
34696
|
+
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/domains/domain_id")
|
|
34697
|
+
.header("Authorization", "Bearer <api_key>")
|
|
34698
|
+
.asString();
|
|
34699
|
+
```
|
|
34700
|
+
|
|
34701
|
+
```php
|
|
34702
|
+
<?php
|
|
34703
|
+
require_once('vendor/autoload.php');
|
|
34704
|
+
|
|
34705
|
+
$client = new \GuzzleHttp\Client();
|
|
34706
|
+
|
|
34707
|
+
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/domains/domain_id', [
|
|
34708
|
+
'headers' => [
|
|
34709
|
+
'Authorization' => 'Bearer <api_key>',
|
|
34710
|
+
],
|
|
34711
|
+
]);
|
|
34712
|
+
|
|
34713
|
+
echo $response->getBody();
|
|
34714
|
+
```
|
|
34715
|
+
|
|
34716
|
+
```csharp
|
|
34717
|
+
using RestSharp;
|
|
34718
|
+
|
|
34719
|
+
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/domains/domain_id");
|
|
34720
|
+
var request = new RestRequest(Method.GET);
|
|
34721
|
+
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
34722
|
+
IRestResponse response = client.Execute(request);
|
|
34723
|
+
```
|
|
34724
|
+
|
|
34725
|
+
```swift
|
|
34726
|
+
import Foundation
|
|
34727
|
+
|
|
34728
|
+
let headers = ["Authorization": "Bearer <api_key>"]
|
|
34729
|
+
|
|
34730
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/domains/domain_id")! as URL,
|
|
34731
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
34732
|
+
timeoutInterval: 10.0)
|
|
34733
|
+
request.httpMethod = "GET"
|
|
34734
|
+
request.allHTTPHeaderFields = headers
|
|
34735
|
+
|
|
34736
|
+
let session = URLSession.shared
|
|
34737
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
34738
|
+
if (error != nil) {
|
|
34739
|
+
print(error as Any)
|
|
34740
|
+
} else {
|
|
34741
|
+
let httpResponse = response as? HTTPURLResponse
|
|
34742
|
+
print(httpResponse)
|
|
34743
|
+
}
|
|
34744
|
+
})
|
|
34745
|
+
|
|
34746
|
+
dataTask.resume()
|
|
34747
|
+
```
|
|
34748
|
+
|
|
33052
34749
|
# Delete Domain
|
|
33053
34750
|
|
|
33054
34751
|
DELETE https://api.agentmail.to/v0/pods/{pod_id}/domains/{domain_id}
|