agentmail 0.4.0 → 0.4.2
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/types/ApiKey.d.ts +2 -0
- package/dist/cjs/api/resources/apiKeys/types/CreateApiKeyResponse.d.ts +2 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +4 -1
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +12 -5
- package/dist/cjs/api/resources/inboxes/resources/threads/client/requests/DeleteThreadRequest.d.ts +8 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/client/requests/DeleteThreadRequest.js +3 -0
- package/dist/cjs/api/resources/inboxes/resources/threads/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/pods/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/pods/client/Client.js +15 -10
- 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/index.d.ts +2 -0
- package/dist/cjs/api/resources/pods/resources/index.js +3 -1
- package/dist/cjs/api/resources/threads/client/Client.js +2 -1
- package/dist/cjs/api/resources/threads/client/requests/ListThreadsRequest.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/types/ApiKey.d.mts +2 -0
- package/dist/esm/api/resources/apiKeys/types/CreateApiKeyResponse.d.mts +2 -0
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +4 -1
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +12 -5
- package/dist/esm/api/resources/inboxes/resources/threads/client/requests/DeleteThreadRequest.d.mts +8 -0
- package/dist/esm/api/resources/inboxes/resources/threads/client/requests/DeleteThreadRequest.mjs +2 -0
- package/dist/esm/api/resources/inboxes/resources/threads/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/pods/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/pods/client/Client.mjs +5 -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/index.d.mts +2 -0
- package/dist/esm/api/resources/pods/resources/index.mjs +2 -0
- package/dist/esm/api/resources/threads/client/Client.mjs +2 -1
- package/dist/esm/api/resources/threads/client/requests/ListThreadsRequest.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 +2275 -97
- package/dist/llms.txt +6 -2
- package/package.json +1 -1
- package/reference.md +197 -1
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
|
|
|
@@ -593,7 +763,7 @@ Replying to an existing `Message` adds your new `Message` to the same `Thread`,
|
|
|
593
763
|
# Python example
|
|
594
764
|
reply = client.inboxes.messages.reply(
|
|
595
765
|
inbox_id='my_inbox@domain.com'
|
|
596
|
-
message_id='
|
|
766
|
+
message_id='<abc123@agentmail.to>',
|
|
597
767
|
text="Thanks for the referral!",
|
|
598
768
|
attachments=[
|
|
599
769
|
SendAttachment(
|
|
@@ -611,7 +781,7 @@ Replying to an existing `Message` adds your new `Message` to the same `Thread`,
|
|
|
611
781
|
|
|
612
782
|
const reply = await client.inboxes.messages.reply(
|
|
613
783
|
"my_inbox@domain.com",
|
|
614
|
-
"
|
|
784
|
+
"<abc123@agentmail.to>",
|
|
615
785
|
{
|
|
616
786
|
text: "Thanks for the referral!",
|
|
617
787
|
attachments: [
|
|
@@ -640,7 +810,7 @@ You can retrieve the details of any specific `Message` by providing its ID along
|
|
|
640
810
|
<CodeBlocks>
|
|
641
811
|
```python title="Python"
|
|
642
812
|
|
|
643
|
-
message = client.inboxes.messages.get(inbox_id = 'my_inbox@agentmail.to', message_id = '
|
|
813
|
+
message = client.inboxes.messages.get(inbox_id = 'my_inbox@agentmail.to', message_id = '<abc123@agentmail.to>')
|
|
644
814
|
|
|
645
815
|
print(f"Retrieved message with subject: {message.subject}")
|
|
646
816
|
|
|
@@ -650,7 +820,7 @@ You can retrieve the details of any specific `Message` by providing its ID along
|
|
|
650
820
|
|
|
651
821
|
await client.inboxes.messages.get(
|
|
652
822
|
"my_inbox@domain.com",
|
|
653
|
-
"
|
|
823
|
+
"<abc123@agentmail.to>"
|
|
654
824
|
)
|
|
655
825
|
|
|
656
826
|
console.log(`Retrieved message with subject: ${message.subject}`);
|
|
@@ -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
|
|
|
@@ -1143,7 +1568,7 @@ You can modify the `Labels` on a `Message` that has already been sent using the
|
|
|
1143
1568
|
|
|
1144
1569
|
client.messages.update(
|
|
1145
1570
|
inbox_id='outbound@domain.com',
|
|
1146
|
-
message_id='
|
|
1571
|
+
message_id='<abc123@agentmail.to>',
|
|
1147
1572
|
add_labels=["resolved"],
|
|
1148
1573
|
remove_labels=['unresolved']
|
|
1149
1574
|
)
|
|
@@ -1156,7 +1581,7 @@ You can modify the `Labels` on a `Message` that has already been sent using the
|
|
|
1156
1581
|
|
|
1157
1582
|
await client.inboxes.messages.update(
|
|
1158
1583
|
"my_inbox@domain.com",
|
|
1159
|
-
"
|
|
1584
|
+
"<abc123@agentmail.to>",
|
|
1160
1585
|
{
|
|
1161
1586
|
addLabels: [
|
|
1162
1587
|
"resolved"
|
|
@@ -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", "<abc123@agentmail.to>", 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", "<abc123@agentmail.to>", {
|
|
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
|
|
|
@@ -1393,7 +1941,7 @@ If you know the `Message` an `Attachment` belongs to, you can retrieve it direct
|
|
|
1393
1941
|
<CodeBlocks>
|
|
1394
1942
|
```python
|
|
1395
1943
|
inbox_id = "inbox_123"
|
|
1396
|
-
message_id = "
|
|
1944
|
+
message_id = "<def456@agentmail.to>"
|
|
1397
1945
|
attachment_id = "attach_789" # From the message object
|
|
1398
1946
|
|
|
1399
1947
|
file_data = client.inboxes.messages.get_attachment(
|
|
@@ -1411,7 +1959,7 @@ If you know the `Message` an `Attachment` belongs to, you can retrieve it direct
|
|
|
1411
1959
|
|
|
1412
1960
|
```typescript title="TypeScript"
|
|
1413
1961
|
const inboxId = "inbox_123";
|
|
1414
|
-
const messageId = "
|
|
1962
|
+
const messageId = "<def456@agentmail.to>";
|
|
1415
1963
|
const attachmentId = "attach_789"; // From the message object
|
|
1416
1964
|
|
|
1417
1965
|
const fileData = await client.inboxes.messages.get_attachment(
|
|
@@ -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", "<abc123@agentmail.to>", "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", "<abc123@agentmail.to>", "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
|
|
|
@@ -2098,19 +3049,19 @@ curl -X POST -H "Authorization: Bearer $AGENTMAIL_API_KEY" \
|
|
|
2098
3049
|
-H "Content-Type: application/json" \
|
|
2099
3050
|
-d '{
|
|
2100
3051
|
"url": "https://your-openclaw-webhook-url",
|
|
2101
|
-
"
|
|
3052
|
+
"event_types": ["message.received"]
|
|
2102
3053
|
}' \
|
|
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
|
***
|
|
@@ -3551,19 +4502,19 @@ The process is straightforward:
|
|
|
3551
4502
|
```python
|
|
3552
4503
|
client.webhooks.create(
|
|
3553
4504
|
url="https://<your-ngrok-url>.ngrok-free.app/webhooks",
|
|
3554
|
-
|
|
4505
|
+
event_types=["message.received", "message.sent"],
|
|
3555
4506
|
)
|
|
3556
4507
|
```
|
|
3557
4508
|
|
|
3558
4509
|
```typescript
|
|
3559
4510
|
await client.webhooks.create({
|
|
3560
4511
|
url: "https://<your-ngrok-url>.ngrok-free.app/webhooks",
|
|
3561
|
-
|
|
4512
|
+
eventTypes: ["message.received", "message.sent"],
|
|
3562
4513
|
});
|
|
3563
4514
|
```
|
|
3564
4515
|
</CodeBlocks>
|
|
3565
4516
|
|
|
3566
|
-
Specify which events to receive; omit `
|
|
4517
|
+
Specify which events to receive; omit `event_types` to subscribe to all event types.
|
|
3567
4518
|
</Step>
|
|
3568
4519
|
|
|
3569
4520
|
<Step title="3. AgentMail Sends Events">
|
|
@@ -3584,7 +4535,7 @@ When AgentMail sends a webhook, the payload includes `event_type` and `event_id`
|
|
|
3584
4535
|
"organization_id": "org_abc123...",
|
|
3585
4536
|
"inbox_id": "inbox_def456...",
|
|
3586
4537
|
"thread_id": "thd_ghi789...",
|
|
3587
|
-
"message_id": "
|
|
4538
|
+
"message_id": "<jkl012@agentmail.to>",
|
|
3588
4539
|
"labels": ["received"],
|
|
3589
4540
|
"timestamp": "2023-10-27T10:00:00Z",
|
|
3590
4541
|
"reply_to": ["reply-to@example.com"],
|
|
@@ -3604,8 +4555,8 @@ When AgentMail sends a webhook, the payload includes `event_type` and `event_id`
|
|
|
3604
4555
|
"inline": false
|
|
3605
4556
|
}
|
|
3606
4557
|
],
|
|
3607
|
-
"in_reply_to": "
|
|
3608
|
-
"references": ["
|
|
4558
|
+
"in_reply_to": "<parent456@agentmail.to>",
|
|
4559
|
+
"references": ["<ref001@agentmail.to>", "<ref002@agentmail.to>"],
|
|
3609
4560
|
"sort_key": "some-sort-key",
|
|
3610
4561
|
"updated_at": "2023-10-27T10:00:05Z",
|
|
3611
4562
|
"created_at": "2023-10-27T10:00:00Z"
|
|
@@ -3631,6 +4582,73 @@ When AgentMail sends a webhook, the payload includes `event_type` and `event_id`
|
|
|
3631
4582
|
* **`attachments`** (`array<object>`): A list of attachments, each with its own `attachment_id`, `filename`, `content_type`, `size`, and `inline` status.
|
|
3632
4583
|
* **`in_reply_to`** (`string`): The `message_id` of the email this message is a reply to, if applicable.
|
|
3633
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, event_types?, 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", event_types=["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
|
+
|
|
3634
4652
|
## Next Steps
|
|
3635
4653
|
|
|
3636
4654
|
<CardGroup>
|
|
@@ -3748,6 +4766,72 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3748
4766
|
```
|
|
3749
4767
|
</CodeBlocks>
|
|
3750
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
|
+
|
|
3751
4835
|
## Message Events
|
|
3752
4836
|
|
|
3753
4837
|
### `message.received`
|
|
@@ -3771,7 +4855,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3771
4855
|
"message": {
|
|
3772
4856
|
"inbox_id": "inbox_456def",
|
|
3773
4857
|
"thread_id": "thd_789ghi",
|
|
3774
|
-
"message_id": "
|
|
4858
|
+
"message_id": "<abc123@agentmail.to>",
|
|
3775
4859
|
"labels": ["received"],
|
|
3776
4860
|
"timestamp": "2023-10-27T10:00:00Z",
|
|
3777
4861
|
"from": "Jane Doe <jane@example.com>",
|
|
@@ -3793,7 +4877,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3793
4877
|
"recipients": ["Support Agent <support@agentmail.to>"],
|
|
3794
4878
|
"subject": "Question about my account",
|
|
3795
4879
|
"preview": "A short preview of the email text...",
|
|
3796
|
-
"last_message_id": "
|
|
4880
|
+
"last_message_id": "<abc123@agentmail.to>",
|
|
3797
4881
|
"message_count": 1,
|
|
3798
4882
|
"size": 2048,
|
|
3799
4883
|
"updated_at": "2023-10-27T10:00:00Z",
|
|
@@ -3817,7 +4901,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3817
4901
|
"send": {
|
|
3818
4902
|
"inbox_id": "inbox_456def",
|
|
3819
4903
|
"thread_id": "thd_789ghi",
|
|
3820
|
-
"message_id": "
|
|
4904
|
+
"message_id": "<abc123@agentmail.to>",
|
|
3821
4905
|
"timestamp": "2023-10-27T10:05:00Z",
|
|
3822
4906
|
"recipients": [
|
|
3823
4907
|
"recipient@example.com"
|
|
@@ -3841,7 +4925,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3841
4925
|
"delivery": {
|
|
3842
4926
|
"inbox_id": "inbox_456def",
|
|
3843
4927
|
"thread_id": "thd_789ghi",
|
|
3844
|
-
"message_id": "
|
|
4928
|
+
"message_id": "<abc123@agentmail.to>",
|
|
3845
4929
|
"timestamp": "2023-10-27T10:06:00Z",
|
|
3846
4930
|
"recipients": [
|
|
3847
4931
|
"recipient@example.com"
|
|
@@ -3884,7 +4968,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3884
4968
|
"bounce": {
|
|
3885
4969
|
"inbox_id": "inbox_456def",
|
|
3886
4970
|
"thread_id": "thd_789ghi",
|
|
3887
|
-
"message_id": "
|
|
4971
|
+
"message_id": "<abc123@agentmail.to>",
|
|
3888
4972
|
"timestamp": "2023-10-27T10:07:00Z",
|
|
3889
4973
|
"type": "Permanent",
|
|
3890
4974
|
"sub_type": "General",
|
|
@@ -3913,7 +4997,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3913
4997
|
"complaint": {
|
|
3914
4998
|
"inbox_id": "inbox_456def",
|
|
3915
4999
|
"thread_id": "thd_789ghi",
|
|
3916
|
-
"message_id": "
|
|
5000
|
+
"message_id": "<abc123@agentmail.to>",
|
|
3917
5001
|
"timestamp": "2023-10-27T10:08:00Z",
|
|
3918
5002
|
"type": "abuse",
|
|
3919
5003
|
"sub_type": "spam",
|
|
@@ -3939,7 +5023,7 @@ The AgentMail SDKs export typed classes for each webhook event, so you can parse
|
|
|
3939
5023
|
"reject": {
|
|
3940
5024
|
"inbox_id": "inbox_456def",
|
|
3941
5025
|
"thread_id": "thd_789ghi",
|
|
3942
|
-
"message_id": "
|
|
5026
|
+
"message_id": "<abc123@agentmail.to>",
|
|
3943
5027
|
"timestamp": "2023-10-27T10:09:00Z",
|
|
3944
5028
|
"reason": "Invalid recipient address"
|
|
3945
5029
|
}
|
|
@@ -4102,7 +5186,7 @@ webhook_url = "https://your-subdomain.ngrok-free.app/webhooks"
|
|
|
4102
5186
|
|
|
4103
5187
|
webhook = client.webhooks.create(
|
|
4104
5188
|
url=webhook_url,
|
|
4105
|
-
|
|
5189
|
+
event_types=["message.received"], # add others (e.g. message.sent) as needed
|
|
4106
5190
|
client_id="webhook-demo-webhook" # Ensures idempotency
|
|
4107
5191
|
)
|
|
4108
5192
|
|
|
@@ -4223,6 +5307,63 @@ To test your webhook setup:
|
|
|
4223
5307
|
</Accordion>
|
|
4224
5308
|
</AccordionGroup>
|
|
4225
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, event_types=[...], 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", event_types=["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
|
+
|
|
4226
5367
|
## Production Considerations
|
|
4227
5368
|
|
|
4228
5369
|
For production deployments:
|
|
@@ -4410,6 +5551,65 @@ The easiest way to verify webhooks is using the official Svix library, which han
|
|
|
4410
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.
|
|
4411
5552
|
</Callout>
|
|
4412
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
|
+
|
|
4413
5613
|
## Testing Locally with ngrok
|
|
4414
5614
|
|
|
4415
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.
|
|
@@ -5016,6 +6216,57 @@ main();
|
|
|
5016
6216
|
|
|
5017
6217
|
***
|
|
5018
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
|
+
|
|
5019
6270
|
|
|
5020
6271
|
***
|
|
5021
6272
|
|
|
@@ -5024,6 +6275,46 @@ subtitle: Get started with real-time email event streaming
|
|
|
5024
6275
|
slug: websockets/quickstart
|
|
5025
6276
|
---------------------------
|
|
5026
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
|
+
|
|
5027
6318
|
```typescript title="TypeScript"
|
|
5028
6319
|
import { AgentMailClient } from "agentmail";
|
|
5029
6320
|
|
|
@@ -6069,7 +7360,7 @@ def receive_webhook():
|
|
|
6069
7360
|
{
|
|
6070
7361
|
"type": "message.received",
|
|
6071
7362
|
"message": {
|
|
6072
|
-
"message_id": "abc123
|
|
7363
|
+
"message_id": "<abc123@agentmail.to>",
|
|
6073
7364
|
"inbox_id": "auto-reply@agentmail.to",
|
|
6074
7365
|
"from_": "John Doe <john@example.com>",
|
|
6075
7366
|
"subject": "Hello",
|
|
@@ -9010,6 +10301,11 @@ paths:
|
|
|
9010
10301
|
required: false
|
|
9011
10302
|
schema:
|
|
9012
10303
|
$ref: '#/components/schemas/type_:PageToken'
|
|
10304
|
+
- name: ascending
|
|
10305
|
+
in: query
|
|
10306
|
+
required: false
|
|
10307
|
+
schema:
|
|
10308
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
9013
10309
|
- name: Authorization
|
|
9014
10310
|
in: header
|
|
9015
10311
|
description: Bearer authentication
|
|
@@ -9038,6 +10334,10 @@ components:
|
|
|
9038
10334
|
type: string
|
|
9039
10335
|
description: Page token for pagination.
|
|
9040
10336
|
title: PageToken
|
|
10337
|
+
type_:Ascending:
|
|
10338
|
+
type: boolean
|
|
10339
|
+
description: Sort in ascending temporal order.
|
|
10340
|
+
title: Ascending
|
|
9041
10341
|
type_:Count:
|
|
9042
10342
|
type: integer
|
|
9043
10343
|
description: Number of items returned.
|
|
@@ -9048,7 +10348,7 @@ components:
|
|
|
9048
10348
|
title: PodId
|
|
9049
10349
|
type_inboxes:InboxId:
|
|
9050
10350
|
type: string
|
|
9051
|
-
description: ID of inbox.
|
|
10351
|
+
description: The ID of the inbox.
|
|
9052
10352
|
title: InboxId
|
|
9053
10353
|
type_inboxes:DisplayName:
|
|
9054
10354
|
type: string
|
|
@@ -9289,7 +10589,7 @@ components:
|
|
|
9289
10589
|
schemas:
|
|
9290
10590
|
type_inboxes:InboxId:
|
|
9291
10591
|
type: string
|
|
9292
|
-
description: ID of inbox.
|
|
10592
|
+
description: The ID of the inbox.
|
|
9293
10593
|
title: InboxId
|
|
9294
10594
|
type_pods:PodId:
|
|
9295
10595
|
type: string
|
|
@@ -9566,7 +10866,7 @@ components:
|
|
|
9566
10866
|
title: PodId
|
|
9567
10867
|
type_inboxes:InboxId:
|
|
9568
10868
|
type: string
|
|
9569
|
-
description: ID of inbox.
|
|
10869
|
+
description: The ID of the inbox.
|
|
9570
10870
|
title: InboxId
|
|
9571
10871
|
type_inboxes:Inbox:
|
|
9572
10872
|
type: object
|
|
@@ -9810,7 +11110,7 @@ components:
|
|
|
9810
11110
|
schemas:
|
|
9811
11111
|
type_inboxes:InboxId:
|
|
9812
11112
|
type: string
|
|
9813
|
-
description: ID of inbox.
|
|
11113
|
+
description: The ID of the inbox.
|
|
9814
11114
|
title: InboxId
|
|
9815
11115
|
type_inboxes:DisplayName:
|
|
9816
11116
|
type: string
|
|
@@ -10086,7 +11386,7 @@ components:
|
|
|
10086
11386
|
schemas:
|
|
10087
11387
|
type_inboxes:InboxId:
|
|
10088
11388
|
type: string
|
|
10089
|
-
description: ID of inbox.
|
|
11389
|
+
description: The ID of the inbox.
|
|
10090
11390
|
title: InboxId
|
|
10091
11391
|
type_:ErrorName:
|
|
10092
11392
|
type: string
|
|
@@ -10342,7 +11642,7 @@ components:
|
|
|
10342
11642
|
schemas:
|
|
10343
11643
|
type_inboxes:InboxId:
|
|
10344
11644
|
type: string
|
|
10345
|
-
description: ID of inbox.
|
|
11645
|
+
description: The ID of the inbox.
|
|
10346
11646
|
title: InboxId
|
|
10347
11647
|
type_:Limit:
|
|
10348
11648
|
type: integer
|
|
@@ -10791,7 +12091,7 @@ components:
|
|
|
10791
12091
|
schemas:
|
|
10792
12092
|
type_inboxes:InboxId:
|
|
10793
12093
|
type: string
|
|
10794
|
-
description: ID of inbox.
|
|
12094
|
+
description: The ID of the inbox.
|
|
10795
12095
|
title: InboxId
|
|
10796
12096
|
type_threads:ThreadId:
|
|
10797
12097
|
type: string
|
|
@@ -11355,7 +12655,7 @@ components:
|
|
|
11355
12655
|
schemas:
|
|
11356
12656
|
type_inboxes:InboxId:
|
|
11357
12657
|
type: string
|
|
11358
|
-
description: ID of inbox.
|
|
12658
|
+
description: The ID of the inbox.
|
|
11359
12659
|
title: InboxId
|
|
11360
12660
|
type_threads:ThreadId:
|
|
11361
12661
|
type: string
|
|
@@ -11628,7 +12928,7 @@ components:
|
|
|
11628
12928
|
schemas:
|
|
11629
12929
|
type_inboxes:InboxId:
|
|
11630
12930
|
type: string
|
|
11631
|
-
description: ID of inbox.
|
|
12931
|
+
description: The ID of the inbox.
|
|
11632
12932
|
title: InboxId
|
|
11633
12933
|
type_threads:ThreadId:
|
|
11634
12934
|
type: string
|
|
@@ -11889,7 +13189,7 @@ components:
|
|
|
11889
13189
|
schemas:
|
|
11890
13190
|
type_inboxes:InboxId:
|
|
11891
13191
|
type: string
|
|
11892
|
-
description: ID of inbox.
|
|
13192
|
+
description: The ID of the inbox.
|
|
11893
13193
|
title: InboxId
|
|
11894
13194
|
type_:Limit:
|
|
11895
13195
|
type: integer
|
|
@@ -12357,7 +13657,7 @@ components:
|
|
|
12357
13657
|
schemas:
|
|
12358
13658
|
type_inboxes:InboxId:
|
|
12359
13659
|
type: string
|
|
12360
|
-
description: ID of inbox.
|
|
13660
|
+
description: The ID of the inbox.
|
|
12361
13661
|
title: InboxId
|
|
12362
13662
|
type_messages:MessageId:
|
|
12363
13663
|
type: string
|
|
@@ -12794,7 +14094,7 @@ components:
|
|
|
12794
14094
|
schemas:
|
|
12795
14095
|
type_inboxes:InboxId:
|
|
12796
14096
|
type: string
|
|
12797
|
-
description: ID of inbox.
|
|
14097
|
+
description: The ID of the inbox.
|
|
12798
14098
|
title: InboxId
|
|
12799
14099
|
type_messages:MessageId:
|
|
12800
14100
|
type: string
|
|
@@ -13072,7 +14372,7 @@ components:
|
|
|
13072
14372
|
schemas:
|
|
13073
14373
|
type_inboxes:InboxId:
|
|
13074
14374
|
type: string
|
|
13075
|
-
description: ID of inbox.
|
|
14375
|
+
description: The ID of the inbox.
|
|
13076
14376
|
title: InboxId
|
|
13077
14377
|
type_messages:MessageId:
|
|
13078
14378
|
type: string
|
|
@@ -13306,7 +14606,7 @@ components:
|
|
|
13306
14606
|
schemas:
|
|
13307
14607
|
type_inboxes:InboxId:
|
|
13308
14608
|
type: string
|
|
13309
|
-
description: ID of inbox.
|
|
14609
|
+
description: The ID of the inbox.
|
|
13310
14610
|
title: InboxId
|
|
13311
14611
|
type_messages:MessageLabels:
|
|
13312
14612
|
type: array
|
|
@@ -13703,7 +15003,7 @@ components:
|
|
|
13703
15003
|
schemas:
|
|
13704
15004
|
type_inboxes:InboxId:
|
|
13705
15005
|
type: string
|
|
13706
|
-
description: ID of inbox.
|
|
15006
|
+
description: The ID of the inbox.
|
|
13707
15007
|
title: InboxId
|
|
13708
15008
|
type_messages:MessageId:
|
|
13709
15009
|
type: string
|
|
@@ -14101,7 +15401,7 @@ components:
|
|
|
14101
15401
|
schemas:
|
|
14102
15402
|
type_inboxes:InboxId:
|
|
14103
15403
|
type: string
|
|
14104
|
-
description: ID of inbox.
|
|
15404
|
+
description: The ID of the inbox.
|
|
14105
15405
|
title: InboxId
|
|
14106
15406
|
type_messages:MessageId:
|
|
14107
15407
|
type: string
|
|
@@ -14475,7 +15775,7 @@ components:
|
|
|
14475
15775
|
schemas:
|
|
14476
15776
|
type_inboxes:InboxId:
|
|
14477
15777
|
type: string
|
|
14478
|
-
description: ID of inbox.
|
|
15778
|
+
description: The ID of the inbox.
|
|
14479
15779
|
title: InboxId
|
|
14480
15780
|
type_messages:MessageId:
|
|
14481
15781
|
type: string
|
|
@@ -14867,7 +16167,7 @@ components:
|
|
|
14867
16167
|
schemas:
|
|
14868
16168
|
type_inboxes:InboxId:
|
|
14869
16169
|
type: string
|
|
14870
|
-
description: ID of inbox.
|
|
16170
|
+
description: The ID of the inbox.
|
|
14871
16171
|
title: InboxId
|
|
14872
16172
|
type_messages:MessageId:
|
|
14873
16173
|
type: string
|
|
@@ -15368,7 +16668,7 @@ components:
|
|
|
15368
16668
|
schemas:
|
|
15369
16669
|
type_inboxes:InboxId:
|
|
15370
16670
|
type: string
|
|
15371
|
-
description: ID of inbox.
|
|
16671
|
+
description: The ID of the inbox.
|
|
15372
16672
|
title: InboxId
|
|
15373
16673
|
type_:Limit:
|
|
15374
16674
|
type: integer
|
|
@@ -15786,7 +17086,7 @@ components:
|
|
|
15786
17086
|
schemas:
|
|
15787
17087
|
type_inboxes:InboxId:
|
|
15788
17088
|
type: string
|
|
15789
|
-
description: ID of inbox.
|
|
17089
|
+
description: The ID of the inbox.
|
|
15790
17090
|
title: InboxId
|
|
15791
17091
|
type_drafts:DraftId:
|
|
15792
17092
|
type: string
|
|
@@ -16204,7 +17504,7 @@ components:
|
|
|
16204
17504
|
schemas:
|
|
16205
17505
|
type_inboxes:InboxId:
|
|
16206
17506
|
type: string
|
|
16207
|
-
description: ID of inbox.
|
|
17507
|
+
description: The ID of the inbox.
|
|
16208
17508
|
title: InboxId
|
|
16209
17509
|
type_drafts:DraftId:
|
|
16210
17510
|
type: string
|
|
@@ -16482,7 +17782,7 @@ components:
|
|
|
16482
17782
|
schemas:
|
|
16483
17783
|
type_inboxes:InboxId:
|
|
16484
17784
|
type: string
|
|
16485
|
-
description: ID of inbox.
|
|
17785
|
+
description: The ID of the inbox.
|
|
16486
17786
|
title: InboxId
|
|
16487
17787
|
type_drafts:DraftLabels:
|
|
16488
17788
|
type: array
|
|
@@ -16968,7 +18268,7 @@ components:
|
|
|
16968
18268
|
schemas:
|
|
16969
18269
|
type_inboxes:InboxId:
|
|
16970
18270
|
type: string
|
|
16971
|
-
description: ID of inbox.
|
|
18271
|
+
description: The ID of the inbox.
|
|
16972
18272
|
title: InboxId
|
|
16973
18273
|
type_drafts:DraftId:
|
|
16974
18274
|
type: string
|
|
@@ -17438,7 +18738,7 @@ components:
|
|
|
17438
18738
|
schemas:
|
|
17439
18739
|
type_inboxes:InboxId:
|
|
17440
18740
|
type: string
|
|
17441
|
-
description: ID of inbox.
|
|
18741
|
+
description: The ID of the inbox.
|
|
17442
18742
|
title: InboxId
|
|
17443
18743
|
type_drafts:DraftId:
|
|
17444
18744
|
type: string
|
|
@@ -17718,7 +19018,7 @@ components:
|
|
|
17718
19018
|
schemas:
|
|
17719
19019
|
type_inboxes:InboxId:
|
|
17720
19020
|
type: string
|
|
17721
|
-
description: ID of inbox.
|
|
19021
|
+
description: The ID of the inbox.
|
|
17722
19022
|
title: InboxId
|
|
17723
19023
|
type_drafts:DraftId:
|
|
17724
19024
|
type: string
|
|
@@ -17955,7 +19255,7 @@ components:
|
|
|
17955
19255
|
schemas:
|
|
17956
19256
|
type_inboxes:InboxId:
|
|
17957
19257
|
type: string
|
|
17958
|
-
description: ID of inbox.
|
|
19258
|
+
description: The ID of the inbox.
|
|
17959
19259
|
title: InboxId
|
|
17960
19260
|
type_metrics:MetricEventType:
|
|
17961
19261
|
type: string
|
|
@@ -18337,7 +19637,7 @@ components:
|
|
|
18337
19637
|
title: Count
|
|
18338
19638
|
type_inboxes:InboxId:
|
|
18339
19639
|
type: string
|
|
18340
|
-
description: ID of inbox.
|
|
19640
|
+
description: The ID of the inbox.
|
|
18341
19641
|
title: InboxId
|
|
18342
19642
|
type_threads:ThreadId:
|
|
18343
19643
|
type: string
|
|
@@ -18739,7 +20039,7 @@ components:
|
|
|
18739
20039
|
title: ThreadId
|
|
18740
20040
|
type_inboxes:InboxId:
|
|
18741
20041
|
type: string
|
|
18742
|
-
description: ID of inbox.
|
|
20042
|
+
description: The ID of the inbox.
|
|
18743
20043
|
title: InboxId
|
|
18744
20044
|
type_threads:ThreadLabels:
|
|
18745
20045
|
type: array
|
|
@@ -19617,7 +20917,7 @@ components:
|
|
|
19617
20917
|
title: Count
|
|
19618
20918
|
type_inboxes:InboxId:
|
|
19619
20919
|
type: string
|
|
19620
|
-
description: ID of inbox.
|
|
20920
|
+
description: The ID of the inbox.
|
|
19621
20921
|
title: InboxId
|
|
19622
20922
|
type_threads:ThreadId:
|
|
19623
20923
|
type: string
|
|
@@ -20000,7 +21300,7 @@ components:
|
|
|
20000
21300
|
title: DraftId
|
|
20001
21301
|
type_inboxes:InboxId:
|
|
20002
21302
|
type: string
|
|
20003
|
-
description: ID of inbox.
|
|
21303
|
+
description: The ID of the inbox.
|
|
20004
21304
|
title: InboxId
|
|
20005
21305
|
type_threads:ThreadId:
|
|
20006
21306
|
type: string
|
|
@@ -20652,6 +21952,11 @@ paths:
|
|
|
20652
21952
|
required: false
|
|
20653
21953
|
schema:
|
|
20654
21954
|
$ref: '#/components/schemas/type_:PageToken'
|
|
21955
|
+
- name: ascending
|
|
21956
|
+
in: query
|
|
21957
|
+
required: false
|
|
21958
|
+
schema:
|
|
21959
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
20655
21960
|
- name: Authorization
|
|
20656
21961
|
in: header
|
|
20657
21962
|
description: Bearer authentication
|
|
@@ -20680,6 +21985,10 @@ components:
|
|
|
20680
21985
|
type: string
|
|
20681
21986
|
description: Page token for pagination.
|
|
20682
21987
|
title: PageToken
|
|
21988
|
+
type_:Ascending:
|
|
21989
|
+
type: boolean
|
|
21990
|
+
description: Sort in ascending temporal order.
|
|
21991
|
+
title: Ascending
|
|
20683
21992
|
type_:Count:
|
|
20684
21993
|
type: integer
|
|
20685
21994
|
description: Number of items returned.
|
|
@@ -23278,6 +24587,11 @@ paths:
|
|
|
23278
24587
|
required: false
|
|
23279
24588
|
schema:
|
|
23280
24589
|
$ref: '#/components/schemas/type_:PageToken'
|
|
24590
|
+
- name: ascending
|
|
24591
|
+
in: query
|
|
24592
|
+
required: false
|
|
24593
|
+
schema:
|
|
24594
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
23281
24595
|
- name: Authorization
|
|
23282
24596
|
in: header
|
|
23283
24597
|
description: Bearer authentication
|
|
@@ -23306,6 +24620,10 @@ components:
|
|
|
23306
24620
|
type: string
|
|
23307
24621
|
description: Page token for pagination.
|
|
23308
24622
|
title: PageToken
|
|
24623
|
+
type_:Ascending:
|
|
24624
|
+
type: boolean
|
|
24625
|
+
description: Sort in ascending temporal order.
|
|
24626
|
+
title: Ascending
|
|
23309
24627
|
type_:Count:
|
|
23310
24628
|
type: integer
|
|
23311
24629
|
description: Number of items returned.
|
|
@@ -24776,7 +26094,7 @@ components:
|
|
|
24776
26094
|
title: EventId
|
|
24777
26095
|
type_inboxes:InboxId:
|
|
24778
26096
|
type: string
|
|
24779
|
-
description: ID of inbox.
|
|
26097
|
+
description: The ID of the inbox.
|
|
24780
26098
|
title: InboxId
|
|
24781
26099
|
type_threads:ThreadId:
|
|
24782
26100
|
type: string
|
|
@@ -25205,7 +26523,7 @@ components:
|
|
|
25205
26523
|
title: EventId
|
|
25206
26524
|
type_inboxes:InboxId:
|
|
25207
26525
|
type: string
|
|
25208
|
-
description: ID of inbox.
|
|
26526
|
+
description: The ID of the inbox.
|
|
25209
26527
|
title: InboxId
|
|
25210
26528
|
type_threads:ThreadId:
|
|
25211
26529
|
type: string
|
|
@@ -25331,7 +26649,7 @@ components:
|
|
|
25331
26649
|
title: EventId
|
|
25332
26650
|
type_inboxes:InboxId:
|
|
25333
26651
|
type: string
|
|
25334
|
-
description: ID of inbox.
|
|
26652
|
+
description: The ID of the inbox.
|
|
25335
26653
|
title: InboxId
|
|
25336
26654
|
type_threads:ThreadId:
|
|
25337
26655
|
type: string
|
|
@@ -25457,7 +26775,7 @@ components:
|
|
|
25457
26775
|
title: EventId
|
|
25458
26776
|
type_inboxes:InboxId:
|
|
25459
26777
|
type: string
|
|
25460
|
-
description: ID of inbox.
|
|
26778
|
+
description: The ID of the inbox.
|
|
25461
26779
|
title: InboxId
|
|
25462
26780
|
type_threads:ThreadId:
|
|
25463
26781
|
type: string
|
|
@@ -25604,7 +26922,7 @@ components:
|
|
|
25604
26922
|
title: EventId
|
|
25605
26923
|
type_inboxes:InboxId:
|
|
25606
26924
|
type: string
|
|
25607
|
-
description: ID of inbox.
|
|
26925
|
+
description: The ID of the inbox.
|
|
25608
26926
|
title: InboxId
|
|
25609
26927
|
type_threads:ThreadId:
|
|
25610
26928
|
type: string
|
|
@@ -25738,7 +27056,7 @@ components:
|
|
|
25738
27056
|
title: EventId
|
|
25739
27057
|
type_inboxes:InboxId:
|
|
25740
27058
|
type: string
|
|
25741
|
-
description: ID of inbox.
|
|
27059
|
+
description: The ID of the inbox.
|
|
25742
27060
|
title: InboxId
|
|
25743
27061
|
type_threads:ThreadId:
|
|
25744
27062
|
type: string
|
|
@@ -26139,7 +27457,7 @@ components:
|
|
|
26139
27457
|
title: EventId
|
|
26140
27458
|
type_inboxes:InboxId:
|
|
26141
27459
|
type: string
|
|
26142
|
-
description: ID of inbox.
|
|
27460
|
+
description: The ID of the inbox.
|
|
26143
27461
|
title: InboxId
|
|
26144
27462
|
type_threads:ThreadId:
|
|
26145
27463
|
type: string
|
|
@@ -27248,6 +28566,11 @@ paths:
|
|
|
27248
28566
|
required: false
|
|
27249
28567
|
schema:
|
|
27250
28568
|
$ref: '#/components/schemas/type_:PageToken'
|
|
28569
|
+
- name: ascending
|
|
28570
|
+
in: query
|
|
28571
|
+
required: false
|
|
28572
|
+
schema:
|
|
28573
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
27251
28574
|
- name: Authorization
|
|
27252
28575
|
in: header
|
|
27253
28576
|
description: Bearer authentication
|
|
@@ -27276,6 +28599,10 @@ components:
|
|
|
27276
28599
|
type: string
|
|
27277
28600
|
description: Page token for pagination.
|
|
27278
28601
|
title: PageToken
|
|
28602
|
+
type_:Ascending:
|
|
28603
|
+
type: boolean
|
|
28604
|
+
description: Sort in ascending temporal order.
|
|
28605
|
+
title: Ascending
|
|
27279
28606
|
type_:Count:
|
|
27280
28607
|
type: integer
|
|
27281
28608
|
description: Number of items returned.
|
|
@@ -27306,6 +28633,11 @@ components:
|
|
|
27306
28633
|
$ref: '#/components/schemas/type_api-keys:Prefix'
|
|
27307
28634
|
name:
|
|
27308
28635
|
$ref: '#/components/schemas/type_api-keys:Name'
|
|
28636
|
+
pod_id:
|
|
28637
|
+
type: string
|
|
28638
|
+
description: >-
|
|
28639
|
+
Pod ID the api key is scoped to. If set, the key can only access
|
|
28640
|
+
resources within this pod.
|
|
27309
28641
|
used_at:
|
|
27310
28642
|
type: string
|
|
27311
28643
|
format: date-time
|
|
@@ -27558,6 +28890,9 @@ components:
|
|
|
27558
28890
|
$ref: '#/components/schemas/type_api-keys:Prefix'
|
|
27559
28891
|
name:
|
|
27560
28892
|
$ref: '#/components/schemas/type_api-keys:Name'
|
|
28893
|
+
pod_id:
|
|
28894
|
+
type: string
|
|
28895
|
+
description: Pod ID the api key is scoped to.
|
|
27561
28896
|
created_at:
|
|
27562
28897
|
$ref: '#/components/schemas/type_api-keys:CreatedAt'
|
|
27563
28898
|
required:
|
|
@@ -27979,6 +29314,11 @@ paths:
|
|
|
27979
29314
|
required: false
|
|
27980
29315
|
schema:
|
|
27981
29316
|
$ref: '#/components/schemas/type_:PageToken'
|
|
29317
|
+
- name: ascending
|
|
29318
|
+
in: query
|
|
29319
|
+
required: false
|
|
29320
|
+
schema:
|
|
29321
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
27982
29322
|
- name: Authorization
|
|
27983
29323
|
in: header
|
|
27984
29324
|
description: Bearer authentication
|
|
@@ -28007,6 +29347,10 @@ components:
|
|
|
28007
29347
|
type: string
|
|
28008
29348
|
description: Page token for pagination.
|
|
28009
29349
|
title: PageToken
|
|
29350
|
+
type_:Ascending:
|
|
29351
|
+
type: boolean
|
|
29352
|
+
description: Sort in ascending temporal order.
|
|
29353
|
+
title: Ascending
|
|
28010
29354
|
type_:Count:
|
|
28011
29355
|
type: integer
|
|
28012
29356
|
description: Number of items returned.
|
|
@@ -28947,6 +30291,11 @@ paths:
|
|
|
28947
30291
|
required: false
|
|
28948
30292
|
schema:
|
|
28949
30293
|
$ref: '#/components/schemas/type_:PageToken'
|
|
30294
|
+
- name: ascending
|
|
30295
|
+
in: query
|
|
30296
|
+
required: false
|
|
30297
|
+
schema:
|
|
30298
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
28950
30299
|
- name: Authorization
|
|
28951
30300
|
in: header
|
|
28952
30301
|
description: Bearer authentication
|
|
@@ -28985,13 +30334,17 @@ components:
|
|
|
28985
30334
|
type: string
|
|
28986
30335
|
description: Page token for pagination.
|
|
28987
30336
|
title: PageToken
|
|
30337
|
+
type_:Ascending:
|
|
30338
|
+
type: boolean
|
|
30339
|
+
description: Sort in ascending temporal order.
|
|
30340
|
+
title: Ascending
|
|
28988
30341
|
type_:Count:
|
|
28989
30342
|
type: integer
|
|
28990
30343
|
description: Number of items returned.
|
|
28991
30344
|
title: Count
|
|
28992
30345
|
type_inboxes:InboxId:
|
|
28993
30346
|
type: string
|
|
28994
|
-
description: ID of inbox.
|
|
30347
|
+
description: The ID of the inbox.
|
|
28995
30348
|
title: InboxId
|
|
28996
30349
|
type_inboxes:DisplayName:
|
|
28997
30350
|
type: string
|
|
@@ -29262,7 +30615,7 @@ components:
|
|
|
29262
30615
|
title: PodId
|
|
29263
30616
|
type_inboxes:InboxId:
|
|
29264
30617
|
type: string
|
|
29265
|
-
description: ID of inbox.
|
|
30618
|
+
description: The ID of the inbox.
|
|
29266
30619
|
title: InboxId
|
|
29267
30620
|
type_inboxes:DisplayName:
|
|
29268
30621
|
type: string
|
|
@@ -29541,7 +30894,7 @@ components:
|
|
|
29541
30894
|
title: CreateInboxRequest
|
|
29542
30895
|
type_inboxes:InboxId:
|
|
29543
30896
|
type: string
|
|
29544
|
-
description: ID of inbox.
|
|
30897
|
+
description: The ID of the inbox.
|
|
29545
30898
|
title: InboxId
|
|
29546
30899
|
type_inboxes:Inbox:
|
|
29547
30900
|
type: object
|
|
@@ -29797,7 +31150,7 @@ components:
|
|
|
29797
31150
|
title: PodId
|
|
29798
31151
|
type_inboxes:InboxId:
|
|
29799
31152
|
type: string
|
|
29800
|
-
description: ID of inbox.
|
|
31153
|
+
description: The ID of the inbox.
|
|
29801
31154
|
title: InboxId
|
|
29802
31155
|
type_:ErrorName:
|
|
29803
31156
|
type: string
|
|
@@ -30102,7 +31455,7 @@ components:
|
|
|
30102
31455
|
title: Count
|
|
30103
31456
|
type_inboxes:InboxId:
|
|
30104
31457
|
type: string
|
|
30105
|
-
description: ID of inbox.
|
|
31458
|
+
description: The ID of the inbox.
|
|
30106
31459
|
title: InboxId
|
|
30107
31460
|
type_threads:ThreadId:
|
|
30108
31461
|
type: string
|
|
@@ -30515,7 +31868,7 @@ components:
|
|
|
30515
31868
|
title: ThreadId
|
|
30516
31869
|
type_inboxes:InboxId:
|
|
30517
31870
|
type: string
|
|
30518
|
-
description: ID of inbox.
|
|
31871
|
+
description: The ID of the inbox.
|
|
30519
31872
|
title: InboxId
|
|
30520
31873
|
type_threads:ThreadLabels:
|
|
30521
31874
|
type: array
|
|
@@ -31413,7 +32766,7 @@ components:
|
|
|
31413
32766
|
title: Count
|
|
31414
32767
|
type_inboxes:InboxId:
|
|
31415
32768
|
type: string
|
|
31416
|
-
description: ID of inbox.
|
|
32769
|
+
description: The ID of the inbox.
|
|
31417
32770
|
title: InboxId
|
|
31418
32771
|
type_threads:ThreadId:
|
|
31419
32772
|
type: string
|
|
@@ -31807,7 +33160,7 @@ components:
|
|
|
31807
33160
|
title: DraftId
|
|
31808
33161
|
type_inboxes:InboxId:
|
|
31809
33162
|
type: string
|
|
31810
|
-
description: ID of inbox.
|
|
33163
|
+
description: The ID of the inbox.
|
|
31811
33164
|
title: InboxId
|
|
31812
33165
|
type_threads:ThreadId:
|
|
31813
33166
|
type: string
|
|
@@ -32475,6 +33828,11 @@ paths:
|
|
|
32475
33828
|
required: false
|
|
32476
33829
|
schema:
|
|
32477
33830
|
$ref: '#/components/schemas/type_:PageToken'
|
|
33831
|
+
- name: ascending
|
|
33832
|
+
in: query
|
|
33833
|
+
required: false
|
|
33834
|
+
schema:
|
|
33835
|
+
$ref: '#/components/schemas/type_:Ascending'
|
|
32478
33836
|
- name: Authorization
|
|
32479
33837
|
in: header
|
|
32480
33838
|
description: Bearer authentication
|
|
@@ -32513,6 +33871,10 @@ components:
|
|
|
32513
33871
|
type: string
|
|
32514
33872
|
description: Page token for pagination.
|
|
32515
33873
|
title: PageToken
|
|
33874
|
+
type_:Ascending:
|
|
33875
|
+
type: boolean
|
|
33876
|
+
description: Sort in ascending temporal order.
|
|
33877
|
+
title: Ascending
|
|
32516
33878
|
type_:Count:
|
|
32517
33879
|
type: integer
|
|
32518
33880
|
description: Number of items returned.
|
|
@@ -34761,6 +36123,822 @@ let dataTask = session.dataTask(with: request as URLRequest, completionHandler:
|
|
|
34761
36123
|
dataTask.resume()
|
|
34762
36124
|
```
|
|
34763
36125
|
|
|
36126
|
+
# Create API Key
|
|
36127
|
+
|
|
36128
|
+
POST https://api.agentmail.to/v0/pods/{pod_id}/api-keys
|
|
36129
|
+
Content-Type: application/json
|
|
36130
|
+
|
|
36131
|
+
Reference: https://docs.agentmail.to/api-reference/pods/api-keys/create
|
|
36132
|
+
|
|
36133
|
+
## OpenAPI Specification
|
|
36134
|
+
|
|
36135
|
+
```yaml
|
|
36136
|
+
openapi: 3.1.0
|
|
36137
|
+
info:
|
|
36138
|
+
title: api
|
|
36139
|
+
version: 1.0.0
|
|
36140
|
+
paths:
|
|
36141
|
+
/v0/pods/{pod_id}/api-keys:
|
|
36142
|
+
post:
|
|
36143
|
+
operationId: create
|
|
36144
|
+
summary: Create API Key
|
|
36145
|
+
tags:
|
|
36146
|
+
- subpackage_pods.subpackage_pods/api-keys
|
|
36147
|
+
parameters:
|
|
36148
|
+
- name: pod_id
|
|
36149
|
+
in: path
|
|
36150
|
+
required: true
|
|
36151
|
+
schema:
|
|
36152
|
+
$ref: '#/components/schemas/type_pods:PodId'
|
|
36153
|
+
- name: Authorization
|
|
36154
|
+
in: header
|
|
36155
|
+
description: Bearer authentication
|
|
36156
|
+
required: true
|
|
36157
|
+
schema:
|
|
36158
|
+
type: string
|
|
36159
|
+
responses:
|
|
36160
|
+
'200':
|
|
36161
|
+
description: Response with status 200
|
|
36162
|
+
content:
|
|
36163
|
+
application/json:
|
|
36164
|
+
schema:
|
|
36165
|
+
$ref: '#/components/schemas/type_api-keys:CreateApiKeyResponse'
|
|
36166
|
+
'400':
|
|
36167
|
+
description: Error response with status 400
|
|
36168
|
+
content:
|
|
36169
|
+
application/json:
|
|
36170
|
+
schema:
|
|
36171
|
+
$ref: '#/components/schemas/type_:ValidationErrorResponse'
|
|
36172
|
+
'404':
|
|
36173
|
+
description: Error response with status 404
|
|
36174
|
+
content:
|
|
36175
|
+
application/json:
|
|
36176
|
+
schema:
|
|
36177
|
+
$ref: '#/components/schemas/type_:ErrorResponse'
|
|
36178
|
+
requestBody:
|
|
36179
|
+
content:
|
|
36180
|
+
application/json:
|
|
36181
|
+
schema:
|
|
36182
|
+
$ref: '#/components/schemas/type_api-keys:CreateApiKeyRequest'
|
|
36183
|
+
servers:
|
|
36184
|
+
- url: https://api.agentmail.to
|
|
36185
|
+
- url: https://x402.api.agentmail.to
|
|
36186
|
+
- url: https://mpp.api.agentmail.to
|
|
36187
|
+
- url: https://api.agentmail.eu
|
|
36188
|
+
components:
|
|
36189
|
+
schemas:
|
|
36190
|
+
type_pods:PodId:
|
|
36191
|
+
type: string
|
|
36192
|
+
description: ID of pod.
|
|
36193
|
+
title: PodId
|
|
36194
|
+
type_api-keys:Name:
|
|
36195
|
+
type: string
|
|
36196
|
+
description: Name of api key.
|
|
36197
|
+
title: Name
|
|
36198
|
+
type_api-keys:CreateApiKeyRequest:
|
|
36199
|
+
type: object
|
|
36200
|
+
properties:
|
|
36201
|
+
name:
|
|
36202
|
+
$ref: '#/components/schemas/type_api-keys:Name'
|
|
36203
|
+
required:
|
|
36204
|
+
- name
|
|
36205
|
+
title: CreateApiKeyRequest
|
|
36206
|
+
type_api-keys:ApiKeyId:
|
|
36207
|
+
type: string
|
|
36208
|
+
description: ID of api key.
|
|
36209
|
+
title: ApiKeyId
|
|
36210
|
+
type_api-keys:Prefix:
|
|
36211
|
+
type: string
|
|
36212
|
+
description: Prefix of api key.
|
|
36213
|
+
title: Prefix
|
|
36214
|
+
type_api-keys:CreatedAt:
|
|
36215
|
+
type: string
|
|
36216
|
+
format: date-time
|
|
36217
|
+
description: Time at which api key was created.
|
|
36218
|
+
title: CreatedAt
|
|
36219
|
+
type_api-keys:CreateApiKeyResponse:
|
|
36220
|
+
type: object
|
|
36221
|
+
properties:
|
|
36222
|
+
api_key_id:
|
|
36223
|
+
$ref: '#/components/schemas/type_api-keys:ApiKeyId'
|
|
36224
|
+
api_key:
|
|
36225
|
+
type: string
|
|
36226
|
+
description: API key.
|
|
36227
|
+
prefix:
|
|
36228
|
+
$ref: '#/components/schemas/type_api-keys:Prefix'
|
|
36229
|
+
name:
|
|
36230
|
+
$ref: '#/components/schemas/type_api-keys:Name'
|
|
36231
|
+
pod_id:
|
|
36232
|
+
type: string
|
|
36233
|
+
description: Pod ID the api key is scoped to.
|
|
36234
|
+
created_at:
|
|
36235
|
+
$ref: '#/components/schemas/type_api-keys:CreatedAt'
|
|
36236
|
+
required:
|
|
36237
|
+
- api_key_id
|
|
36238
|
+
- api_key
|
|
36239
|
+
- prefix
|
|
36240
|
+
- name
|
|
36241
|
+
- created_at
|
|
36242
|
+
title: CreateApiKeyResponse
|
|
36243
|
+
type_:ErrorName:
|
|
36244
|
+
type: string
|
|
36245
|
+
description: Name of error.
|
|
36246
|
+
title: ErrorName
|
|
36247
|
+
type_:ErrorMessage:
|
|
36248
|
+
type: string
|
|
36249
|
+
description: Error message.
|
|
36250
|
+
title: ErrorMessage
|
|
36251
|
+
type_:ErrorResponse:
|
|
36252
|
+
type: object
|
|
36253
|
+
properties:
|
|
36254
|
+
name:
|
|
36255
|
+
$ref: '#/components/schemas/type_:ErrorName'
|
|
36256
|
+
message:
|
|
36257
|
+
$ref: '#/components/schemas/type_:ErrorMessage'
|
|
36258
|
+
required:
|
|
36259
|
+
- name
|
|
36260
|
+
- message
|
|
36261
|
+
title: ErrorResponse
|
|
36262
|
+
type_:ValidationErrorResponse:
|
|
36263
|
+
type: object
|
|
36264
|
+
properties:
|
|
36265
|
+
name:
|
|
36266
|
+
$ref: '#/components/schemas/type_:ErrorName'
|
|
36267
|
+
errors:
|
|
36268
|
+
description: Validation errors.
|
|
36269
|
+
required:
|
|
36270
|
+
- name
|
|
36271
|
+
- errors
|
|
36272
|
+
title: ValidationErrorResponse
|
|
36273
|
+
securitySchemes:
|
|
36274
|
+
Bearer:
|
|
36275
|
+
type: http
|
|
36276
|
+
scheme: bearer
|
|
36277
|
+
|
|
36278
|
+
```
|
|
36279
|
+
|
|
36280
|
+
## SDK Code Examples
|
|
36281
|
+
|
|
36282
|
+
```typescript
|
|
36283
|
+
import { AgentMailClient } from "agentmail";
|
|
36284
|
+
|
|
36285
|
+
async function main() {
|
|
36286
|
+
const client = new AgentMailClient({
|
|
36287
|
+
apiKey: "YOUR_TOKEN_HERE",
|
|
36288
|
+
});
|
|
36289
|
+
await client.pods.apiKeys.create("pod_id", {
|
|
36290
|
+
name: "name",
|
|
36291
|
+
});
|
|
36292
|
+
}
|
|
36293
|
+
main();
|
|
36294
|
+
|
|
36295
|
+
```
|
|
36296
|
+
|
|
36297
|
+
```python
|
|
36298
|
+
from agentmail import AgentMail
|
|
36299
|
+
|
|
36300
|
+
client = AgentMail(
|
|
36301
|
+
api_key="YOUR_TOKEN_HERE"
|
|
36302
|
+
)
|
|
36303
|
+
|
|
36304
|
+
client.pods.api_keys.create(
|
|
36305
|
+
pod_id="pod_id",
|
|
36306
|
+
name="name"
|
|
36307
|
+
)
|
|
36308
|
+
|
|
36309
|
+
```
|
|
36310
|
+
|
|
36311
|
+
```go
|
|
36312
|
+
package main
|
|
36313
|
+
|
|
36314
|
+
import (
|
|
36315
|
+
"fmt"
|
|
36316
|
+
"strings"
|
|
36317
|
+
"net/http"
|
|
36318
|
+
"io"
|
|
36319
|
+
)
|
|
36320
|
+
|
|
36321
|
+
func main() {
|
|
36322
|
+
|
|
36323
|
+
url := "https://api.agentmail.to/v0/pods/pod_id/api-keys"
|
|
36324
|
+
|
|
36325
|
+
payload := strings.NewReader("{\n \"name\": \"name\"\n}")
|
|
36326
|
+
|
|
36327
|
+
req, _ := http.NewRequest("POST", url, payload)
|
|
36328
|
+
|
|
36329
|
+
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
36330
|
+
req.Header.Add("Content-Type", "application/json")
|
|
36331
|
+
|
|
36332
|
+
res, _ := http.DefaultClient.Do(req)
|
|
36333
|
+
|
|
36334
|
+
defer res.Body.Close()
|
|
36335
|
+
body, _ := io.ReadAll(res.Body)
|
|
36336
|
+
|
|
36337
|
+
fmt.Println(res)
|
|
36338
|
+
fmt.Println(string(body))
|
|
36339
|
+
|
|
36340
|
+
}
|
|
36341
|
+
```
|
|
36342
|
+
|
|
36343
|
+
```ruby
|
|
36344
|
+
require 'uri'
|
|
36345
|
+
require 'net/http'
|
|
36346
|
+
|
|
36347
|
+
url = URI("https://api.agentmail.to/v0/pods/pod_id/api-keys")
|
|
36348
|
+
|
|
36349
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
36350
|
+
http.use_ssl = true
|
|
36351
|
+
|
|
36352
|
+
request = Net::HTTP::Post.new(url)
|
|
36353
|
+
request["Authorization"] = 'Bearer <api_key>'
|
|
36354
|
+
request["Content-Type"] = 'application/json'
|
|
36355
|
+
request.body = "{\n \"name\": \"name\"\n}"
|
|
36356
|
+
|
|
36357
|
+
response = http.request(request)
|
|
36358
|
+
puts response.read_body
|
|
36359
|
+
```
|
|
36360
|
+
|
|
36361
|
+
```java
|
|
36362
|
+
import com.mashape.unirest.http.HttpResponse;
|
|
36363
|
+
import com.mashape.unirest.http.Unirest;
|
|
36364
|
+
|
|
36365
|
+
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/pods/pod_id/api-keys")
|
|
36366
|
+
.header("Authorization", "Bearer <api_key>")
|
|
36367
|
+
.header("Content-Type", "application/json")
|
|
36368
|
+
.body("{\n \"name\": \"name\"\n}")
|
|
36369
|
+
.asString();
|
|
36370
|
+
```
|
|
36371
|
+
|
|
36372
|
+
```php
|
|
36373
|
+
<?php
|
|
36374
|
+
require_once('vendor/autoload.php');
|
|
36375
|
+
|
|
36376
|
+
$client = new \GuzzleHttp\Client();
|
|
36377
|
+
|
|
36378
|
+
$response = $client->request('POST', 'https://api.agentmail.to/v0/pods/pod_id/api-keys', [
|
|
36379
|
+
'body' => '{
|
|
36380
|
+
"name": "name"
|
|
36381
|
+
}',
|
|
36382
|
+
'headers' => [
|
|
36383
|
+
'Authorization' => 'Bearer <api_key>',
|
|
36384
|
+
'Content-Type' => 'application/json',
|
|
36385
|
+
],
|
|
36386
|
+
]);
|
|
36387
|
+
|
|
36388
|
+
echo $response->getBody();
|
|
36389
|
+
```
|
|
36390
|
+
|
|
36391
|
+
```csharp
|
|
36392
|
+
using RestSharp;
|
|
36393
|
+
|
|
36394
|
+
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/api-keys");
|
|
36395
|
+
var request = new RestRequest(Method.POST);
|
|
36396
|
+
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
36397
|
+
request.AddHeader("Content-Type", "application/json");
|
|
36398
|
+
request.AddParameter("application/json", "{\n \"name\": \"name\"\n}", ParameterType.RequestBody);
|
|
36399
|
+
IRestResponse response = client.Execute(request);
|
|
36400
|
+
```
|
|
36401
|
+
|
|
36402
|
+
```swift
|
|
36403
|
+
import Foundation
|
|
36404
|
+
|
|
36405
|
+
let headers = [
|
|
36406
|
+
"Authorization": "Bearer <api_key>",
|
|
36407
|
+
"Content-Type": "application/json"
|
|
36408
|
+
]
|
|
36409
|
+
let parameters = ["name": "name"] as [String : Any]
|
|
36410
|
+
|
|
36411
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
36412
|
+
|
|
36413
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/api-keys")! as URL,
|
|
36414
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
36415
|
+
timeoutInterval: 10.0)
|
|
36416
|
+
request.httpMethod = "POST"
|
|
36417
|
+
request.allHTTPHeaderFields = headers
|
|
36418
|
+
request.httpBody = postData as Data
|
|
36419
|
+
|
|
36420
|
+
let session = URLSession.shared
|
|
36421
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
36422
|
+
if (error != nil) {
|
|
36423
|
+
print(error as Any)
|
|
36424
|
+
} else {
|
|
36425
|
+
let httpResponse = response as? HTTPURLResponse
|
|
36426
|
+
print(httpResponse)
|
|
36427
|
+
}
|
|
36428
|
+
})
|
|
36429
|
+
|
|
36430
|
+
dataTask.resume()
|
|
36431
|
+
```
|
|
36432
|
+
|
|
36433
|
+
# List API Keys
|
|
36434
|
+
|
|
36435
|
+
GET https://api.agentmail.to/v0/pods/{pod_id}/api-keys
|
|
36436
|
+
|
|
36437
|
+
Reference: https://docs.agentmail.to/api-reference/pods/api-keys/list
|
|
36438
|
+
|
|
36439
|
+
## OpenAPI Specification
|
|
36440
|
+
|
|
36441
|
+
```yaml
|
|
36442
|
+
openapi: 3.1.0
|
|
36443
|
+
info:
|
|
36444
|
+
title: api
|
|
36445
|
+
version: 1.0.0
|
|
36446
|
+
paths:
|
|
36447
|
+
/v0/pods/{pod_id}/api-keys:
|
|
36448
|
+
get:
|
|
36449
|
+
operationId: list
|
|
36450
|
+
summary: List API Keys
|
|
36451
|
+
tags:
|
|
36452
|
+
- subpackage_pods.subpackage_pods/api-keys
|
|
36453
|
+
parameters:
|
|
36454
|
+
- name: pod_id
|
|
36455
|
+
in: path
|
|
36456
|
+
required: true
|
|
36457
|
+
schema:
|
|
36458
|
+
$ref: '#/components/schemas/type_pods:PodId'
|
|
36459
|
+
- name: limit
|
|
36460
|
+
in: query
|
|
36461
|
+
required: false
|
|
36462
|
+
schema:
|
|
36463
|
+
$ref: '#/components/schemas/type_:Limit'
|
|
36464
|
+
- name: page_token
|
|
36465
|
+
in: query
|
|
36466
|
+
required: false
|
|
36467
|
+
schema:
|
|
36468
|
+
$ref: '#/components/schemas/type_:PageToken'
|
|
36469
|
+
- name: Authorization
|
|
36470
|
+
in: header
|
|
36471
|
+
description: Bearer authentication
|
|
36472
|
+
required: true
|
|
36473
|
+
schema:
|
|
36474
|
+
type: string
|
|
36475
|
+
responses:
|
|
36476
|
+
'200':
|
|
36477
|
+
description: Response with status 200
|
|
36478
|
+
content:
|
|
36479
|
+
application/json:
|
|
36480
|
+
schema:
|
|
36481
|
+
$ref: '#/components/schemas/type_api-keys:ListApiKeysResponse'
|
|
36482
|
+
'404':
|
|
36483
|
+
description: Error response with status 404
|
|
36484
|
+
content:
|
|
36485
|
+
application/json:
|
|
36486
|
+
schema:
|
|
36487
|
+
$ref: '#/components/schemas/type_:ErrorResponse'
|
|
36488
|
+
servers:
|
|
36489
|
+
- url: https://api.agentmail.to
|
|
36490
|
+
- url: https://x402.api.agentmail.to
|
|
36491
|
+
- url: https://mpp.api.agentmail.to
|
|
36492
|
+
- url: https://api.agentmail.eu
|
|
36493
|
+
components:
|
|
36494
|
+
schemas:
|
|
36495
|
+
type_pods:PodId:
|
|
36496
|
+
type: string
|
|
36497
|
+
description: ID of pod.
|
|
36498
|
+
title: PodId
|
|
36499
|
+
type_:Limit:
|
|
36500
|
+
type: integer
|
|
36501
|
+
description: Limit of number of items returned.
|
|
36502
|
+
title: Limit
|
|
36503
|
+
type_:PageToken:
|
|
36504
|
+
type: string
|
|
36505
|
+
description: Page token for pagination.
|
|
36506
|
+
title: PageToken
|
|
36507
|
+
type_:Count:
|
|
36508
|
+
type: integer
|
|
36509
|
+
description: Number of items returned.
|
|
36510
|
+
title: Count
|
|
36511
|
+
type_api-keys:ApiKeyId:
|
|
36512
|
+
type: string
|
|
36513
|
+
description: ID of api key.
|
|
36514
|
+
title: ApiKeyId
|
|
36515
|
+
type_api-keys:Prefix:
|
|
36516
|
+
type: string
|
|
36517
|
+
description: Prefix of api key.
|
|
36518
|
+
title: Prefix
|
|
36519
|
+
type_api-keys:Name:
|
|
36520
|
+
type: string
|
|
36521
|
+
description: Name of api key.
|
|
36522
|
+
title: Name
|
|
36523
|
+
type_api-keys:CreatedAt:
|
|
36524
|
+
type: string
|
|
36525
|
+
format: date-time
|
|
36526
|
+
description: Time at which api key was created.
|
|
36527
|
+
title: CreatedAt
|
|
36528
|
+
type_api-keys:ApiKey:
|
|
36529
|
+
type: object
|
|
36530
|
+
properties:
|
|
36531
|
+
api_key_id:
|
|
36532
|
+
$ref: '#/components/schemas/type_api-keys:ApiKeyId'
|
|
36533
|
+
prefix:
|
|
36534
|
+
$ref: '#/components/schemas/type_api-keys:Prefix'
|
|
36535
|
+
name:
|
|
36536
|
+
$ref: '#/components/schemas/type_api-keys:Name'
|
|
36537
|
+
pod_id:
|
|
36538
|
+
type: string
|
|
36539
|
+
description: >-
|
|
36540
|
+
Pod ID the api key is scoped to. If set, the key can only access
|
|
36541
|
+
resources within this pod.
|
|
36542
|
+
used_at:
|
|
36543
|
+
type: string
|
|
36544
|
+
format: date-time
|
|
36545
|
+
description: Time at which api key was last used.
|
|
36546
|
+
created_at:
|
|
36547
|
+
$ref: '#/components/schemas/type_api-keys:CreatedAt'
|
|
36548
|
+
required:
|
|
36549
|
+
- api_key_id
|
|
36550
|
+
- prefix
|
|
36551
|
+
- name
|
|
36552
|
+
- created_at
|
|
36553
|
+
title: ApiKey
|
|
36554
|
+
type_api-keys:ListApiKeysResponse:
|
|
36555
|
+
type: object
|
|
36556
|
+
properties:
|
|
36557
|
+
count:
|
|
36558
|
+
$ref: '#/components/schemas/type_:Count'
|
|
36559
|
+
next_page_token:
|
|
36560
|
+
$ref: '#/components/schemas/type_:PageToken'
|
|
36561
|
+
api_keys:
|
|
36562
|
+
type: array
|
|
36563
|
+
items:
|
|
36564
|
+
$ref: '#/components/schemas/type_api-keys:ApiKey'
|
|
36565
|
+
description: Ordered by `created_at` descending.
|
|
36566
|
+
required:
|
|
36567
|
+
- count
|
|
36568
|
+
- api_keys
|
|
36569
|
+
title: ListApiKeysResponse
|
|
36570
|
+
type_:ErrorName:
|
|
36571
|
+
type: string
|
|
36572
|
+
description: Name of error.
|
|
36573
|
+
title: ErrorName
|
|
36574
|
+
type_:ErrorMessage:
|
|
36575
|
+
type: string
|
|
36576
|
+
description: Error message.
|
|
36577
|
+
title: ErrorMessage
|
|
36578
|
+
type_:ErrorResponse:
|
|
36579
|
+
type: object
|
|
36580
|
+
properties:
|
|
36581
|
+
name:
|
|
36582
|
+
$ref: '#/components/schemas/type_:ErrorName'
|
|
36583
|
+
message:
|
|
36584
|
+
$ref: '#/components/schemas/type_:ErrorMessage'
|
|
36585
|
+
required:
|
|
36586
|
+
- name
|
|
36587
|
+
- message
|
|
36588
|
+
title: ErrorResponse
|
|
36589
|
+
securitySchemes:
|
|
36590
|
+
Bearer:
|
|
36591
|
+
type: http
|
|
36592
|
+
scheme: bearer
|
|
36593
|
+
|
|
36594
|
+
```
|
|
36595
|
+
|
|
36596
|
+
## SDK Code Examples
|
|
36597
|
+
|
|
36598
|
+
```typescript
|
|
36599
|
+
import { AgentMailClient } from "agentmail";
|
|
36600
|
+
|
|
36601
|
+
async function main() {
|
|
36602
|
+
const client = new AgentMailClient({
|
|
36603
|
+
apiKey: "YOUR_TOKEN_HERE",
|
|
36604
|
+
});
|
|
36605
|
+
await client.pods.apiKeys.list("pod_id", {});
|
|
36606
|
+
}
|
|
36607
|
+
main();
|
|
36608
|
+
|
|
36609
|
+
```
|
|
36610
|
+
|
|
36611
|
+
```python
|
|
36612
|
+
from agentmail import AgentMail
|
|
36613
|
+
|
|
36614
|
+
client = AgentMail(
|
|
36615
|
+
api_key="YOUR_TOKEN_HERE"
|
|
36616
|
+
)
|
|
36617
|
+
|
|
36618
|
+
client.pods.api_keys.list(
|
|
36619
|
+
pod_id="pod_id"
|
|
36620
|
+
)
|
|
36621
|
+
|
|
36622
|
+
```
|
|
36623
|
+
|
|
36624
|
+
```go
|
|
36625
|
+
package main
|
|
36626
|
+
|
|
36627
|
+
import (
|
|
36628
|
+
"fmt"
|
|
36629
|
+
"net/http"
|
|
36630
|
+
"io"
|
|
36631
|
+
)
|
|
36632
|
+
|
|
36633
|
+
func main() {
|
|
36634
|
+
|
|
36635
|
+
url := "https://api.agentmail.to/v0/pods/pod_id/api-keys"
|
|
36636
|
+
|
|
36637
|
+
req, _ := http.NewRequest("GET", url, nil)
|
|
36638
|
+
|
|
36639
|
+
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
36640
|
+
|
|
36641
|
+
res, _ := http.DefaultClient.Do(req)
|
|
36642
|
+
|
|
36643
|
+
defer res.Body.Close()
|
|
36644
|
+
body, _ := io.ReadAll(res.Body)
|
|
36645
|
+
|
|
36646
|
+
fmt.Println(res)
|
|
36647
|
+
fmt.Println(string(body))
|
|
36648
|
+
|
|
36649
|
+
}
|
|
36650
|
+
```
|
|
36651
|
+
|
|
36652
|
+
```ruby
|
|
36653
|
+
require 'uri'
|
|
36654
|
+
require 'net/http'
|
|
36655
|
+
|
|
36656
|
+
url = URI("https://api.agentmail.to/v0/pods/pod_id/api-keys")
|
|
36657
|
+
|
|
36658
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
36659
|
+
http.use_ssl = true
|
|
36660
|
+
|
|
36661
|
+
request = Net::HTTP::Get.new(url)
|
|
36662
|
+
request["Authorization"] = 'Bearer <api_key>'
|
|
36663
|
+
|
|
36664
|
+
response = http.request(request)
|
|
36665
|
+
puts response.read_body
|
|
36666
|
+
```
|
|
36667
|
+
|
|
36668
|
+
```java
|
|
36669
|
+
import com.mashape.unirest.http.HttpResponse;
|
|
36670
|
+
import com.mashape.unirest.http.Unirest;
|
|
36671
|
+
|
|
36672
|
+
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/api-keys")
|
|
36673
|
+
.header("Authorization", "Bearer <api_key>")
|
|
36674
|
+
.asString();
|
|
36675
|
+
```
|
|
36676
|
+
|
|
36677
|
+
```php
|
|
36678
|
+
<?php
|
|
36679
|
+
require_once('vendor/autoload.php');
|
|
36680
|
+
|
|
36681
|
+
$client = new \GuzzleHttp\Client();
|
|
36682
|
+
|
|
36683
|
+
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/api-keys', [
|
|
36684
|
+
'headers' => [
|
|
36685
|
+
'Authorization' => 'Bearer <api_key>',
|
|
36686
|
+
],
|
|
36687
|
+
]);
|
|
36688
|
+
|
|
36689
|
+
echo $response->getBody();
|
|
36690
|
+
```
|
|
36691
|
+
|
|
36692
|
+
```csharp
|
|
36693
|
+
using RestSharp;
|
|
36694
|
+
|
|
36695
|
+
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/api-keys");
|
|
36696
|
+
var request = new RestRequest(Method.GET);
|
|
36697
|
+
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
36698
|
+
IRestResponse response = client.Execute(request);
|
|
36699
|
+
```
|
|
36700
|
+
|
|
36701
|
+
```swift
|
|
36702
|
+
import Foundation
|
|
36703
|
+
|
|
36704
|
+
let headers = ["Authorization": "Bearer <api_key>"]
|
|
36705
|
+
|
|
36706
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/api-keys")! as URL,
|
|
36707
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
36708
|
+
timeoutInterval: 10.0)
|
|
36709
|
+
request.httpMethod = "GET"
|
|
36710
|
+
request.allHTTPHeaderFields = headers
|
|
36711
|
+
|
|
36712
|
+
let session = URLSession.shared
|
|
36713
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
36714
|
+
if (error != nil) {
|
|
36715
|
+
print(error as Any)
|
|
36716
|
+
} else {
|
|
36717
|
+
let httpResponse = response as? HTTPURLResponse
|
|
36718
|
+
print(httpResponse)
|
|
36719
|
+
}
|
|
36720
|
+
})
|
|
36721
|
+
|
|
36722
|
+
dataTask.resume()
|
|
36723
|
+
```
|
|
36724
|
+
|
|
36725
|
+
# Delete API Key
|
|
36726
|
+
|
|
36727
|
+
DELETE https://api.agentmail.to/v0/pods/{pod_id}/api-keys/{api_key}
|
|
36728
|
+
|
|
36729
|
+
Reference: https://docs.agentmail.to/api-reference/pods/api-keys/delete
|
|
36730
|
+
|
|
36731
|
+
## OpenAPI Specification
|
|
36732
|
+
|
|
36733
|
+
```yaml
|
|
36734
|
+
openapi: 3.1.0
|
|
36735
|
+
info:
|
|
36736
|
+
title: api
|
|
36737
|
+
version: 1.0.0
|
|
36738
|
+
paths:
|
|
36739
|
+
/v0/pods/{pod_id}/api-keys/{api_key}:
|
|
36740
|
+
delete:
|
|
36741
|
+
operationId: delete
|
|
36742
|
+
summary: Delete API Key
|
|
36743
|
+
tags:
|
|
36744
|
+
- subpackage_pods.subpackage_pods/api-keys
|
|
36745
|
+
parameters:
|
|
36746
|
+
- name: pod_id
|
|
36747
|
+
in: path
|
|
36748
|
+
required: true
|
|
36749
|
+
schema:
|
|
36750
|
+
$ref: '#/components/schemas/type_pods:PodId'
|
|
36751
|
+
- name: api_key
|
|
36752
|
+
in: path
|
|
36753
|
+
required: true
|
|
36754
|
+
schema:
|
|
36755
|
+
$ref: '#/components/schemas/type_api-keys:ApiKeyId'
|
|
36756
|
+
- name: Authorization
|
|
36757
|
+
in: header
|
|
36758
|
+
description: Bearer authentication
|
|
36759
|
+
required: true
|
|
36760
|
+
schema:
|
|
36761
|
+
type: string
|
|
36762
|
+
responses:
|
|
36763
|
+
'200':
|
|
36764
|
+
description: Successful response
|
|
36765
|
+
'404':
|
|
36766
|
+
description: Error response with status 404
|
|
36767
|
+
content:
|
|
36768
|
+
application/json:
|
|
36769
|
+
schema:
|
|
36770
|
+
$ref: '#/components/schemas/type_:ErrorResponse'
|
|
36771
|
+
servers:
|
|
36772
|
+
- url: https://api.agentmail.to
|
|
36773
|
+
- url: https://x402.api.agentmail.to
|
|
36774
|
+
- url: https://mpp.api.agentmail.to
|
|
36775
|
+
- url: https://api.agentmail.eu
|
|
36776
|
+
components:
|
|
36777
|
+
schemas:
|
|
36778
|
+
type_pods:PodId:
|
|
36779
|
+
type: string
|
|
36780
|
+
description: ID of pod.
|
|
36781
|
+
title: PodId
|
|
36782
|
+
type_api-keys:ApiKeyId:
|
|
36783
|
+
type: string
|
|
36784
|
+
description: ID of api key.
|
|
36785
|
+
title: ApiKeyId
|
|
36786
|
+
type_:ErrorName:
|
|
36787
|
+
type: string
|
|
36788
|
+
description: Name of error.
|
|
36789
|
+
title: ErrorName
|
|
36790
|
+
type_:ErrorMessage:
|
|
36791
|
+
type: string
|
|
36792
|
+
description: Error message.
|
|
36793
|
+
title: ErrorMessage
|
|
36794
|
+
type_:ErrorResponse:
|
|
36795
|
+
type: object
|
|
36796
|
+
properties:
|
|
36797
|
+
name:
|
|
36798
|
+
$ref: '#/components/schemas/type_:ErrorName'
|
|
36799
|
+
message:
|
|
36800
|
+
$ref: '#/components/schemas/type_:ErrorMessage'
|
|
36801
|
+
required:
|
|
36802
|
+
- name
|
|
36803
|
+
- message
|
|
36804
|
+
title: ErrorResponse
|
|
36805
|
+
securitySchemes:
|
|
36806
|
+
Bearer:
|
|
36807
|
+
type: http
|
|
36808
|
+
scheme: bearer
|
|
36809
|
+
|
|
36810
|
+
```
|
|
36811
|
+
|
|
36812
|
+
## SDK Code Examples
|
|
36813
|
+
|
|
36814
|
+
```typescript
|
|
36815
|
+
import { AgentMailClient } from "agentmail";
|
|
36816
|
+
|
|
36817
|
+
async function main() {
|
|
36818
|
+
const client = new AgentMailClient({
|
|
36819
|
+
apiKey: "YOUR_TOKEN_HERE",
|
|
36820
|
+
});
|
|
36821
|
+
await client.pods.apiKeys.delete("pod_id", "api_key");
|
|
36822
|
+
}
|
|
36823
|
+
main();
|
|
36824
|
+
|
|
36825
|
+
```
|
|
36826
|
+
|
|
36827
|
+
```python
|
|
36828
|
+
from agentmail import AgentMail
|
|
36829
|
+
|
|
36830
|
+
client = AgentMail(
|
|
36831
|
+
api_key="YOUR_TOKEN_HERE"
|
|
36832
|
+
)
|
|
36833
|
+
|
|
36834
|
+
client.pods.api_keys.delete(
|
|
36835
|
+
pod_id="pod_id",
|
|
36836
|
+
api_key="api_key"
|
|
36837
|
+
)
|
|
36838
|
+
|
|
36839
|
+
```
|
|
36840
|
+
|
|
36841
|
+
```go
|
|
36842
|
+
package main
|
|
36843
|
+
|
|
36844
|
+
import (
|
|
36845
|
+
"fmt"
|
|
36846
|
+
"net/http"
|
|
36847
|
+
"io"
|
|
36848
|
+
)
|
|
36849
|
+
|
|
36850
|
+
func main() {
|
|
36851
|
+
|
|
36852
|
+
url := "https://api.agentmail.to/v0/pods/pod_id/api-keys/api_key"
|
|
36853
|
+
|
|
36854
|
+
req, _ := http.NewRequest("DELETE", url, nil)
|
|
36855
|
+
|
|
36856
|
+
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
36857
|
+
|
|
36858
|
+
res, _ := http.DefaultClient.Do(req)
|
|
36859
|
+
|
|
36860
|
+
defer res.Body.Close()
|
|
36861
|
+
body, _ := io.ReadAll(res.Body)
|
|
36862
|
+
|
|
36863
|
+
fmt.Println(res)
|
|
36864
|
+
fmt.Println(string(body))
|
|
36865
|
+
|
|
36866
|
+
}
|
|
36867
|
+
```
|
|
36868
|
+
|
|
36869
|
+
```ruby
|
|
36870
|
+
require 'uri'
|
|
36871
|
+
require 'net/http'
|
|
36872
|
+
|
|
36873
|
+
url = URI("https://api.agentmail.to/v0/pods/pod_id/api-keys/api_key")
|
|
36874
|
+
|
|
36875
|
+
http = Net::HTTP.new(url.host, url.port)
|
|
36876
|
+
http.use_ssl = true
|
|
36877
|
+
|
|
36878
|
+
request = Net::HTTP::Delete.new(url)
|
|
36879
|
+
request["Authorization"] = 'Bearer <api_key>'
|
|
36880
|
+
|
|
36881
|
+
response = http.request(request)
|
|
36882
|
+
puts response.read_body
|
|
36883
|
+
```
|
|
36884
|
+
|
|
36885
|
+
```java
|
|
36886
|
+
import com.mashape.unirest.http.HttpResponse;
|
|
36887
|
+
import com.mashape.unirest.http.Unirest;
|
|
36888
|
+
|
|
36889
|
+
HttpResponse<String> response = Unirest.delete("https://api.agentmail.to/v0/pods/pod_id/api-keys/api_key")
|
|
36890
|
+
.header("Authorization", "Bearer <api_key>")
|
|
36891
|
+
.asString();
|
|
36892
|
+
```
|
|
36893
|
+
|
|
36894
|
+
```php
|
|
36895
|
+
<?php
|
|
36896
|
+
require_once('vendor/autoload.php');
|
|
36897
|
+
|
|
36898
|
+
$client = new \GuzzleHttp\Client();
|
|
36899
|
+
|
|
36900
|
+
$response = $client->request('DELETE', 'https://api.agentmail.to/v0/pods/pod_id/api-keys/api_key', [
|
|
36901
|
+
'headers' => [
|
|
36902
|
+
'Authorization' => 'Bearer <api_key>',
|
|
36903
|
+
],
|
|
36904
|
+
]);
|
|
36905
|
+
|
|
36906
|
+
echo $response->getBody();
|
|
36907
|
+
```
|
|
36908
|
+
|
|
36909
|
+
```csharp
|
|
36910
|
+
using RestSharp;
|
|
36911
|
+
|
|
36912
|
+
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/api-keys/api_key");
|
|
36913
|
+
var request = new RestRequest(Method.DELETE);
|
|
36914
|
+
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
36915
|
+
IRestResponse response = client.Execute(request);
|
|
36916
|
+
```
|
|
36917
|
+
|
|
36918
|
+
```swift
|
|
36919
|
+
import Foundation
|
|
36920
|
+
|
|
36921
|
+
let headers = ["Authorization": "Bearer <api_key>"]
|
|
36922
|
+
|
|
36923
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/api-keys/api_key")! as URL,
|
|
36924
|
+
cachePolicy: .useProtocolCachePolicy,
|
|
36925
|
+
timeoutInterval: 10.0)
|
|
36926
|
+
request.httpMethod = "DELETE"
|
|
36927
|
+
request.allHTTPHeaderFields = headers
|
|
36928
|
+
|
|
36929
|
+
let session = URLSession.shared
|
|
36930
|
+
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
36931
|
+
if (error != nil) {
|
|
36932
|
+
print(error as Any)
|
|
36933
|
+
} else {
|
|
36934
|
+
let httpResponse = response as? HTTPURLResponse
|
|
36935
|
+
print(httpResponse)
|
|
36936
|
+
}
|
|
36937
|
+
})
|
|
36938
|
+
|
|
36939
|
+
dataTask.resume()
|
|
36940
|
+
```
|
|
36941
|
+
|
|
34764
36942
|
# Get Organization
|
|
34765
36943
|
|
|
34766
36944
|
GET https://api.agentmail.to/v0/organizations
|