agentmail 0.1.19 → 0.2.3
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/README.md +30 -1
- package/dist/cjs/BaseClient.d.ts +7 -7
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/Client.d.ts +1 -2
- package/dist/cjs/api/errors/IsTakenError.js +5 -1
- package/dist/cjs/api/errors/NotFoundError.js +5 -1
- package/dist/cjs/api/errors/ValidationError.js +5 -1
- package/dist/cjs/api/resources/apiKeys/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/apiKeys/client/Client.js +8 -52
- package/dist/cjs/api/resources/attachments/types/AttachmentResponse.d.ts +13 -0
- package/dist/cjs/api/resources/attachments/types/AttachmentResponse.js +3 -0
- package/dist/cjs/api/resources/attachments/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/attachments/types/index.js +1 -0
- package/dist/cjs/api/resources/domains/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/domains/client/Client.js +11 -97
- package/dist/cjs/api/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/drafts/client/Client.js +20 -49
- package/dist/cjs/api/resources/inboxes/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/client/Client.js +10 -82
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +24 -109
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +10 -3
- package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +45 -144
- package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/inboxes/resources/metrics/client/Client.js +16 -22
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.d.ts +10 -3
- package/dist/cjs/api/resources/inboxes/resources/threads/client/Client.js +41 -84
- package/dist/cjs/api/resources/messages/errors/MessageRejectedError.js +5 -1
- package/dist/cjs/api/resources/metrics/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/metrics/client/Client.js +16 -22
- package/dist/cjs/api/resources/organizations/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/organizations/client/Client.js +2 -15
- package/dist/cjs/api/resources/pods/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/client/Client.js +9 -67
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/domains/client/Client.js +8 -52
- package/dist/cjs/api/resources/pods/resources/drafts/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/drafts/client/Client.js +20 -49
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/pods/resources/inboxes/client/Client.js +9 -67
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.d.ts +10 -3
- package/dist/cjs/api/resources/pods/resources/threads/client/Client.js +40 -69
- package/dist/cjs/api/resources/threads/client/Client.d.ts +9 -3
- package/dist/cjs/api/resources/threads/client/Client.js +39 -69
- package/dist/cjs/api/resources/webhooks/client/Client.d.ts +1 -2
- package/dist/cjs/api/resources/webhooks/client/Client.js +9 -67
- package/dist/cjs/api/resources/websockets/client/Client.d.ts +2 -3
- package/dist/cjs/api/resources/websockets/client/Client.js +3 -4
- package/dist/cjs/auth/BearerAuthProvider.d.ts +14 -8
- package/dist/cjs/auth/BearerAuthProvider.js +16 -6
- package/dist/cjs/core/fetcher/BinaryResponse.d.ts +6 -7
- package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
- package/dist/cjs/core/fetcher/Fetcher.d.ts +6 -3
- package/dist/cjs/core/fetcher/Fetcher.js +2 -1
- package/dist/cjs/core/fetcher/getResponseBody.js +18 -4
- package/dist/cjs/core/fetcher/signals.d.ts +1 -1
- package/dist/cjs/core/headers.d.ts +2 -2
- package/dist/cjs/core/runtime/runtime.js +11 -10
- package/dist/cjs/core/schemas/builders/object/object.js +34 -3
- package/dist/cjs/core/websocket/ws.d.ts +1 -1
- package/dist/cjs/errors/AgentMailError.js +5 -1
- package/dist/cjs/errors/AgentMailTimeoutError.js +5 -1
- package/dist/cjs/errors/handleNonStatusCodeError.d.ts +2 -0
- package/dist/cjs/errors/handleNonStatusCodeError.js +65 -0
- package/dist/cjs/serialization/resources/attachments/types/AttachmentResponse.d.ts +22 -0
- package/dist/cjs/serialization/resources/attachments/types/AttachmentResponse.js +54 -0
- package/dist/cjs/serialization/resources/attachments/types/index.d.ts +1 -0
- package/dist/cjs/serialization/resources/attachments/types/index.js +1 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +7 -7
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/Client.d.mts +1 -2
- package/dist/esm/api/errors/IsTakenError.mjs +5 -1
- package/dist/esm/api/errors/NotFoundError.mjs +5 -1
- package/dist/esm/api/errors/ValidationError.mjs +5 -1
- package/dist/esm/api/resources/apiKeys/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/apiKeys/client/Client.mjs +8 -52
- package/dist/esm/api/resources/attachments/types/AttachmentResponse.d.mts +13 -0
- package/dist/esm/api/resources/attachments/types/AttachmentResponse.mjs +2 -0
- package/dist/esm/api/resources/attachments/types/index.d.mts +1 -0
- package/dist/esm/api/resources/attachments/types/index.mjs +1 -0
- package/dist/esm/api/resources/domains/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/domains/client/Client.mjs +11 -97
- package/dist/esm/api/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/drafts/client/Client.mjs +20 -49
- package/dist/esm/api/resources/inboxes/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/client/Client.mjs +10 -82
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +24 -109
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +10 -3
- package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +45 -144
- package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/inboxes/resources/metrics/client/Client.mjs +16 -22
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.d.mts +10 -3
- package/dist/esm/api/resources/inboxes/resources/threads/client/Client.mjs +41 -84
- package/dist/esm/api/resources/messages/errors/MessageRejectedError.mjs +5 -1
- package/dist/esm/api/resources/metrics/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/metrics/client/Client.mjs +16 -22
- package/dist/esm/api/resources/organizations/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/organizations/client/Client.mjs +2 -15
- package/dist/esm/api/resources/pods/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/client/Client.mjs +9 -67
- package/dist/esm/api/resources/pods/resources/domains/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/domains/client/Client.mjs +8 -52
- package/dist/esm/api/resources/pods/resources/drafts/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/drafts/client/Client.mjs +20 -49
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/pods/resources/inboxes/client/Client.mjs +9 -67
- package/dist/esm/api/resources/pods/resources/threads/client/Client.d.mts +10 -3
- package/dist/esm/api/resources/pods/resources/threads/client/Client.mjs +40 -69
- package/dist/esm/api/resources/threads/client/Client.d.mts +9 -3
- package/dist/esm/api/resources/threads/client/Client.mjs +39 -69
- package/dist/esm/api/resources/webhooks/client/Client.d.mts +1 -2
- package/dist/esm/api/resources/webhooks/client/Client.mjs +9 -67
- package/dist/esm/api/resources/websockets/client/Client.d.mts +2 -3
- package/dist/esm/api/resources/websockets/client/Client.mjs +3 -4
- package/dist/esm/auth/BearerAuthProvider.d.mts +14 -8
- package/dist/esm/auth/BearerAuthProvider.mjs +16 -6
- package/dist/esm/core/fetcher/BinaryResponse.d.mts +6 -7
- package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
- package/dist/esm/core/fetcher/Fetcher.d.mts +6 -3
- package/dist/esm/core/fetcher/Fetcher.mjs +2 -1
- package/dist/esm/core/fetcher/getResponseBody.mjs +18 -4
- package/dist/esm/core/fetcher/signals.d.mts +1 -1
- package/dist/esm/core/headers.d.mts +2 -2
- package/dist/esm/core/runtime/runtime.mjs +11 -10
- package/dist/esm/core/schemas/builders/object/object.mjs +34 -3
- package/dist/esm/core/websocket/ws.d.mts +1 -1
- package/dist/esm/errors/AgentMailError.mjs +5 -1
- package/dist/esm/errors/AgentMailTimeoutError.mjs +5 -1
- package/dist/esm/errors/handleNonStatusCodeError.d.mts +2 -0
- package/dist/esm/errors/handleNonStatusCodeError.mjs +29 -0
- package/dist/esm/serialization/resources/attachments/types/AttachmentResponse.d.mts +22 -0
- package/dist/esm/serialization/resources/attachments/types/AttachmentResponse.mjs +18 -0
- package/dist/esm/serialization/resources/attachments/types/index.d.mts +1 -0
- package/dist/esm/serialization/resources/attachments/types/index.mjs +1 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/dist/llms-full.txt +1905 -131
- package/dist/llms.txt +3 -0
- package/package.json +6 -3
- package/reference.md +4 -4
- package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +0 -4
- package/dist/cjs/core/fetcher/ResponseWithBody.js +0 -6
- package/dist/esm/core/fetcher/ResponseWithBody.d.mts +0 -4
- package/dist/esm/core/fetcher/ResponseWithBody.mjs +0 -3
package/dist/llms-full.txt
CHANGED
|
@@ -1862,6 +1862,244 @@ Here's the step-by-step logic for a polling-based conversational agent.
|
|
|
1862
1862
|
</Callout>
|
|
1863
1863
|
|
|
1864
1864
|
|
|
1865
|
+
# IMAP & SMTP
|
|
1866
|
+
|
|
1867
|
+
> Configure IMAP and SMTP to access your AgentMail inboxes using email clients or programmatic access.
|
|
1868
|
+
|
|
1869
|
+
AgentMail supports standard IMAP and SMTP protocols, allowing you to connect using traditional email clients or integrate with existing systems that rely on these protocols.
|
|
1870
|
+
|
|
1871
|
+
## What are IMAP and SMTP?
|
|
1872
|
+
|
|
1873
|
+
**IMAP (Internet Message Access Protocol)** and **SMTP (Simple Mail Transfer Protocol)** are the standard protocols that power email communication across the internet.
|
|
1874
|
+
|
|
1875
|
+
* **IMAP** is used to **read and manage emails**. It allows email clients to sync with a mail server, keeping your messages organized across multiple devices. When you check your inbox in Outlook or Thunderbird, you're using IMAP.
|
|
1876
|
+
|
|
1877
|
+
* **SMTP** is used to **send emails**. When you hit "Send" on an email, SMTP handles delivering that message to the recipient's mail server.
|
|
1878
|
+
|
|
1879
|
+
### Why Use IMAP/SMTP with AgentMail?
|
|
1880
|
+
|
|
1881
|
+
* **Email Client Integration**: Connect Outlook, Thunderbird, Apple Mail, or any IMAP/SMTP-compatible client to your AgentMail inbox
|
|
1882
|
+
* **Programmatic Access**: Send and receive emails using standard libraries (like Python's `imaplib` or `smtplib`) in any programming language
|
|
1883
|
+
* **Legacy System Integration**: Bridge AgentMail with existing systems that only support IMAP/SMTP protocols
|
|
1884
|
+
* **Familiar Tooling**: Use email tools you already know during development and testing
|
|
1885
|
+
|
|
1886
|
+
## Finding Your Credentials
|
|
1887
|
+
|
|
1888
|
+
Before configuring IMAP or SMTP, you'll need two pieces of information from the [AgentMail Console](https://console.agentmail.to):
|
|
1889
|
+
|
|
1890
|
+
<Steps>
|
|
1891
|
+
<Step title="Get Your Inbox ID (Username)">
|
|
1892
|
+
Navigate to **Dashboard → Inboxes** and find the **Inbox ID** column. Your
|
|
1893
|
+
inbox ID is your inbox's email address (e.g., `myinbox@agentmail.to`). This
|
|
1894
|
+
will be your username for IMAP authentication.
|
|
1895
|
+
</Step>
|
|
1896
|
+
|
|
1897
|
+
<Step title="Get Your API Key (Password)">
|
|
1898
|
+
Navigate to **Dashboard → API Keys** and create or copy an API key—this will
|
|
1899
|
+
be your password.
|
|
1900
|
+
</Step>
|
|
1901
|
+
</Steps>
|
|
1902
|
+
|
|
1903
|
+
## IMAP Configuration
|
|
1904
|
+
|
|
1905
|
+
Use IMAP to read emails from your AgentMail inbox.
|
|
1906
|
+
|
|
1907
|
+
<Callout intent="warning" title="SSL/TLS Required">
|
|
1908
|
+
SSL/TLS is **required** for all IMAP connections. Connections without SSL will
|
|
1909
|
+
be rejected. Make sure to enable SSL/TLS in your email client settings.
|
|
1910
|
+
</Callout>
|
|
1911
|
+
|
|
1912
|
+
| Setting | Value |
|
|
1913
|
+
| ------------ | ----------------------------------------------- |
|
|
1914
|
+
| **Host** | `imap.agentmail.to` |
|
|
1915
|
+
| **Port** | `993` |
|
|
1916
|
+
| **Username** | Your inbox email (e.g., `myinbox@agentmail.to`) |
|
|
1917
|
+
| **Password** | Your API key |
|
|
1918
|
+
| **SSL/TLS** | **Required** (must be enabled) |
|
|
1919
|
+
|
|
1920
|
+
<Callout intent="tip" title="Folder Support">
|
|
1921
|
+
Currently, only the **INBOX** folder is accessible via IMAP. Other folders
|
|
1922
|
+
(Sent, Drafts, Trash) are not available through IMAP. Use the [AgentMail
|
|
1923
|
+
API](/introduction) for full folder access.
|
|
1924
|
+
</Callout>
|
|
1925
|
+
|
|
1926
|
+
### Python IMAP Example
|
|
1927
|
+
|
|
1928
|
+
```python
|
|
1929
|
+
import imaplib
|
|
1930
|
+
import os
|
|
1931
|
+
import email
|
|
1932
|
+
|
|
1933
|
+
# Your credentials from AgentMail Console
|
|
1934
|
+
inbox_email = "myinbox@agentmail.to" # From Dashboard → Inboxes
|
|
1935
|
+
api_key = os.getenv("AGENTMAIL_API_KEY") # From Dashboard → API Keys
|
|
1936
|
+
|
|
1937
|
+
# Connect with SSL (required)
|
|
1938
|
+
imap = imaplib.IMAP4_SSL("imap.agentmail.to", 993)
|
|
1939
|
+
|
|
1940
|
+
try:
|
|
1941
|
+
# Authenticate using inbox email as username
|
|
1942
|
+
imap.login(inbox_email, api_key)
|
|
1943
|
+
|
|
1944
|
+
# Select INBOX (only supported folder)
|
|
1945
|
+
imap.select("INBOX")
|
|
1946
|
+
|
|
1947
|
+
# Search for all messages
|
|
1948
|
+
status, message_ids = imap.search(None, "ALL")
|
|
1949
|
+
|
|
1950
|
+
if status == "OK":
|
|
1951
|
+
for msg_id in message_ids[0].split():
|
|
1952
|
+
# Fetch message
|
|
1953
|
+
status, msg_data = imap.fetch(msg_id, "(RFC822)")
|
|
1954
|
+
if status == "OK":
|
|
1955
|
+
email_body = msg_data[0][1]
|
|
1956
|
+
message = email.message_from_bytes(email_body)
|
|
1957
|
+
print(f"Subject: {message['subject']}")
|
|
1958
|
+
finally:
|
|
1959
|
+
imap.logout()
|
|
1960
|
+
```
|
|
1961
|
+
|
|
1962
|
+
### TypeScript IMAP Example
|
|
1963
|
+
|
|
1964
|
+
```typescript
|
|
1965
|
+
import Imap from "imap";
|
|
1966
|
+
|
|
1967
|
+
// Your credentials from AgentMail Console
|
|
1968
|
+
const inboxEmail = "myinbox@agentmail.to"; // From Dashboard → Inboxes
|
|
1969
|
+
const apiKey = process.env.AGENTMAIL_API_KEY!; // From Dashboard → API Keys
|
|
1970
|
+
|
|
1971
|
+
const imap = new Imap({
|
|
1972
|
+
user: inboxEmail,
|
|
1973
|
+
password: apiKey,
|
|
1974
|
+
host: "imap.agentmail.to",
|
|
1975
|
+
port: 993,
|
|
1976
|
+
tls: true, // SSL required
|
|
1977
|
+
});
|
|
1978
|
+
|
|
1979
|
+
imap.once("ready", () => {
|
|
1980
|
+
imap.openBox("INBOX", false, (err, box) => {
|
|
1981
|
+
if (err) throw err;
|
|
1982
|
+
console.log(`${box.messages.total} messages in INBOX`);
|
|
1983
|
+
imap.end();
|
|
1984
|
+
});
|
|
1985
|
+
});
|
|
1986
|
+
|
|
1987
|
+
imap.once("error", (err: Error) => {
|
|
1988
|
+
console.error("IMAP error:", err.message);
|
|
1989
|
+
});
|
|
1990
|
+
|
|
1991
|
+
imap.connect();
|
|
1992
|
+
```
|
|
1993
|
+
|
|
1994
|
+
## SMTP Configuration
|
|
1995
|
+
|
|
1996
|
+
Use SMTP to send emails from your AgentMail inbox.
|
|
1997
|
+
|
|
1998
|
+
<Callout intent="warning" title="SSL/TLS Required">
|
|
1999
|
+
SSL/TLS is **required** for all SMTP connections. Connections without SSL will
|
|
2000
|
+
be rejected. Make sure to enable SSL/TLS in your email client settings.
|
|
2001
|
+
</Callout>
|
|
2002
|
+
|
|
2003
|
+
| Setting | Value |
|
|
2004
|
+
| ------------ | ------------------------------ |
|
|
2005
|
+
| **Host** | `smtp.agentmail.to` |
|
|
2006
|
+
| **Port** | `465` |
|
|
2007
|
+
| **Username** | agentmail |
|
|
2008
|
+
| **Password** | Your API key |
|
|
2009
|
+
| **SSL/TLS** | **Required** (must be enabled) |
|
|
2010
|
+
|
|
2011
|
+
<Callout intent="warning" title="From Address">
|
|
2012
|
+
The "From" address in your email should match the email address of your inbox
|
|
2013
|
+
(e.g., `myinbox@agentmail.to`). Using a different From address may result in
|
|
2014
|
+
delivery failures.
|
|
2015
|
+
</Callout>
|
|
2016
|
+
|
|
2017
|
+
### SMTP Limits
|
|
2018
|
+
|
|
2019
|
+
* **Max recipients**: 50 per email
|
|
2020
|
+
* **Max message size**: 10MB
|
|
2021
|
+
* **Session timeout**: 30 minutes
|
|
2022
|
+
|
|
2023
|
+
### Python SMTP Example
|
|
2024
|
+
|
|
2025
|
+
```python
|
|
2026
|
+
import smtplib
|
|
2027
|
+
import os
|
|
2028
|
+
from email.mime.text import MIMEText
|
|
2029
|
+
from email.mime.multipart import MIMEMultipart
|
|
2030
|
+
|
|
2031
|
+
# Your credentials from AgentMail Console
|
|
2032
|
+
inbox_email = "myinbox@agentmail.to" # From Dashboard → Inboxes
|
|
2033
|
+
api_key = os.getenv("AGENTMAIL_API_KEY") # From Dashboard → API Keys
|
|
2034
|
+
|
|
2035
|
+
# Create message
|
|
2036
|
+
msg = MIMEMultipart()
|
|
2037
|
+
msg["Subject"] = "Hello from AgentMail"
|
|
2038
|
+
msg["From"] = inbox_email # Use your inbox email as the From address
|
|
2039
|
+
msg["To"] = "recipient@example.com"
|
|
2040
|
+
msg.attach(MIMEText("This is a test email sent via SMTP.", "plain"))
|
|
2041
|
+
|
|
2042
|
+
# Connect with SSL (required) and send
|
|
2043
|
+
with smtplib.SMTP_SSL("smtp.agentmail.to", 465) as server:
|
|
2044
|
+
server.login(inbox_email, api_key)
|
|
2045
|
+
server.send_message(msg)
|
|
2046
|
+
print("Email sent successfully!")
|
|
2047
|
+
```
|
|
2048
|
+
|
|
2049
|
+
### TypeScript SMTP Example
|
|
2050
|
+
|
|
2051
|
+
```typescript
|
|
2052
|
+
import nodemailer from "nodemailer";
|
|
2053
|
+
|
|
2054
|
+
// Your credentials from AgentMail Console
|
|
2055
|
+
const inboxEmail = "myinbox@agentmail.to"; // From Dashboard → Inboxes
|
|
2056
|
+
const apiKey = process.env.AGENTMAIL_API_KEY!; // From Dashboard → API Keys
|
|
2057
|
+
|
|
2058
|
+
const transporter = nodemailer.createTransport({
|
|
2059
|
+
host: "smtp.agentmail.to",
|
|
2060
|
+
port: 465,
|
|
2061
|
+
secure: true, // SSL required
|
|
2062
|
+
auth: {
|
|
2063
|
+
user: inboxEmail,
|
|
2064
|
+
pass: apiKey,
|
|
2065
|
+
},
|
|
2066
|
+
});
|
|
2067
|
+
|
|
2068
|
+
async function sendEmail() {
|
|
2069
|
+
const info = await transporter.sendMail({
|
|
2070
|
+
from: inboxEmail, // Use your inbox email as the From address
|
|
2071
|
+
to: "recipient@example.com",
|
|
2072
|
+
subject: "Hello from AgentMail",
|
|
2073
|
+
text: "This is a test email sent via SMTP.",
|
|
2074
|
+
});
|
|
2075
|
+
console.log("Email sent:", info.messageId);
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
sendEmail().catch(console.error);
|
|
2079
|
+
```
|
|
2080
|
+
|
|
2081
|
+
## Troubleshooting
|
|
2082
|
+
|
|
2083
|
+
| Error | Cause | Solution |
|
|
2084
|
+
| ----------------------- | ----------------------- | ------------------------------------------------------ |
|
|
2085
|
+
| "Authentication failed" | Invalid credentials | Verify your inbox email and API key from the console |
|
|
2086
|
+
| "Connection refused" | SSL not enabled | Enable SSL/TLS in your client settings |
|
|
2087
|
+
| "Connection timeout" | Firewall blocking ports | Ensure ports 993 (IMAP) and 465/587 (SMTP) are open |
|
|
2088
|
+
| "Sender not authorized" | Wrong From address | Use your inbox's email address as the From address |
|
|
2089
|
+
| "Folder not found" | Non-INBOX folder | Only INBOX is supported; use the API for other folders |
|
|
2090
|
+
|
|
2091
|
+
## When to Use IMAP/SMTP vs API
|
|
2092
|
+
|
|
2093
|
+
| Use Case | Recommendation |
|
|
2094
|
+
| --------------------------- | -------------- |
|
|
2095
|
+
| Email client integration | IMAP/SMTP |
|
|
2096
|
+
| Simple programmatic sending | SMTP |
|
|
2097
|
+
| Full inbox management | API |
|
|
2098
|
+
| Real-time notifications | API (Webhooks) |
|
|
2099
|
+
| Access to all folders | API |
|
|
2100
|
+
| Bulk operations | API |
|
|
2101
|
+
|
|
2102
|
+
|
|
1865
2103
|
# Using Custom Domains
|
|
1866
2104
|
|
|
1867
2105
|
> A step-by-step guide to configuring your custom domain with AgentMail for enhanced branding and trust.
|
|
@@ -2574,6 +2812,10 @@ When AgentMail sends a webhook, the payload will have the following structure.
|
|
|
2574
2812
|
Explore the full list of available event types and their data payloads.
|
|
2575
2813
|
</Card>
|
|
2576
2814
|
|
|
2815
|
+
<Card title="Verifying Webhooks" href="/webhook-verification">
|
|
2816
|
+
Learn how to verify webhook signatures to secure your endpoints.
|
|
2817
|
+
</Card>
|
|
2818
|
+
|
|
2577
2819
|
<Card title="Example: Event-Driven Agent" href="/github-star-agent">
|
|
2578
2820
|
Build a fully deployable, event-driven agent that can respond to emails in
|
|
2579
2821
|
real time.
|
|
@@ -3067,12 +3309,16 @@ To test your webhook setup:
|
|
|
3067
3309
|
For production deployments:
|
|
3068
3310
|
|
|
3069
3311
|
* **Use a dedicated server**: Deploy your webhook receiver to a cloud service (AWS, GCP, Heroku, etc.) instead of using ngrok
|
|
3070
|
-
* **Implement webhook verification**: Validate incoming requests are from AgentMail
|
|
3312
|
+
* **Implement webhook verification**: [Validate incoming requests](/webhook-verification) are authentically from AgentMail
|
|
3071
3313
|
* **Add error handling**: Implement retry logic and error reporting
|
|
3072
3314
|
* **Use async processing**: Return 200 immediately and process webhooks in background jobs
|
|
3073
3315
|
* **Monitor webhook health**: Set up logging and alerting for failed webhook deliveries
|
|
3074
3316
|
|
|
3075
3317
|
<CardGroup>
|
|
3318
|
+
<Card title="Verifying Webhooks" href="/webhook-verification">
|
|
3319
|
+
Learn how to verify webhook signatures for secure endpoints.
|
|
3320
|
+
</Card>
|
|
3321
|
+
|
|
3076
3322
|
<Card title="Webhooks Overview" href="/overview">
|
|
3077
3323
|
Learn more about how webhooks work and their payload structure.
|
|
3078
3324
|
</Card>
|
|
@@ -3080,9 +3326,367 @@ For production deployments:
|
|
|
3080
3326
|
<Card title="Webhook Events" href="/events">
|
|
3081
3327
|
Explore the full list of webhook event types.
|
|
3082
3328
|
</Card>
|
|
3329
|
+
</CardGroup>
|
|
3330
|
+
|
|
3331
|
+
|
|
3332
|
+
# Verifying Webhooks
|
|
3333
|
+
|
|
3334
|
+
> Learn how to verify webhook signatures to secure your webhook endpoints and prevent spoofed requests.
|
|
3335
|
+
|
|
3336
|
+
When building webhook receivers, it's critical to verify that incoming requests actually originate from AgentMail and haven't been tampered with. AgentMail uses [Svix](https://www.svix.com/) to deliver webhooks, which provides cryptographic signature verification.
|
|
3337
|
+
|
|
3338
|
+
## Why Verify Webhooks?
|
|
3339
|
+
|
|
3340
|
+
Without verification, anyone who discovers your webhook URL could send fake requests to your endpoint, potentially causing:
|
|
3341
|
+
|
|
3342
|
+
* **Data manipulation:** Malicious actors could trigger actions based on fake events
|
|
3343
|
+
* **Security breaches:** Spoofed messages could inject harmful data into your systems
|
|
3344
|
+
* **Resource exhaustion:** Attackers could flood your endpoint with fake requests
|
|
3345
|
+
|
|
3346
|
+
Always verify webhook signatures in production environments.
|
|
3347
|
+
|
|
3348
|
+
## Getting Your Signing Secret
|
|
3349
|
+
|
|
3350
|
+
Each webhook endpoint has a unique signing secret that you'll use to verify requests. You can find this secret in the AgentMail console when you create your webhook or by fetching your webhook details:
|
|
3351
|
+
|
|
3352
|
+
<CodeBlocks>
|
|
3353
|
+
```python
|
|
3354
|
+
from agentmail import AgentMail
|
|
3355
|
+
|
|
3356
|
+
client = AgentMail()
|
|
3357
|
+
|
|
3358
|
+
# Get webhook details including the signing secret
|
|
3359
|
+
webhook = client.webhooks.get(webhook_id="ep_xxx")
|
|
3360
|
+
|
|
3361
|
+
# The secret starts with "whsec_"
|
|
3362
|
+
signing_secret = webhook.secret
|
|
3363
|
+
print(f"Signing secret: {signing_secret}")
|
|
3364
|
+
```
|
|
3365
|
+
|
|
3366
|
+
```typescript
|
|
3367
|
+
import AgentMail from "agentmail";
|
|
3368
|
+
|
|
3369
|
+
const client = new AgentMail();
|
|
3370
|
+
|
|
3371
|
+
// Get webhook details including the signing secret
|
|
3372
|
+
const webhook = await client.webhooks.get("ep_xxx");
|
|
3373
|
+
|
|
3374
|
+
// The secret starts with "whsec_"
|
|
3375
|
+
const signingSecret = webhook.secret;
|
|
3376
|
+
console.log(`Signing secret: ${signingSecret}`);
|
|
3377
|
+
```
|
|
3378
|
+
</CodeBlocks>
|
|
3379
|
+
|
|
3380
|
+
<Callout intent="warning" title="Keep your secret safe">
|
|
3381
|
+
Store your signing secret securely in environment variables. Never commit it to version control or expose it in client-side code.
|
|
3382
|
+
</Callout>
|
|
3383
|
+
|
|
3384
|
+
## Verification Headers
|
|
3385
|
+
|
|
3386
|
+
Every webhook request from AgentMail includes three headers used for verification:
|
|
3387
|
+
|
|
3388
|
+
| Header | Description |
|
|
3389
|
+
| ---------------- | --------------------------------------------------------------------------------------------- |
|
|
3390
|
+
| `svix-id` | Unique message identifier. Same ID is used for retries of the same message. |
|
|
3391
|
+
| `svix-timestamp` | Unix timestamp (seconds) when the message was sent. |
|
|
3392
|
+
| `svix-signature` | Space-delimited list of signatures in the format `v1,<base64>` (e.g., `v1,abc123 v1,def456`). |
|
|
3393
|
+
|
|
3394
|
+
## Verifying with the Svix Library (Recommended)
|
|
3395
|
+
|
|
3396
|
+
The easiest way to verify webhooks is using the official Svix library, which handles all the cryptographic details for you.
|
|
3397
|
+
|
|
3398
|
+
<CodeBlocks>
|
|
3399
|
+
```python
|
|
3400
|
+
import os
|
|
3401
|
+
from dotenv import load_dotenv
|
|
3402
|
+
from flask import Flask, request
|
|
3403
|
+
|
|
3404
|
+
from svix.webhooks import Webhook, WebhookVerificationError
|
|
3405
|
+
|
|
3406
|
+
load_dotenv()
|
|
3407
|
+
|
|
3408
|
+
app = Flask(__name__)
|
|
3409
|
+
|
|
3410
|
+
secret = os.environ["AGENTMAIL_WEBHOOK_SECRET"]
|
|
3411
|
+
|
|
3412
|
+
@app.route('/webhooks', methods=['POST'])
|
|
3413
|
+
def webhook_handler():
|
|
3414
|
+
headers = request.headers
|
|
3415
|
+
payload = request.get_data()
|
|
3416
|
+
|
|
3417
|
+
try:
|
|
3418
|
+
wh = Webhook(secret)
|
|
3419
|
+
msg = wh.verify(payload, headers)
|
|
3420
|
+
except WebhookVerificationError as e:
|
|
3421
|
+
return ('', 400)
|
|
3422
|
+
|
|
3423
|
+
# Do something with the message...
|
|
3424
|
+
|
|
3425
|
+
return ('', 204)
|
|
3426
|
+
|
|
3427
|
+
if __name__ == '__main__':
|
|
3428
|
+
app.run(port=3000)
|
|
3429
|
+
|
|
3430
|
+
```
|
|
3431
|
+
|
|
3432
|
+
```typescript
|
|
3433
|
+
import "dotenv/config";
|
|
3434
|
+
import express, { Request, Response } from "express";
|
|
3435
|
+
import { Webhook } from "svix";
|
|
3436
|
+
|
|
3437
|
+
const app = express();
|
|
3438
|
+
const port = 3000;
|
|
3439
|
+
|
|
3440
|
+
const secret = process.env.AGENTMAIL_WEBHOOK_SECRET;
|
|
3441
|
+
|
|
3442
|
+
if (!secret) {
|
|
3443
|
+
throw new Error("AGENTMAIL_WEBHOOK_SECRET environment variable is required");
|
|
3444
|
+
}
|
|
3445
|
+
|
|
3446
|
+
app.post(
|
|
3447
|
+
"/webhooks",
|
|
3448
|
+
express.raw({ type: "application/json" }),
|
|
3449
|
+
(req: Request, res: Response) => {
|
|
3450
|
+
const payload = req.body;
|
|
3451
|
+
const headers = req.headers as Record<string, string>;
|
|
3452
|
+
|
|
3453
|
+
try {
|
|
3454
|
+
const wh = new Webhook(secret);
|
|
3455
|
+
const msg = wh.verify(payload, headers);
|
|
3456
|
+
|
|
3457
|
+
// Do something with the message...
|
|
3458
|
+
console.log("Webhook verified:", msg);
|
|
3459
|
+
|
|
3460
|
+
res.status(204).send();
|
|
3461
|
+
} catch (err) {
|
|
3462
|
+
console.error("Webhook verification failed:", err);
|
|
3463
|
+
res.status(400).send();
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
);
|
|
3467
|
+
|
|
3468
|
+
app.listen(port, () => {
|
|
3469
|
+
console.log(`Webhook server listening on port ${port}`);
|
|
3470
|
+
});
|
|
3471
|
+
```
|
|
3472
|
+
</CodeBlocks>
|
|
3473
|
+
|
|
3474
|
+
<Callout intent="info" title="Raw body required">
|
|
3475
|
+
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.
|
|
3476
|
+
</Callout>
|
|
3477
|
+
|
|
3478
|
+
## Testing Locally with ngrok
|
|
3479
|
+
|
|
3480
|
+
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.
|
|
3481
|
+
|
|
3482
|
+
### Step 1: Save Your Webhook Server
|
|
3483
|
+
|
|
3484
|
+
Create a webhook server file:
|
|
3485
|
+
|
|
3486
|
+
<CodeBlocks>
|
|
3487
|
+
```python title="webhook_server.py"
|
|
3488
|
+
import os
|
|
3489
|
+
from dotenv import load_dotenv
|
|
3490
|
+
from flask import Flask, request
|
|
3491
|
+
|
|
3492
|
+
from svix.webhooks import Webhook, WebhookVerificationError
|
|
3493
|
+
|
|
3494
|
+
load_dotenv()
|
|
3495
|
+
|
|
3496
|
+
app = Flask(__name__)
|
|
3497
|
+
|
|
3498
|
+
secret = os.environ.get("AGENTMAIL_WEBHOOK_SECRET")
|
|
3499
|
+
|
|
3500
|
+
@app.route('/webhooks', methods=['POST'])
|
|
3501
|
+
def webhook_handler():
|
|
3502
|
+
headers = request.headers
|
|
3503
|
+
payload = request.get_data()
|
|
3504
|
+
|
|
3505
|
+
try:
|
|
3506
|
+
wh = Webhook(secret)
|
|
3507
|
+
msg = wh.verify(payload, headers)
|
|
3508
|
+
print(f"Received event: {msg}")
|
|
3509
|
+
except WebhookVerificationError as e:
|
|
3510
|
+
print(f"Verification failed: {e}")
|
|
3511
|
+
return ('', 400)
|
|
3512
|
+
|
|
3513
|
+
# Do something with the message...
|
|
3514
|
+
|
|
3515
|
+
return ('', 204)
|
|
3516
|
+
|
|
3517
|
+
if __name__ == '__main__':
|
|
3518
|
+
app.run(port=3000)
|
|
3519
|
+
```
|
|
3520
|
+
|
|
3521
|
+
```typescript title="webhook_server.ts"
|
|
3522
|
+
import "dotenv/config";
|
|
3523
|
+
import express, { Request, Response } from "express";
|
|
3524
|
+
import { Webhook } from "svix";
|
|
3525
|
+
|
|
3526
|
+
const app = express();
|
|
3527
|
+
const port = 3000;
|
|
3528
|
+
|
|
3529
|
+
const secret = process.env.AGENTMAIL_WEBHOOK_SECRET;
|
|
3530
|
+
|
|
3531
|
+
if (!secret) {
|
|
3532
|
+
throw new Error("AGENTMAIL_WEBHOOK_SECRET environment variable is required");
|
|
3533
|
+
}
|
|
3534
|
+
|
|
3535
|
+
app.post(
|
|
3536
|
+
"/webhooks",
|
|
3537
|
+
express.raw({ type: "application/json" }),
|
|
3538
|
+
(req: Request, res: Response) => {
|
|
3539
|
+
const payload = req.body;
|
|
3540
|
+
const headers = req.headers as Record<string, string>;
|
|
3541
|
+
|
|
3542
|
+
try {
|
|
3543
|
+
const wh = new Webhook(secret);
|
|
3544
|
+
const msg = wh.verify(payload, headers);
|
|
3545
|
+
|
|
3546
|
+
// Do something with the message...
|
|
3547
|
+
console.log("Webhook verified:", msg);
|
|
3548
|
+
|
|
3549
|
+
res.status(204).send();
|
|
3550
|
+
} catch (err) {
|
|
3551
|
+
console.error("Webhook verification failed:", err);
|
|
3552
|
+
res.status(400).send();
|
|
3553
|
+
}
|
|
3554
|
+
}
|
|
3555
|
+
);
|
|
3556
|
+
|
|
3557
|
+
app.listen(port, () => {
|
|
3558
|
+
console.log(`Webhook server listening on port ${port}`);
|
|
3559
|
+
});
|
|
3560
|
+
```
|
|
3561
|
+
</CodeBlocks>
|
|
3562
|
+
|
|
3563
|
+
### Step 2: Install Dependencies and Run the Server
|
|
3564
|
+
|
|
3565
|
+
<CodeBlocks>
|
|
3566
|
+
```bash title="Python"
|
|
3567
|
+
pip install flask python-dotenv svix
|
|
3568
|
+
python webhook_server.py
|
|
3569
|
+
```
|
|
3570
|
+
|
|
3571
|
+
```bash title="TypeScript"
|
|
3572
|
+
npm install express svix dotenv
|
|
3573
|
+
npx ts-node webhook_server.ts
|
|
3574
|
+
```
|
|
3575
|
+
</CodeBlocks>
|
|
3576
|
+
|
|
3577
|
+
You should see output like:
|
|
3578
|
+
|
|
3579
|
+
<CodeBlocks>
|
|
3580
|
+
```bash title="Python"
|
|
3581
|
+
* Serving Flask app 'webhook_server'
|
|
3582
|
+
* Debug mode: off
|
|
3583
|
+
* Running on http://127.0.0.1:3000
|
|
3584
|
+
Press CTRL+C to quit
|
|
3585
|
+
```
|
|
3586
|
+
|
|
3587
|
+
```bash title="TypeScript"
|
|
3588
|
+
Webhook server listening on port 3000
|
|
3589
|
+
```
|
|
3590
|
+
</CodeBlocks>
|
|
3591
|
+
|
|
3592
|
+
### Step 3: Start ngrok
|
|
3593
|
+
|
|
3594
|
+
In a new terminal window, start ngrok to create a public tunnel to your local server:
|
|
3595
|
+
|
|
3596
|
+
```bash
|
|
3597
|
+
ngrok http 3000
|
|
3598
|
+
```
|
|
3599
|
+
|
|
3600
|
+
ngrok will display a forwarding URL:
|
|
3601
|
+
|
|
3602
|
+
```
|
|
3603
|
+
Session Status online
|
|
3604
|
+
Account your-email@example.com (Plan: Free)
|
|
3605
|
+
Version 3.22.1
|
|
3606
|
+
Region United States (California) (us-cal-1)
|
|
3607
|
+
Forwarding https://da550b82a183.ngrok.app -> http://localhost:3000
|
|
3608
|
+
```
|
|
3609
|
+
|
|
3610
|
+
Copy the `https://` forwarding URL (e.g., `https://da550b82a183.ngrok.app`).
|
|
3611
|
+
|
|
3612
|
+
### Step 4: Add the URL to AgentMail Console
|
|
3613
|
+
|
|
3614
|
+
1. Go to the [AgentMail Console](https://console.agentmail.to)
|
|
3615
|
+
2. Navigate to **Webhooks** in the sidebar
|
|
3616
|
+
3. Click **Create Webhook** (or edit an existing one)
|
|
3617
|
+
4. Paste your ngrok URL with the `/webhooks` path: `https://da550b82a183.ngrok.app/webhooks`
|
|
3618
|
+
5. Select the events you want to receive
|
|
3619
|
+
6. Save the webhook
|
|
3620
|
+
7. Copy the signing secret and add it to your `.env` file:
|
|
3621
|
+
|
|
3622
|
+
```bash
|
|
3623
|
+
AGENTMAIL_WEBHOOK_SECRET=whsec_your_secret_here
|
|
3624
|
+
```
|
|
3625
|
+
|
|
3626
|
+
### Step 5: Trigger a Test Event
|
|
3627
|
+
|
|
3628
|
+
Send an email to one of your AgentMail inboxes, or use the console to send a test event. You should see the webhook received in your terminal:
|
|
3629
|
+
|
|
3630
|
+
```
|
|
3631
|
+
127.0.0.1 - - [19/Jan/2026 16:57:20] "POST /webhooks HTTP/1.1" 204 -
|
|
3632
|
+
Received event: {'event_type': 'message.received', ...}
|
|
3633
|
+
```
|
|
3634
|
+
|
|
3635
|
+
<Callout intent="info" title="Ready for production?">
|
|
3636
|
+
ngrok is great for local development, but for production you'll need to deploy your webhook server to a hosting provider. See the next section for deployment options.
|
|
3637
|
+
</Callout>
|
|
3638
|
+
|
|
3639
|
+
## Deploying to Production
|
|
3640
|
+
|
|
3641
|
+
For production, you'll need to deploy your webhook server to a hosting provider that gives you a stable, public HTTPS URL. We recommend [Render](https://render.com/) for its simplicity and generous free tier.
|
|
3642
|
+
|
|
3643
|
+
<Callout intent="info" title="Other hosting options">
|
|
3644
|
+
You can also deploy to other platforms like [Railway](https://railway.app/), [Fly.io](https://fly.io/), [Heroku](https://heroku.com/), or any cloud provider that supports Python web applications. The key requirements are a stable public HTTPS URL and the ability to set environment variables.
|
|
3645
|
+
</Callout>
|
|
3646
|
+
|
|
3647
|
+
## Best Practices
|
|
3648
|
+
|
|
3649
|
+
<AccordionGroup>
|
|
3650
|
+
<Accordion title="Always verify in production">
|
|
3651
|
+
While you might skip verification during local development, always enable it in production environments. A compromised webhook endpoint can be a serious security vulnerability.
|
|
3652
|
+
</Accordion>
|
|
3653
|
+
|
|
3654
|
+
<Accordion title="Use environment variables">
|
|
3655
|
+
Never hardcode your signing secret. Use environment variables or a secrets manager:
|
|
3656
|
+
|
|
3657
|
+
```python
|
|
3658
|
+
import os
|
|
3659
|
+
WEBHOOK_SECRET = os.environ["AGENTMAIL_WEBHOOK_SECRET"]
|
|
3660
|
+
```
|
|
3661
|
+
</Accordion>
|
|
3662
|
+
</AccordionGroup>
|
|
3663
|
+
|
|
3664
|
+
## Troubleshooting
|
|
3665
|
+
|
|
3666
|
+
<AccordionGroup>
|
|
3667
|
+
<Accordion title="Signature verification fails">
|
|
3668
|
+
* Ensure you're using the raw request body, not a parsed/modified version
|
|
3669
|
+
* Check that your signing secret is correct and matches the webhook endpoint
|
|
3670
|
+
* Verify you're extracting headers correctly (they're case-insensitive)
|
|
3671
|
+
* Make sure the timestamp hasn't expired (default tolerance is 5 minutes)
|
|
3672
|
+
</Accordion>
|
|
3673
|
+
|
|
3674
|
+
<Accordion title="Missing headers">
|
|
3675
|
+
If headers are missing, ensure your server/framework isn't stripping them. Some reverse proxies may need configuration to pass through custom headers.
|
|
3676
|
+
</Accordion>
|
|
3677
|
+
|
|
3678
|
+
<Accordion title="Body parsing issues">
|
|
3679
|
+
If you're using body-parsing middleware, make sure to access the raw body for verification. In Express, use `express.raw()` for your webhook route.
|
|
3680
|
+
</Accordion>
|
|
3681
|
+
</AccordionGroup>
|
|
3682
|
+
|
|
3683
|
+
<CardGroup>
|
|
3684
|
+
<Card title="Webhook Setup" href="/webhook-setup">
|
|
3685
|
+
Complete guide to setting up webhooks with ngrok.
|
|
3686
|
+
</Card>
|
|
3083
3687
|
|
|
3084
|
-
<Card title="
|
|
3085
|
-
|
|
3688
|
+
<Card title="Webhook Events" href="/events">
|
|
3689
|
+
Explore all available webhook event types.
|
|
3086
3690
|
</Card>
|
|
3087
3691
|
</CardGroup>
|
|
3088
3692
|
|
|
@@ -5593,22 +6197,743 @@ Instead of generic auto-replies, craft responses based on classification:
|
|
|
5593
6197
|
* `complaint` → "We're sorry to hear that. A senior support agent will contact you within 4 hours."
|
|
5594
6198
|
* `feature-request` → "Great idea! We've added this to our product roadmap."
|
|
5595
6199
|
|
|
5596
|
-
### Example 5: Analytics Dashboard
|
|
6200
|
+
### Example 5: Analytics Dashboard
|
|
6201
|
+
|
|
6202
|
+
**Scenario**: Track email metrics and trends.
|
|
6203
|
+
|
|
6204
|
+
Build a dashboard that queries emails by labels to analyze:
|
|
6205
|
+
|
|
6206
|
+
* **Sentiment trends**: Are customers getting happier or more frustrated?
|
|
6207
|
+
* **Volume by department**: Which team is handling the most emails?
|
|
6208
|
+
* **Response times by priority**: Are you meeting SLAs for urgent issues?
|
|
6209
|
+
* **Common categories**: What are customers asking about most?
|
|
6210
|
+
|
|
6211
|
+
Use this data to identify bottlenecks, improve processes, and make data-driven decisions about staffing and product priorities.
|
|
6212
|
+
|
|
6213
|
+
***
|
|
6214
|
+
|
|
6215
|
+
Congratulations! You've built an AI-powered email classification system. This agent showcases how AgentMail's labeling feature can power sophisticated inbox automation and analytics.
|
|
6216
|
+
|
|
6217
|
+
|
|
6218
|
+
# Sales Agent with WebSocket
|
|
6219
|
+
|
|
6220
|
+
> A step-by-step guide to building an AI-powered sales agent that uses WebSocket for real-time email processing without polling or webhooks.
|
|
6221
|
+
|
|
6222
|
+
## Overview
|
|
6223
|
+
|
|
6224
|
+
Learn how to build a real-time sales agent that processes emails instantly using WebSocket connections. Unlike webhook-based agents that require ngrok and public URLs, this WebSocket approach connects directly to AgentMail for true real-time processing with minimal setup.
|
|
6225
|
+
|
|
6226
|
+
This agent demonstrates a practical sales workflow: a manager delegates customer outreach to the agent, which then handles the entire conversation autonomously while keeping the manager informed of key signals.
|
|
6227
|
+
|
|
6228
|
+
## What You'll Build
|
|
6229
|
+
|
|
6230
|
+
By the end of this guide, you'll have a working sales agent that:
|
|
6231
|
+
|
|
6232
|
+
1. **Connects via WebSocket** for instant, real-time email processing
|
|
6233
|
+
2. **Handles manager emails** by extracting customer info and sending personalized outreach
|
|
6234
|
+
3. **Processes customer replies** with AI-powered, context-aware responses
|
|
6235
|
+
4. **Notifies the manager** when customers show strong buying signals
|
|
6236
|
+
|
|
6237
|
+
Here's the workflow:
|
|
6238
|
+
|
|
6239
|
+
```
|
|
6240
|
+
Manager sends email with customer info
|
|
6241
|
+
↓
|
|
6242
|
+
Agent extracts customer email
|
|
6243
|
+
↓
|
|
6244
|
+
Agent generates AI sales pitch → Sends to customer
|
|
6245
|
+
↓
|
|
6246
|
+
Agent confirms to manager
|
|
6247
|
+
↓
|
|
6248
|
+
[Customer replies]
|
|
6249
|
+
↓
|
|
6250
|
+
Agent detects intent + generates AI response
|
|
6251
|
+
↓
|
|
6252
|
+
If interested → Notifies manager
|
|
6253
|
+
```
|
|
6254
|
+
|
|
6255
|
+
## WebSocket vs Webhook: Why WebSocket?
|
|
6256
|
+
|
|
6257
|
+
| Feature | Webhook Approach | WebSocket Approach |
|
|
6258
|
+
| ------------ | --------------------------- | ------------------------ |
|
|
6259
|
+
| Setup | Requires ngrok + public URL | No external tools needed |
|
|
6260
|
+
| Architecture | Flask server + HTTP | Pure async Python |
|
|
6261
|
+
| Latency | HTTP round-trip | Instant streaming |
|
|
6262
|
+
| Firewall | Must expose port | Outbound only |
|
|
6263
|
+
|
|
6264
|
+
For more details, see the [WebSocket API Reference](/api-reference/websockets) and the [Python SDK WebSocket documentation](https://github.com/agentmail-to/agentmail-python?tab=readme-ov-file#websockets).
|
|
6265
|
+
|
|
6266
|
+
## Prerequisites
|
|
6267
|
+
|
|
6268
|
+
Before you begin, make sure you have:
|
|
6269
|
+
|
|
6270
|
+
<Callout intent="info">
|
|
6271
|
+
**Required:**
|
|
6272
|
+
|
|
6273
|
+
* Python 3.11 or higher installed
|
|
6274
|
+
* An [AgentMail account](https://console.agentmail.to) and API key
|
|
6275
|
+
* An [OpenAI account](https://platform.openai.com) and API key
|
|
6276
|
+
</Callout>
|
|
6277
|
+
|
|
6278
|
+
## Project Setup
|
|
6279
|
+
|
|
6280
|
+
### Step 1: Create Project Directory
|
|
6281
|
+
|
|
6282
|
+
Create a new directory for your agent:
|
|
6283
|
+
|
|
6284
|
+
```bash
|
|
6285
|
+
mkdir sales-agent-websocket
|
|
6286
|
+
cd sales-agent-websocket
|
|
6287
|
+
```
|
|
6288
|
+
|
|
6289
|
+
### Step 2: Create the Agent Code
|
|
6290
|
+
|
|
6291
|
+
Create a file named `main.py` and paste the following code:
|
|
6292
|
+
|
|
6293
|
+
<Accordion title="Click to view full main.py code">
|
|
6294
|
+
```python
|
|
6295
|
+
"""
|
|
6296
|
+
Sales Agent using AgentMail WebSocket
|
|
6297
|
+
|
|
6298
|
+
This is a simple example showing how to:
|
|
6299
|
+
- Connect to AgentMail via WebSocket for real-time email processing
|
|
6300
|
+
- Use OpenAI to handle sales conversations
|
|
6301
|
+
- Send emails to customers and respond to replies
|
|
6302
|
+
"""
|
|
6303
|
+
|
|
6304
|
+
import asyncio
|
|
6305
|
+
import os
|
|
6306
|
+
import re
|
|
6307
|
+
from dotenv import load_dotenv
|
|
6308
|
+
from agentmail import AsyncAgentMail, Subscribe, Subscribed, MessageReceivedEvent
|
|
6309
|
+
from openai import AsyncOpenAI
|
|
6310
|
+
|
|
6311
|
+
# Load environment variables
|
|
6312
|
+
load_dotenv()
|
|
6313
|
+
|
|
6314
|
+
# Initialize clients
|
|
6315
|
+
agentmail = AsyncAgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
6316
|
+
openai = AsyncOpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
|
6317
|
+
|
|
6318
|
+
# Simple conversation history (thread_id -> messages)
|
|
6319
|
+
conversations = {}
|
|
6320
|
+
|
|
6321
|
+
# Store manager email for notifications
|
|
6322
|
+
manager_email = None
|
|
6323
|
+
|
|
6324
|
+
|
|
6325
|
+
def extract_email(from_field):
|
|
6326
|
+
"""Extract email address from 'Name <email@example.com>' format"""
|
|
6327
|
+
match = re.search(r'<(.+?)>', from_field)
|
|
6328
|
+
return match.group(1) if match else from_field
|
|
6329
|
+
|
|
6330
|
+
|
|
6331
|
+
def is_from_manager(email_body):
|
|
6332
|
+
"""Simple check if email is from sales manager (contains customer info)"""
|
|
6333
|
+
keywords = ['customer', 'lead', 'contact', 'reach out', 'email']
|
|
6334
|
+
return any(keyword in email_body.lower() for keyword in keywords)
|
|
6335
|
+
|
|
6336
|
+
|
|
6337
|
+
def extract_customer_info(email_body):
|
|
6338
|
+
"""Extract customer email from manager's message"""
|
|
6339
|
+
email_pattern = r'\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b'
|
|
6340
|
+
emails = re.findall(email_pattern, email_body)
|
|
6341
|
+
|
|
6342
|
+
# Return the first email found (should be the customer's email in the message body)
|
|
6343
|
+
if emails:
|
|
6344
|
+
return emails[0]
|
|
6345
|
+
return None
|
|
6346
|
+
|
|
6347
|
+
|
|
6348
|
+
async def get_ai_response(messages, system_prompt):
|
|
6349
|
+
"""Get response from OpenAI"""
|
|
6350
|
+
try:
|
|
6351
|
+
response = await openai.chat.completions.create(
|
|
6352
|
+
model="gpt-4o-mini",
|
|
6353
|
+
messages=[
|
|
6354
|
+
{"role": "system", "content": system_prompt},
|
|
6355
|
+
*messages
|
|
6356
|
+
],
|
|
6357
|
+
temperature=0.7,
|
|
6358
|
+
)
|
|
6359
|
+
return response.choices[0].message.content
|
|
6360
|
+
except Exception as e:
|
|
6361
|
+
print(f"Error getting AI response: {e}")
|
|
6362
|
+
return "I apologize, but I encountered an error. Please try again."
|
|
6363
|
+
|
|
6364
|
+
|
|
6365
|
+
async def send_email(inbox_id, to_email, subject, body):
|
|
6366
|
+
"""Send a new email"""
|
|
6367
|
+
try:
|
|
6368
|
+
await agentmail.inboxes.messages.send(
|
|
6369
|
+
inbox_id=inbox_id,
|
|
6370
|
+
to=[to_email],
|
|
6371
|
+
subject=subject,
|
|
6372
|
+
text=body
|
|
6373
|
+
)
|
|
6374
|
+
print(f"✓ Sent email to {to_email}")
|
|
6375
|
+
except Exception as e:
|
|
6376
|
+
print(f"Error sending email: {e}")
|
|
6377
|
+
|
|
6378
|
+
|
|
6379
|
+
async def reply_to_email(inbox_id, message_id, to_email, body):
|
|
6380
|
+
"""Reply to an email"""
|
|
6381
|
+
try:
|
|
6382
|
+
await agentmail.inboxes.messages.reply(
|
|
6383
|
+
inbox_id=inbox_id,
|
|
6384
|
+
message_id=message_id,
|
|
6385
|
+
to=[to_email], # Required parameter for replies
|
|
6386
|
+
text=body
|
|
6387
|
+
)
|
|
6388
|
+
print(f"✓ Sent reply to {to_email}")
|
|
6389
|
+
except Exception as e:
|
|
6390
|
+
print(f"Error replying: {e}")
|
|
6391
|
+
|
|
6392
|
+
|
|
6393
|
+
async def handle_manager_email(inbox_id, message_id, from_email, subject, body):
|
|
6394
|
+
"""Handle email from sales manager - extract customer and send sales pitch"""
|
|
6395
|
+
global manager_email
|
|
6396
|
+
manager_email = from_email # Remember manager for future notifications
|
|
6397
|
+
|
|
6398
|
+
print(f"\n📧 Email from MANAGER: {from_email}")
|
|
6399
|
+
|
|
6400
|
+
# Extract customer email
|
|
6401
|
+
customer_email = extract_customer_info(body)
|
|
6402
|
+
print(f"→ Extracted customer email: {customer_email}")
|
|
6403
|
+
|
|
6404
|
+
if not customer_email:
|
|
6405
|
+
await reply_to_email(
|
|
6406
|
+
inbox_id,
|
|
6407
|
+
message_id,
|
|
6408
|
+
from_email, # Reply back to the manager
|
|
6409
|
+
"I couldn't find a customer email address. Please include it in your message."
|
|
6410
|
+
)
|
|
6411
|
+
return
|
|
6412
|
+
|
|
6413
|
+
# Generate sales pitch using AI
|
|
6414
|
+
system_prompt = """You are a helpful sales agent. Generate a brief, professional sales email
|
|
6415
|
+
based on the manager's request. Keep it under 150 words. Be friendly and professional."""
|
|
6416
|
+
|
|
6417
|
+
messages = [{"role": "user", "content": f"Create a sales email based on this: {body}"}]
|
|
6418
|
+
sales_pitch = await get_ai_response(messages, system_prompt)
|
|
6419
|
+
|
|
6420
|
+
# Send email to customer
|
|
6421
|
+
await send_email(
|
|
6422
|
+
inbox_id,
|
|
6423
|
+
customer_email,
|
|
6424
|
+
f"Introduction: {subject}" if subject else "Quick Introduction",
|
|
6425
|
+
sales_pitch
|
|
6426
|
+
)
|
|
6427
|
+
|
|
6428
|
+
# Confirm to manager
|
|
6429
|
+
await reply_to_email(
|
|
6430
|
+
inbox_id,
|
|
6431
|
+
message_id,
|
|
6432
|
+
from_email, # Reply back to the manager
|
|
6433
|
+
f"✓ I've sent an introduction email to {customer_email}.\n\nHere's what I sent:\n\n{sales_pitch}"
|
|
6434
|
+
)
|
|
6435
|
+
|
|
6436
|
+
|
|
6437
|
+
async def handle_customer_email(inbox_id, message_id, thread_id, from_email, subject, body):
|
|
6438
|
+
"""Handle email from customer - track conversation, detect intent, and notify manager"""
|
|
6439
|
+
print(f"\n📧 Email from CUSTOMER: {from_email}")
|
|
6440
|
+
|
|
6441
|
+
# Track conversation history
|
|
6442
|
+
if thread_id not in conversations:
|
|
6443
|
+
conversations[thread_id] = []
|
|
6444
|
+
conversations[thread_id].append({"role": "user", "content": body})
|
|
6445
|
+
|
|
6446
|
+
# Detect customer intent
|
|
6447
|
+
intent_keywords = {
|
|
6448
|
+
'interested': ['interested', 'demo', 'meeting', 'tell me more', 'sounds good'],
|
|
6449
|
+
'not_interested': ['not interested', 'no thank', 'not right now', 'maybe later'],
|
|
6450
|
+
'question': ['?', 'how', 'what', 'when', 'why', 'can you']
|
|
6451
|
+
}
|
|
6452
|
+
|
|
6453
|
+
body_lower = body.lower()
|
|
6454
|
+
intent = 'question' # default
|
|
6455
|
+
for key, keywords in intent_keywords.items():
|
|
6456
|
+
if any(keyword in body_lower for keyword in keywords):
|
|
6457
|
+
intent = key
|
|
6458
|
+
break
|
|
6459
|
+
|
|
6460
|
+
# Generate AI response
|
|
6461
|
+
system_prompt = """You are a helpful sales agent. Answer customer questions professionally
|
|
6462
|
+
and helpfully. Keep responses brief (under 100 words). Be friendly but professional."""
|
|
6463
|
+
|
|
6464
|
+
response = await get_ai_response(conversations[thread_id], system_prompt)
|
|
6465
|
+
|
|
6466
|
+
# Reply to customer
|
|
6467
|
+
await reply_to_email(inbox_id, message_id, from_email, response)
|
|
6468
|
+
|
|
6469
|
+
# Notify manager if strong intent signal
|
|
6470
|
+
if manager_email and intent in ['interested', 'not_interested']:
|
|
6471
|
+
status = "showing interest" if intent == 'interested' else "not interested at this time"
|
|
6472
|
+
await send_email(
|
|
6473
|
+
inbox_id,
|
|
6474
|
+
manager_email,
|
|
6475
|
+
f"Update: {from_email}",
|
|
6476
|
+
f"Customer {from_email} is {status}.\n\nTheir message:\n{body}\n\nMy response:\n{response}"
|
|
6477
|
+
)
|
|
6478
|
+
print(f"→ Notified manager about customer's {intent}")
|
|
6479
|
+
|
|
6480
|
+
# Update conversation history
|
|
6481
|
+
conversations[thread_id].append({"role": "assistant", "content": response})
|
|
6482
|
+
|
|
6483
|
+
|
|
6484
|
+
async def handle_new_email(message):
|
|
6485
|
+
"""Process incoming email from WebSocket"""
|
|
6486
|
+
try:
|
|
6487
|
+
# Extract message data using object attributes
|
|
6488
|
+
inbox_id = message.inbox_id
|
|
6489
|
+
message_id = message.message_id
|
|
6490
|
+
thread_id = message.thread_id
|
|
6491
|
+
from_field = message.from_ or "" # SDK uses from_
|
|
6492
|
+
from_email = extract_email(from_field)
|
|
6493
|
+
subject = message.subject or ""
|
|
6494
|
+
body = message.text or "" # SDK uses text for the body
|
|
6495
|
+
|
|
6496
|
+
print(f"\n{'='*60}")
|
|
6497
|
+
print(f"New email from: {from_email}")
|
|
6498
|
+
print(f"Subject: {subject}")
|
|
6499
|
+
print(f"{'='*60}")
|
|
6500
|
+
|
|
6501
|
+
# Determine if from manager or customer
|
|
6502
|
+
if is_from_manager(body):
|
|
6503
|
+
await handle_manager_email(inbox_id, message_id, from_email, subject, body)
|
|
6504
|
+
else:
|
|
6505
|
+
await handle_customer_email(inbox_id, message_id, thread_id, from_email, subject, body)
|
|
6506
|
+
|
|
6507
|
+
except Exception as e:
|
|
6508
|
+
print(f"Error handling email: {e}")
|
|
6509
|
+
|
|
6510
|
+
|
|
6511
|
+
async def main():
|
|
6512
|
+
"""Main WebSocket loop"""
|
|
6513
|
+
inbox_username = os.getenv("INBOX_USERNAME", "sales-agent")
|
|
6514
|
+
inbox_id = f"{inbox_username}@agentmail.to"
|
|
6515
|
+
|
|
6516
|
+
print(f"\nSales Agent starting...")
|
|
6517
|
+
print(f"Inbox: {inbox_id}")
|
|
6518
|
+
print(f"✓ Connecting to AgentMail WebSocket...")
|
|
6519
|
+
|
|
6520
|
+
# Connect to WebSocket
|
|
6521
|
+
try:
|
|
6522
|
+
async with agentmail.websockets.connect() as socket:
|
|
6523
|
+
print(f"✓ Connected! Listening for emails...\n")
|
|
6524
|
+
|
|
6525
|
+
# Subscribe to inbox
|
|
6526
|
+
await socket.send_subscribe(Subscribe(inbox_ids=[inbox_id]))
|
|
6527
|
+
|
|
6528
|
+
# Listen for events
|
|
6529
|
+
async for event in socket:
|
|
6530
|
+
if isinstance(event, Subscribed):
|
|
6531
|
+
print(f"✓ Subscribed to: {event.inbox_ids}\n")
|
|
6532
|
+
|
|
6533
|
+
elif isinstance(event, MessageReceivedEvent):
|
|
6534
|
+
print(f"📨 New email received!")
|
|
6535
|
+
await handle_new_email(event.message)
|
|
6536
|
+
|
|
6537
|
+
except (KeyboardInterrupt, asyncio.CancelledError):
|
|
6538
|
+
print("\n\nShutting down gracefully...")
|
|
6539
|
+
except Exception as e:
|
|
6540
|
+
print(f"\nError: {e}")
|
|
6541
|
+
|
|
6542
|
+
|
|
6543
|
+
def run():
|
|
6544
|
+
"""Run the main function"""
|
|
6545
|
+
try:
|
|
6546
|
+
asyncio.run(main())
|
|
6547
|
+
except KeyboardInterrupt:
|
|
6548
|
+
print("\n✓ Shutdown complete")
|
|
6549
|
+
|
|
6550
|
+
|
|
6551
|
+
if __name__ == "__main__":
|
|
6552
|
+
run()
|
|
6553
|
+
```
|
|
6554
|
+
</Accordion>
|
|
6555
|
+
|
|
6556
|
+
### Step 3: Create Requirements File
|
|
6557
|
+
|
|
6558
|
+
Create a file named `requirements.txt`:
|
|
6559
|
+
|
|
6560
|
+
```txt
|
|
6561
|
+
agentmail>=0.0.19
|
|
6562
|
+
openai>=1.0.0
|
|
6563
|
+
python-dotenv>=1.0.0
|
|
6564
|
+
```
|
|
6565
|
+
|
|
6566
|
+
### Step 4: Install Dependencies
|
|
6567
|
+
|
|
6568
|
+
Install the required Python packages:
|
|
6569
|
+
|
|
6570
|
+
```bash
|
|
6571
|
+
pip install -r requirements.txt
|
|
6572
|
+
# or with pyproject.toml
|
|
6573
|
+
pip install .
|
|
6574
|
+
```
|
|
6575
|
+
|
|
6576
|
+
### Step 5: Configure Environment Variables
|
|
6577
|
+
|
|
6578
|
+
Create a `.env` file with your credentials:
|
|
6579
|
+
|
|
6580
|
+
```env
|
|
6581
|
+
# AgentMail Configuration
|
|
6582
|
+
AGENTMAIL_API_KEY=your_agentmail_api_key_here
|
|
6583
|
+
|
|
6584
|
+
# OpenAI Configuration
|
|
6585
|
+
OPENAI_API_KEY=your_openai_api_key_here
|
|
6586
|
+
|
|
6587
|
+
# Inbox Settings
|
|
6588
|
+
INBOX_USERNAME=sales-agent
|
|
6589
|
+
```
|
|
6590
|
+
|
|
6591
|
+
<Callout intent="info">
|
|
6592
|
+
**Note:** Unlike webhook-based agents, you don't need ngrok or a public URL. The WebSocket connection is outbound only, so it works behind firewalls without any port forwarding.
|
|
6593
|
+
</Callout>
|
|
6594
|
+
|
|
6595
|
+
## Code Walkthrough
|
|
6596
|
+
|
|
6597
|
+
Let's understand how the agent works by breaking down the key components.
|
|
6598
|
+
|
|
6599
|
+
### Architecture Overview
|
|
6600
|
+
|
|
6601
|
+
```
|
|
6602
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
6603
|
+
│ Your Python Script │
|
|
6604
|
+
│ │
|
|
6605
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌─────────────┐ │
|
|
6606
|
+
│ │ AsyncAgent │────▶│ WebSocket │────▶│ Event │ │
|
|
6607
|
+
│ │ Mail Client │ │ Connection │ │ Handler │ │
|
|
6608
|
+
│ └──────────────┘ └──────────────┘ └─────────────┘ │
|
|
6609
|
+
│ │ ▲ │ │
|
|
6610
|
+
│ │ │ ▼ │
|
|
6611
|
+
│ │ Real-time ┌─────────────┐ │
|
|
6612
|
+
│ │ Events │ OpenAI │ │
|
|
6613
|
+
│ │ │ Integration │ │
|
|
6614
|
+
│ ▼ └─────────────┘ │
|
|
6615
|
+
│ ┌──────────────┐ │
|
|
6616
|
+
│ │ Send/Reply │◀──────────────────────────────────────────│
|
|
6617
|
+
│ │ Emails │ │
|
|
6618
|
+
│ └──────────────┘ │
|
|
6619
|
+
└─────────────────────────────────────────────────────────────┘
|
|
6620
|
+
│
|
|
6621
|
+
▼
|
|
6622
|
+
┌──────────────────┐
|
|
6623
|
+
│ AgentMail │
|
|
6624
|
+
│ Cloud │
|
|
6625
|
+
└──────────────────┘
|
|
6626
|
+
```
|
|
6627
|
+
|
|
6628
|
+
### 1. WebSocket Connection Setup
|
|
6629
|
+
|
|
6630
|
+
The core of this agent is the WebSocket connection:
|
|
6631
|
+
|
|
6632
|
+
```python
|
|
6633
|
+
from agentmail import AsyncAgentMail, Subscribe, Subscribed, MessageReceivedEvent
|
|
6634
|
+
|
|
6635
|
+
# Initialize the async client
|
|
6636
|
+
agentmail = AsyncAgentMail(api_key=os.getenv("AGENTMAIL_API_KEY"))
|
|
6637
|
+
|
|
6638
|
+
# Connect and subscribe
|
|
6639
|
+
async with agentmail.websockets.connect() as socket:
|
|
6640
|
+
await socket.send_subscribe(Subscribe(inbox_ids=[inbox_id]))
|
|
6641
|
+
```
|
|
6642
|
+
|
|
6643
|
+
**Key points:**
|
|
6644
|
+
|
|
6645
|
+
* `AsyncAgentMail` is the async version of the client
|
|
6646
|
+
* `agentmail.websockets.connect()` creates the WebSocket connection
|
|
6647
|
+
* `Subscribe` specifies which inboxes to monitor
|
|
6648
|
+
|
|
6649
|
+
### 2. Event Handling Loop
|
|
6650
|
+
|
|
6651
|
+
The agent uses an async iterator pattern to process events:
|
|
6652
|
+
|
|
6653
|
+
```python
|
|
6654
|
+
async for event in socket:
|
|
6655
|
+
if isinstance(event, Subscribed):
|
|
6656
|
+
print(f"✓ Subscribed to: {event.inbox_ids}")
|
|
6657
|
+
|
|
6658
|
+
elif isinstance(event, MessageReceivedEvent):
|
|
6659
|
+
await handle_new_email(event.message)
|
|
6660
|
+
```
|
|
6661
|
+
|
|
6662
|
+
**Event types:**
|
|
6663
|
+
|
|
6664
|
+
* `Subscribed` - Confirmation that subscription was successful
|
|
6665
|
+
* `MessageReceivedEvent` - A new email arrived in the inbox
|
|
6666
|
+
|
|
6667
|
+
### 3. Email Processing Flow
|
|
6668
|
+
|
|
6669
|
+
The agent routes emails based on content:
|
|
6670
|
+
|
|
6671
|
+
```python
|
|
6672
|
+
async def handle_new_email(message):
|
|
6673
|
+
# Extract fields from the message object
|
|
6674
|
+
inbox_id = message.inbox_id
|
|
6675
|
+
message_id = message.message_id
|
|
6676
|
+
thread_id = message.thread_id
|
|
6677
|
+
from_field = message.from_ or "" # Note: SDK uses from_
|
|
6678
|
+
from_email = extract_email(from_field)
|
|
6679
|
+
subject = message.subject or ""
|
|
6680
|
+
body = message.text or ""
|
|
6681
|
+
|
|
6682
|
+
# Route based on email content
|
|
6683
|
+
if is_from_manager(body):
|
|
6684
|
+
await handle_manager_email(inbox_id, message_id, from_email, subject, body)
|
|
6685
|
+
else:
|
|
6686
|
+
await handle_customer_email(inbox_id, message_id, thread_id, from_email, subject, body)
|
|
6687
|
+
```
|
|
6688
|
+
|
|
6689
|
+
**Email extraction helper:**
|
|
6690
|
+
|
|
6691
|
+
```python
|
|
6692
|
+
def extract_email(from_field):
|
|
6693
|
+
"""Extract email from 'Name <email@example.com>' format"""
|
|
6694
|
+
match = re.search(r'<(.+?)>', from_field)
|
|
6695
|
+
return match.group(1) if match else from_field
|
|
6696
|
+
```
|
|
6697
|
+
|
|
6698
|
+
### 4. Manager Email Handler
|
|
6699
|
+
|
|
6700
|
+
When the manager sends an email with customer info:
|
|
6701
|
+
|
|
6702
|
+
```python
|
|
6703
|
+
async def handle_manager_email(inbox_id, message_id, from_email, subject, body):
|
|
6704
|
+
global manager_email
|
|
6705
|
+
manager_email = from_email # Remember for notifications
|
|
6706
|
+
|
|
6707
|
+
# Extract customer email using regex
|
|
6708
|
+
customer_email = extract_customer_info(body)
|
|
6709
|
+
|
|
6710
|
+
if not customer_email:
|
|
6711
|
+
await reply_to_email(inbox_id, message_id, from_email,
|
|
6712
|
+
"I couldn't find a customer email. Please include it.")
|
|
6713
|
+
return
|
|
6714
|
+
|
|
6715
|
+
# Generate AI sales pitch
|
|
6716
|
+
sales_pitch = await get_ai_response(
|
|
6717
|
+
[{"role": "user", "content": f"Create a sales email based on: {body}"}],
|
|
6718
|
+
"You are a helpful sales agent. Generate a brief, professional email..."
|
|
6719
|
+
)
|
|
6720
|
+
|
|
6721
|
+
# Send to customer
|
|
6722
|
+
await send_email(inbox_id, customer_email, f"Introduction: {subject}", sales_pitch)
|
|
6723
|
+
|
|
6724
|
+
# Confirm to manager
|
|
6725
|
+
await reply_to_email(inbox_id, message_id, from_email,
|
|
6726
|
+
f"✓ Sent email to {customer_email}.\n\nContent:\n{sales_pitch}")
|
|
6727
|
+
```
|
|
6728
|
+
|
|
6729
|
+
### 5. Customer Email Handler with Intent Detection
|
|
6730
|
+
|
|
6731
|
+
The agent tracks conversations and detects customer intent:
|
|
6732
|
+
|
|
6733
|
+
```python
|
|
6734
|
+
async def handle_customer_email(inbox_id, message_id, thread_id, from_email, subject, body):
|
|
6735
|
+
# Track conversation history per thread
|
|
6736
|
+
if thread_id not in conversations:
|
|
6737
|
+
conversations[thread_id] = []
|
|
6738
|
+
conversations[thread_id].append({"role": "user", "content": body})
|
|
6739
|
+
|
|
6740
|
+
# Detect intent with keyword matching
|
|
6741
|
+
intent_keywords = {
|
|
6742
|
+
'interested': ['interested', 'demo', 'meeting', 'tell me more'],
|
|
6743
|
+
'not_interested': ['not interested', 'no thank', 'maybe later'],
|
|
6744
|
+
'question': ['?', 'how', 'what', 'when', 'why']
|
|
6745
|
+
}
|
|
6746
|
+
|
|
6747
|
+
intent = 'question' # default
|
|
6748
|
+
for key, keywords in intent_keywords.items():
|
|
6749
|
+
if any(kw in body.lower() for kw in keywords):
|
|
6750
|
+
intent = key
|
|
6751
|
+
break
|
|
6752
|
+
|
|
6753
|
+
# Generate contextual AI response using conversation history
|
|
6754
|
+
response = await get_ai_response(conversations[thread_id], system_prompt)
|
|
6755
|
+
|
|
6756
|
+
# Reply to customer
|
|
6757
|
+
await reply_to_email(inbox_id, message_id, from_email, response)
|
|
6758
|
+
|
|
6759
|
+
# Notify manager of strong signals
|
|
6760
|
+
if manager_email and intent in ['interested', 'not_interested']:
|
|
6761
|
+
await send_email(inbox_id, manager_email, f"Update: {from_email}",
|
|
6762
|
+
f"Customer is {intent}.\n\nTheir message:\n{body}")
|
|
6763
|
+
```
|
|
6764
|
+
|
|
6765
|
+
### 6. AI Response Generation
|
|
6766
|
+
|
|
6767
|
+
The agent uses OpenAI for generating responses:
|
|
6768
|
+
|
|
6769
|
+
```python
|
|
6770
|
+
async def get_ai_response(messages, system_prompt):
|
|
6771
|
+
try:
|
|
6772
|
+
response = await openai.chat.completions.create(
|
|
6773
|
+
model="gpt-4o-mini",
|
|
6774
|
+
messages=[
|
|
6775
|
+
{"role": "system", "content": system_prompt},
|
|
6776
|
+
*messages # Include conversation history
|
|
6777
|
+
],
|
|
6778
|
+
temperature=0.7,
|
|
6779
|
+
)
|
|
6780
|
+
return response.choices[0].message.content
|
|
6781
|
+
except Exception as e:
|
|
6782
|
+
print(f"Error: {e}")
|
|
6783
|
+
return "I apologize, but I encountered an error."
|
|
6784
|
+
```
|
|
6785
|
+
|
|
6786
|
+
**Key points:**
|
|
6787
|
+
|
|
6788
|
+
* Includes full conversation history for context
|
|
6789
|
+
* Graceful error handling with fallback message
|
|
6790
|
+
|
|
6791
|
+
## Running the Agent
|
|
6792
|
+
|
|
6793
|
+
Start the agent:
|
|
6794
|
+
|
|
6795
|
+
```bash
|
|
6796
|
+
python main.py
|
|
6797
|
+
```
|
|
6798
|
+
|
|
6799
|
+
You should see output like this:
|
|
6800
|
+
|
|
6801
|
+
```
|
|
6802
|
+
Sales Agent starting...
|
|
6803
|
+
Inbox: sales-agent@agentmail.to
|
|
6804
|
+
✓ Connecting to AgentMail WebSocket...
|
|
6805
|
+
✓ Connected! Listening for emails...
|
|
6806
|
+
|
|
6807
|
+
✓ Subscribed to: ['sales-agent@agentmail.to']
|
|
6808
|
+
```
|
|
6809
|
+
|
|
6810
|
+
<Callout intent="success">
|
|
6811
|
+
**Success!** Your agent is now running and listening for emails in real-time.
|
|
6812
|
+
|
|
6813
|
+
Leave this terminal window open - closing it will stop the agent.
|
|
6814
|
+
</Callout>
|
|
6815
|
+
|
|
6816
|
+
## Testing Your Agent
|
|
6817
|
+
|
|
6818
|
+
Let's verify everything works with some test scenarios.
|
|
6819
|
+
|
|
6820
|
+
### Test Scenario: Manager Outreach Request
|
|
6821
|
+
|
|
6822
|
+
**Send this email from your personal email:**
|
|
6823
|
+
|
|
6824
|
+
```
|
|
6825
|
+
To: sales-agent@agentmail.to
|
|
6826
|
+
Subject: New lead - AI startup
|
|
6827
|
+
Body: Please reach out to this customer: customer-email@gmail.com
|
|
6828
|
+
They're interested in our API platform.
|
|
6829
|
+
```
|
|
6830
|
+
|
|
6831
|
+
**Expected console output:**
|
|
6832
|
+
|
|
6833
|
+
```
|
|
6834
|
+
============================================================
|
|
6835
|
+
New email from: your-email@gmail.com
|
|
6836
|
+
Subject: New lead - AI startup
|
|
6837
|
+
============================================================
|
|
6838
|
+
|
|
6839
|
+
📧 Email from MANAGER: your-email@gmail.com
|
|
6840
|
+
→ Extracted customer email: customer-email@gmail.com
|
|
6841
|
+
✓ Sent email to customer-email@gmail.com
|
|
6842
|
+
✓ Sent reply to your-email@gmail.com
|
|
6843
|
+
```
|
|
6844
|
+
|
|
6845
|
+
**You'll receive:** A confirmation email with the sales pitch that was sent.
|
|
6846
|
+
|
|
6847
|
+
<Callout intent="success">
|
|
6848
|
+
**It works!** The agent processed emails in real-time, generated AI responses, and notified you about the interested customer.
|
|
6849
|
+
</Callout>
|
|
6850
|
+
|
|
6851
|
+
## Customization
|
|
6852
|
+
|
|
6853
|
+
### Modifying Intent Detection
|
|
6854
|
+
|
|
6855
|
+
Update the `intent_keywords` dictionary in `handle_customer_email()`:
|
|
6856
|
+
|
|
6857
|
+
```python
|
|
6858
|
+
intent_keywords = {
|
|
6859
|
+
'interested': ['interested', 'demo', 'meeting', 'pricing', 'sign up'],
|
|
6860
|
+
'not_interested': ['not interested', 'unsubscribe', 'remove me'],
|
|
6861
|
+
'question': ['?', 'how', 'what', 'when', 'can you'],
|
|
6862
|
+
'urgent': ['urgent', 'asap', 'immediately'] # Add new intent
|
|
6863
|
+
}
|
|
6864
|
+
```
|
|
6865
|
+
|
|
6866
|
+
### Adding More Inbox Subscriptions
|
|
6867
|
+
|
|
6868
|
+
Subscribe to multiple inboxes:
|
|
6869
|
+
|
|
6870
|
+
```python
|
|
6871
|
+
await socket.send_subscribe(Subscribe(inbox_ids=[
|
|
6872
|
+
"sales-agent@agentmail.to",
|
|
6873
|
+
"support-agent@agentmail.to",
|
|
6874
|
+
"info@yourdomain.com"
|
|
6875
|
+
]))
|
|
6876
|
+
```
|
|
6877
|
+
|
|
6878
|
+
## Troubleshooting
|
|
6879
|
+
|
|
6880
|
+
### Common Issues
|
|
6881
|
+
|
|
6882
|
+
<Accordion title="WebSocket connection refused or timeout">
|
|
6883
|
+
**Problem:** Cannot connect to AgentMail WebSocket.
|
|
6884
|
+
|
|
6885
|
+
**Solutions:**
|
|
6886
|
+
|
|
6887
|
+
1. Verify your API key is correct:
|
|
6888
|
+
|
|
6889
|
+
```python
|
|
6890
|
+
client = AsyncAgentMail(api_key="your-key")
|
|
6891
|
+
print(await client.inboxes.list()) # Should succeed
|
|
6892
|
+
```
|
|
6893
|
+
|
|
6894
|
+
2. Check your internet connection and firewall settings
|
|
6895
|
+
3. Ensure you're using `agentmail>=0.0.19` which includes WebSocket support:
|
|
6896
|
+
|
|
6897
|
+
```bash
|
|
6898
|
+
pip show agentmail
|
|
6899
|
+
```
|
|
6900
|
+
</Accordion>
|
|
6901
|
+
|
|
6902
|
+
<Accordion title="Emails not being received">
|
|
6903
|
+
**Problem:** Agent is running but not receiving emails.
|
|
6904
|
+
|
|
6905
|
+
**Checklist:**
|
|
6906
|
+
|
|
6907
|
+
1. Verify the inbox exists:
|
|
6908
|
+
|
|
6909
|
+
```python
|
|
6910
|
+
client = AsyncAgentMail()
|
|
6911
|
+
print(await client.inboxes.get("sales-agent@agentmail.to"))
|
|
6912
|
+
```
|
|
6913
|
+
|
|
6914
|
+
2. Check subscription confirmation in console output
|
|
6915
|
+
3. Send test email to the correct inbox address
|
|
6916
|
+
4. Verify the email isn't being filtered as spam
|
|
6917
|
+
</Accordion>
|
|
5597
6918
|
|
|
5598
|
-
|
|
6919
|
+
<Accordion title="Agent crashes with asyncio errors">
|
|
6920
|
+
**Problem:** Async-related exceptions.
|
|
5599
6921
|
|
|
5600
|
-
|
|
6922
|
+
**Solutions:**
|
|
5601
6923
|
|
|
5602
|
-
|
|
5603
|
-
* **Volume by department**: Which team is handling the most emails?
|
|
5604
|
-
* **Response times by priority**: Are you meeting SLAs for urgent issues?
|
|
5605
|
-
* **Common categories**: What are customers asking about most?
|
|
6924
|
+
1. Ensure Python 3.11+ is installed:
|
|
5606
6925
|
|
|
5607
|
-
|
|
6926
|
+
```bash
|
|
6927
|
+
python --version
|
|
6928
|
+
```
|
|
6929
|
+
|
|
6930
|
+
2. Don't mix sync and async code improperly
|
|
6931
|
+
3. Use `asyncio.run(main())` as the entry point
|
|
6932
|
+
</Accordion>
|
|
5608
6933
|
|
|
5609
6934
|
***
|
|
5610
6935
|
|
|
5611
|
-
|
|
6936
|
+
If you build something cool with AgentMail, we'd love to hear about it. Share in our [Discord community](https://discord.gg/hTYatWYWBc)!
|
|
5612
6937
|
|
|
5613
6938
|
|
|
5614
6939
|
# Live AgentMail Examples
|
|
@@ -6662,6 +7987,7 @@ package main
|
|
|
6662
7987
|
|
|
6663
7988
|
import (
|
|
6664
7989
|
"fmt"
|
|
7990
|
+
"strings"
|
|
6665
7991
|
"net/http"
|
|
6666
7992
|
"io"
|
|
6667
7993
|
)
|
|
@@ -6670,9 +7996,12 @@ func main() {
|
|
|
6670
7996
|
|
|
6671
7997
|
url := "https://api.agentmail.to/v0/inboxes"
|
|
6672
7998
|
|
|
6673
|
-
|
|
7999
|
+
payload := strings.NewReader("{}")
|
|
8000
|
+
|
|
8001
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
6674
8002
|
|
|
6675
8003
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
8004
|
+
req.Header.Add("Content-Type", "application/json")
|
|
6676
8005
|
|
|
6677
8006
|
res, _ := http.DefaultClient.Do(req)
|
|
6678
8007
|
|
|
@@ -6696,6 +8025,8 @@ http.use_ssl = true
|
|
|
6696
8025
|
|
|
6697
8026
|
request = Net::HTTP::Get.new(url)
|
|
6698
8027
|
request["Authorization"] = 'Bearer <api_key>'
|
|
8028
|
+
request["Content-Type"] = 'application/json'
|
|
8029
|
+
request.body = "{}"
|
|
6699
8030
|
|
|
6700
8031
|
response = http.request(request)
|
|
6701
8032
|
puts response.read_body
|
|
@@ -6704,6 +8035,8 @@ puts response.read_body
|
|
|
6704
8035
|
```java
|
|
6705
8036
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes")
|
|
6706
8037
|
.header("Authorization", "Bearer <api_key>")
|
|
8038
|
+
.header("Content-Type", "application/json")
|
|
8039
|
+
.body("{}")
|
|
6707
8040
|
.asString();
|
|
6708
8041
|
```
|
|
6709
8042
|
|
|
@@ -6713,8 +8046,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
|
6713
8046
|
$client = new \GuzzleHttp\Client();
|
|
6714
8047
|
|
|
6715
8048
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes', [
|
|
8049
|
+
'body' => '{}',
|
|
6716
8050
|
'headers' => [
|
|
6717
8051
|
'Authorization' => 'Bearer <api_key>',
|
|
8052
|
+
'Content-Type' => 'application/json',
|
|
6718
8053
|
],
|
|
6719
8054
|
]);
|
|
6720
8055
|
|
|
@@ -6725,19 +8060,28 @@ echo $response->getBody();
|
|
|
6725
8060
|
var client = new RestClient("https://api.agentmail.to/v0/inboxes");
|
|
6726
8061
|
var request = new RestRequest(Method.GET);
|
|
6727
8062
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
8063
|
+
request.AddHeader("Content-Type", "application/json");
|
|
8064
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
6728
8065
|
IRestResponse response = client.Execute(request);
|
|
6729
8066
|
```
|
|
6730
8067
|
|
|
6731
8068
|
```swift
|
|
6732
8069
|
import Foundation
|
|
6733
8070
|
|
|
6734
|
-
let headers = [
|
|
8071
|
+
let headers = [
|
|
8072
|
+
"Authorization": "Bearer <api_key>",
|
|
8073
|
+
"Content-Type": "application/json"
|
|
8074
|
+
]
|
|
8075
|
+
let parameters = [] as [String : Any]
|
|
8076
|
+
|
|
8077
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
6735
8078
|
|
|
6736
8079
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes")! as URL,
|
|
6737
8080
|
cachePolicy: .useProtocolCachePolicy,
|
|
6738
8081
|
timeoutInterval: 10.0)
|
|
6739
8082
|
request.httpMethod = "GET"
|
|
6740
8083
|
request.allHTTPHeaderFields = headers
|
|
8084
|
+
request.httpBody = postData as Data
|
|
6741
8085
|
|
|
6742
8086
|
let session = URLSession.shared
|
|
6743
8087
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -6868,6 +8212,7 @@ package main
|
|
|
6868
8212
|
|
|
6869
8213
|
import (
|
|
6870
8214
|
"fmt"
|
|
8215
|
+
"strings"
|
|
6871
8216
|
"net/http"
|
|
6872
8217
|
"io"
|
|
6873
8218
|
)
|
|
@@ -6876,9 +8221,12 @@ func main() {
|
|
|
6876
8221
|
|
|
6877
8222
|
url := "https://api.agentmail.to/v0/inboxes/inbox_id"
|
|
6878
8223
|
|
|
6879
|
-
|
|
8224
|
+
payload := strings.NewReader("{}")
|
|
8225
|
+
|
|
8226
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
6880
8227
|
|
|
6881
8228
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
8229
|
+
req.Header.Add("Content-Type", "application/json")
|
|
6882
8230
|
|
|
6883
8231
|
res, _ := http.DefaultClient.Do(req)
|
|
6884
8232
|
|
|
@@ -6902,6 +8250,8 @@ http.use_ssl = true
|
|
|
6902
8250
|
|
|
6903
8251
|
request = Net::HTTP::Get.new(url)
|
|
6904
8252
|
request["Authorization"] = 'Bearer <api_key>'
|
|
8253
|
+
request["Content-Type"] = 'application/json'
|
|
8254
|
+
request.body = "{}"
|
|
6905
8255
|
|
|
6906
8256
|
response = http.request(request)
|
|
6907
8257
|
puts response.read_body
|
|
@@ -6910,6 +8260,8 @@ puts response.read_body
|
|
|
6910
8260
|
```java
|
|
6911
8261
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id")
|
|
6912
8262
|
.header("Authorization", "Bearer <api_key>")
|
|
8263
|
+
.header("Content-Type", "application/json")
|
|
8264
|
+
.body("{}")
|
|
6913
8265
|
.asString();
|
|
6914
8266
|
```
|
|
6915
8267
|
|
|
@@ -6919,8 +8271,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
|
6919
8271
|
$client = new \GuzzleHttp\Client();
|
|
6920
8272
|
|
|
6921
8273
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id', [
|
|
8274
|
+
'body' => '{}',
|
|
6922
8275
|
'headers' => [
|
|
6923
8276
|
'Authorization' => 'Bearer <api_key>',
|
|
8277
|
+
'Content-Type' => 'application/json',
|
|
6924
8278
|
],
|
|
6925
8279
|
]);
|
|
6926
8280
|
|
|
@@ -6931,19 +8285,28 @@ echo $response->getBody();
|
|
|
6931
8285
|
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id");
|
|
6932
8286
|
var request = new RestRequest(Method.GET);
|
|
6933
8287
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
8288
|
+
request.AddHeader("Content-Type", "application/json");
|
|
8289
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
6934
8290
|
IRestResponse response = client.Execute(request);
|
|
6935
8291
|
```
|
|
6936
8292
|
|
|
6937
8293
|
```swift
|
|
6938
8294
|
import Foundation
|
|
6939
8295
|
|
|
6940
|
-
let headers = [
|
|
8296
|
+
let headers = [
|
|
8297
|
+
"Authorization": "Bearer <api_key>",
|
|
8298
|
+
"Content-Type": "application/json"
|
|
8299
|
+
]
|
|
8300
|
+
let parameters = [] as [String : Any]
|
|
8301
|
+
|
|
8302
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
6941
8303
|
|
|
6942
8304
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id")! as URL,
|
|
6943
8305
|
cachePolicy: .useProtocolCachePolicy,
|
|
6944
8306
|
timeoutInterval: 10.0)
|
|
6945
8307
|
request.httpMethod = "GET"
|
|
6946
8308
|
request.allHTTPHeaderFields = headers
|
|
8309
|
+
request.httpBody = postData as Data
|
|
6947
8310
|
|
|
6948
8311
|
let session = URLSession.shared
|
|
6949
8312
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -7065,7 +8428,10 @@ async function main() {
|
|
|
7065
8428
|
environment: "https://api.agentmail.to",
|
|
7066
8429
|
apiKey: "YOUR_TOKEN_HERE",
|
|
7067
8430
|
});
|
|
7068
|
-
await client.inboxes.create(
|
|
8431
|
+
await client.inboxes.create({
|
|
8432
|
+
displayName: "Support Team Inbox",
|
|
8433
|
+
clientId: "client-abcde",
|
|
8434
|
+
});
|
|
7069
8435
|
}
|
|
7070
8436
|
main();
|
|
7071
8437
|
|
|
@@ -7079,7 +8445,10 @@ client = AgentMail(
|
|
|
7079
8445
|
api_key="YOUR_TOKEN_HERE"
|
|
7080
8446
|
)
|
|
7081
8447
|
|
|
7082
|
-
client.inboxes.create(
|
|
8448
|
+
client.inboxes.create(
|
|
8449
|
+
display_name="Support Team Inbox",
|
|
8450
|
+
client_id="client-abcde"
|
|
8451
|
+
)
|
|
7083
8452
|
|
|
7084
8453
|
```
|
|
7085
8454
|
|
|
@@ -7088,6 +8457,7 @@ package main
|
|
|
7088
8457
|
|
|
7089
8458
|
import (
|
|
7090
8459
|
"fmt"
|
|
8460
|
+
"strings"
|
|
7091
8461
|
"net/http"
|
|
7092
8462
|
"io"
|
|
7093
8463
|
)
|
|
@@ -7096,7 +8466,9 @@ func main() {
|
|
|
7096
8466
|
|
|
7097
8467
|
url := "https://api.agentmail.to/v0/inboxes"
|
|
7098
8468
|
|
|
7099
|
-
|
|
8469
|
+
payload := strings.NewReader("{\n \"display_name\": \"Support Team Inbox\",\n \"client_id\": \"client-abcde\",\n \"pod_id\": \"pod-12345\",\n \"inbox_id\": \"inbox-67890\"\n}")
|
|
8470
|
+
|
|
8471
|
+
req, _ := http.NewRequest("POST", url, payload)
|
|
7100
8472
|
|
|
7101
8473
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
7102
8474
|
req.Header.Add("Content-Type", "application/json")
|
|
@@ -7124,6 +8496,7 @@ http.use_ssl = true
|
|
|
7124
8496
|
request = Net::HTTP::Post.new(url)
|
|
7125
8497
|
request["Authorization"] = 'Bearer <api_key>'
|
|
7126
8498
|
request["Content-Type"] = 'application/json'
|
|
8499
|
+
request.body = "{\n \"display_name\": \"Support Team Inbox\",\n \"client_id\": \"client-abcde\",\n \"pod_id\": \"pod-12345\",\n \"inbox_id\": \"inbox-67890\"\n}"
|
|
7127
8500
|
|
|
7128
8501
|
response = http.request(request)
|
|
7129
8502
|
puts response.read_body
|
|
@@ -7133,6 +8506,7 @@ puts response.read_body
|
|
|
7133
8506
|
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes")
|
|
7134
8507
|
.header("Authorization", "Bearer <api_key>")
|
|
7135
8508
|
.header("Content-Type", "application/json")
|
|
8509
|
+
.body("{\n \"display_name\": \"Support Team Inbox\",\n \"client_id\": \"client-abcde\",\n \"pod_id\": \"pod-12345\",\n \"inbox_id\": \"inbox-67890\"\n}")
|
|
7136
8510
|
.asString();
|
|
7137
8511
|
```
|
|
7138
8512
|
|
|
@@ -7142,6 +8516,12 @@ HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxe
|
|
|
7142
8516
|
$client = new \GuzzleHttp\Client();
|
|
7143
8517
|
|
|
7144
8518
|
$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes', [
|
|
8519
|
+
'body' => '{
|
|
8520
|
+
"display_name": "Support Team Inbox",
|
|
8521
|
+
"client_id": "client-abcde",
|
|
8522
|
+
"pod_id": "pod-12345",
|
|
8523
|
+
"inbox_id": "inbox-67890"
|
|
8524
|
+
}',
|
|
7145
8525
|
'headers' => [
|
|
7146
8526
|
'Authorization' => 'Bearer <api_key>',
|
|
7147
8527
|
'Content-Type' => 'application/json',
|
|
@@ -7156,6 +8536,7 @@ var client = new RestClient("https://api.agentmail.to/v0/inboxes");
|
|
|
7156
8536
|
var request = new RestRequest(Method.POST);
|
|
7157
8537
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
7158
8538
|
request.AddHeader("Content-Type", "application/json");
|
|
8539
|
+
request.AddParameter("application/json", "{\n \"display_name\": \"Support Team Inbox\",\n \"client_id\": \"client-abcde\",\n \"pod_id\": \"pod-12345\",\n \"inbox_id\": \"inbox-67890\"\n}", ParameterType.RequestBody);
|
|
7159
8540
|
IRestResponse response = client.Execute(request);
|
|
7160
8541
|
```
|
|
7161
8542
|
|
|
@@ -7166,12 +8547,21 @@ let headers = [
|
|
|
7166
8547
|
"Authorization": "Bearer <api_key>",
|
|
7167
8548
|
"Content-Type": "application/json"
|
|
7168
8549
|
]
|
|
8550
|
+
let parameters = [
|
|
8551
|
+
"display_name": "Support Team Inbox",
|
|
8552
|
+
"client_id": "client-abcde",
|
|
8553
|
+
"pod_id": "pod-12345",
|
|
8554
|
+
"inbox_id": "inbox-67890"
|
|
8555
|
+
] as [String : Any]
|
|
8556
|
+
|
|
8557
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
7169
8558
|
|
|
7170
8559
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes")! as URL,
|
|
7171
8560
|
cachePolicy: .useProtocolCachePolicy,
|
|
7172
8561
|
timeoutInterval: 10.0)
|
|
7173
8562
|
request.httpMethod = "POST"
|
|
7174
8563
|
request.allHTTPHeaderFields = headers
|
|
8564
|
+
request.httpBody = postData as Data
|
|
7175
8565
|
|
|
7176
8566
|
let session = URLSession.shared
|
|
7177
8567
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -7765,7 +9155,6 @@ components:
|
|
|
7765
9155
|
required:
|
|
7766
9156
|
- attachment_id
|
|
7767
9157
|
- size
|
|
7768
|
-
- content_disposition
|
|
7769
9158
|
type_threads:ThreadAttachments:
|
|
7770
9159
|
type: array
|
|
7771
9160
|
items:
|
|
@@ -7886,6 +9275,7 @@ package main
|
|
|
7886
9275
|
|
|
7887
9276
|
import (
|
|
7888
9277
|
"fmt"
|
|
9278
|
+
"strings"
|
|
7889
9279
|
"net/http"
|
|
7890
9280
|
"io"
|
|
7891
9281
|
)
|
|
@@ -7894,9 +9284,12 @@ func main() {
|
|
|
7894
9284
|
|
|
7895
9285
|
url := "https://api.agentmail.to/v0/inboxes/inbox_id/threads"
|
|
7896
9286
|
|
|
7897
|
-
|
|
9287
|
+
payload := strings.NewReader("{}")
|
|
9288
|
+
|
|
9289
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
7898
9290
|
|
|
7899
9291
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
9292
|
+
req.Header.Add("Content-Type", "application/json")
|
|
7900
9293
|
|
|
7901
9294
|
res, _ := http.DefaultClient.Do(req)
|
|
7902
9295
|
|
|
@@ -7920,6 +9313,8 @@ http.use_ssl = true
|
|
|
7920
9313
|
|
|
7921
9314
|
request = Net::HTTP::Get.new(url)
|
|
7922
9315
|
request["Authorization"] = 'Bearer <api_key>'
|
|
9316
|
+
request["Content-Type"] = 'application/json'
|
|
9317
|
+
request.body = "{}"
|
|
7923
9318
|
|
|
7924
9319
|
response = http.request(request)
|
|
7925
9320
|
puts response.read_body
|
|
@@ -7928,6 +9323,8 @@ puts response.read_body
|
|
|
7928
9323
|
```java
|
|
7929
9324
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/threads")
|
|
7930
9325
|
.header("Authorization", "Bearer <api_key>")
|
|
9326
|
+
.header("Content-Type", "application/json")
|
|
9327
|
+
.body("{}")
|
|
7931
9328
|
.asString();
|
|
7932
9329
|
```
|
|
7933
9330
|
|
|
@@ -7937,8 +9334,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
|
7937
9334
|
$client = new \GuzzleHttp\Client();
|
|
7938
9335
|
|
|
7939
9336
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/threads', [
|
|
9337
|
+
'body' => '{}',
|
|
7940
9338
|
'headers' => [
|
|
7941
9339
|
'Authorization' => 'Bearer <api_key>',
|
|
9340
|
+
'Content-Type' => 'application/json',
|
|
7942
9341
|
],
|
|
7943
9342
|
]);
|
|
7944
9343
|
|
|
@@ -7949,19 +9348,28 @@ echo $response->getBody();
|
|
|
7949
9348
|
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/threads");
|
|
7950
9349
|
var request = new RestRequest(Method.GET);
|
|
7951
9350
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
9351
|
+
request.AddHeader("Content-Type", "application/json");
|
|
9352
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
7952
9353
|
IRestResponse response = client.Execute(request);
|
|
7953
9354
|
```
|
|
7954
9355
|
|
|
7955
9356
|
```swift
|
|
7956
9357
|
import Foundation
|
|
7957
9358
|
|
|
7958
|
-
let headers = [
|
|
9359
|
+
let headers = [
|
|
9360
|
+
"Authorization": "Bearer <api_key>",
|
|
9361
|
+
"Content-Type": "application/json"
|
|
9362
|
+
]
|
|
9363
|
+
let parameters = [] as [String : Any]
|
|
9364
|
+
|
|
9365
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
7959
9366
|
|
|
7960
9367
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/threads")! as URL,
|
|
7961
9368
|
cachePolicy: .useProtocolCachePolicy,
|
|
7962
9369
|
timeoutInterval: 10.0)
|
|
7963
9370
|
request.httpMethod = "GET"
|
|
7964
9371
|
request.allHTTPHeaderFields = headers
|
|
9372
|
+
request.httpBody = postData as Data
|
|
7965
9373
|
|
|
7966
9374
|
let session = URLSession.shared
|
|
7967
9375
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -8090,7 +9498,6 @@ components:
|
|
|
8090
9498
|
required:
|
|
8091
9499
|
- attachment_id
|
|
8092
9500
|
- size
|
|
8093
|
-
- content_disposition
|
|
8094
9501
|
type_threads:ThreadAttachments:
|
|
8095
9502
|
type: array
|
|
8096
9503
|
items:
|
|
@@ -8460,10 +9867,9 @@ paths:
|
|
|
8460
9867
|
'200':
|
|
8461
9868
|
description: Response with status 200
|
|
8462
9869
|
content:
|
|
8463
|
-
application/
|
|
9870
|
+
application/json:
|
|
8464
9871
|
schema:
|
|
8465
|
-
|
|
8466
|
-
format: binary
|
|
9872
|
+
$ref: '#/components/schemas/type_attachments:AttachmentResponse'
|
|
8467
9873
|
'404':
|
|
8468
9874
|
description: Error response with status 404
|
|
8469
9875
|
content: {}
|
|
@@ -8475,6 +9881,46 @@ components:
|
|
|
8475
9881
|
type: string
|
|
8476
9882
|
type_attachments:AttachmentId:
|
|
8477
9883
|
type: string
|
|
9884
|
+
type_attachments:AttachmentFilename:
|
|
9885
|
+
type: string
|
|
9886
|
+
type_attachments:AttachmentSize:
|
|
9887
|
+
type: integer
|
|
9888
|
+
type_attachments:AttachmentContentType:
|
|
9889
|
+
type: string
|
|
9890
|
+
type_attachments:AttachmentContentDisposition:
|
|
9891
|
+
type: string
|
|
9892
|
+
enum:
|
|
9893
|
+
- value: inline
|
|
9894
|
+
- value: attachment
|
|
9895
|
+
type_attachments:AttachmentContentId:
|
|
9896
|
+
type: string
|
|
9897
|
+
type_attachments:AttachmentResponse:
|
|
9898
|
+
type: object
|
|
9899
|
+
properties:
|
|
9900
|
+
attachment_id:
|
|
9901
|
+
$ref: '#/components/schemas/type_attachments:AttachmentId'
|
|
9902
|
+
filename:
|
|
9903
|
+
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
|
|
9904
|
+
size:
|
|
9905
|
+
$ref: '#/components/schemas/type_attachments:AttachmentSize'
|
|
9906
|
+
content_type:
|
|
9907
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
|
|
9908
|
+
content_disposition:
|
|
9909
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
|
|
9910
|
+
content_id:
|
|
9911
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
|
|
9912
|
+
download_url:
|
|
9913
|
+
type: string
|
|
9914
|
+
description: URL to download the attachment.
|
|
9915
|
+
expires_at:
|
|
9916
|
+
type: string
|
|
9917
|
+
format: date-time
|
|
9918
|
+
description: Time at which the download URL expires.
|
|
9919
|
+
required:
|
|
9920
|
+
- attachment_id
|
|
9921
|
+
- size
|
|
9922
|
+
- download_url
|
|
9923
|
+
- expires_at
|
|
8478
9924
|
|
|
8479
9925
|
```
|
|
8480
9926
|
|
|
@@ -8488,7 +9934,7 @@ async function main() {
|
|
|
8488
9934
|
environment: "https://api.agentmail.to",
|
|
8489
9935
|
apiKey: "YOUR_TOKEN_HERE",
|
|
8490
9936
|
});
|
|
8491
|
-
await client.inboxes.threads.getAttachment("
|
|
9937
|
+
await client.inboxes.threads.getAttachment("inbox_id", "thread_id", "attachment_id");
|
|
8492
9938
|
}
|
|
8493
9939
|
main();
|
|
8494
9940
|
|
|
@@ -8503,9 +9949,9 @@ client = AgentMail(
|
|
|
8503
9949
|
)
|
|
8504
9950
|
|
|
8505
9951
|
client.inboxes.threads.get_attachment(
|
|
8506
|
-
inbox_id="
|
|
8507
|
-
thread_id="
|
|
8508
|
-
attachment_id="
|
|
9952
|
+
inbox_id="inbox_id",
|
|
9953
|
+
thread_id="thread_id",
|
|
9954
|
+
attachment_id="attachment_id"
|
|
8509
9955
|
)
|
|
8510
9956
|
|
|
8511
9957
|
```
|
|
@@ -8521,7 +9967,7 @@ import (
|
|
|
8521
9967
|
|
|
8522
9968
|
func main() {
|
|
8523
9969
|
|
|
8524
|
-
url := "https://api.agentmail.to/v0/inboxes
|
|
9970
|
+
url := "https://api.agentmail.to/v0/inboxes/inbox_id/threads/thread_id/attachments/attachment_id"
|
|
8525
9971
|
|
|
8526
9972
|
req, _ := http.NewRequest("GET", url, nil)
|
|
8527
9973
|
|
|
@@ -8542,7 +9988,7 @@ func main() {
|
|
|
8542
9988
|
require 'uri'
|
|
8543
9989
|
require 'net/http'
|
|
8544
9990
|
|
|
8545
|
-
url = URI("https://api.agentmail.to/v0/inboxes
|
|
9991
|
+
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/threads/thread_id/attachments/attachment_id")
|
|
8546
9992
|
|
|
8547
9993
|
http = Net::HTTP.new(url.host, url.port)
|
|
8548
9994
|
http.use_ssl = true
|
|
@@ -8555,7 +10001,7 @@ puts response.read_body
|
|
|
8555
10001
|
```
|
|
8556
10002
|
|
|
8557
10003
|
```java
|
|
8558
|
-
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
10004
|
+
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/threads/thread_id/attachments/attachment_id")
|
|
8559
10005
|
.header("Authorization", "Bearer <api_key>")
|
|
8560
10006
|
.asString();
|
|
8561
10007
|
```
|
|
@@ -8565,7 +10011,7 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
|
8565
10011
|
|
|
8566
10012
|
$client = new \GuzzleHttp\Client();
|
|
8567
10013
|
|
|
8568
|
-
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes
|
|
10014
|
+
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/threads/thread_id/attachments/attachment_id', [
|
|
8569
10015
|
'headers' => [
|
|
8570
10016
|
'Authorization' => 'Bearer <api_key>',
|
|
8571
10017
|
],
|
|
@@ -8575,7 +10021,7 @@ echo $response->getBody();
|
|
|
8575
10021
|
```
|
|
8576
10022
|
|
|
8577
10023
|
```csharp
|
|
8578
|
-
var client = new RestClient("https://api.agentmail.to/v0/inboxes
|
|
10024
|
+
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/threads/thread_id/attachments/attachment_id");
|
|
8579
10025
|
var request = new RestRequest(Method.GET);
|
|
8580
10026
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
8581
10027
|
IRestResponse response = client.Execute(request);
|
|
@@ -8586,7 +10032,7 @@ import Foundation
|
|
|
8586
10032
|
|
|
8587
10033
|
let headers = ["Authorization": "Bearer <api_key>"]
|
|
8588
10034
|
|
|
8589
|
-
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes
|
|
10035
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/threads/thread_id/attachments/attachment_id")! as URL,
|
|
8590
10036
|
cachePolicy: .useProtocolCachePolicy,
|
|
8591
10037
|
timeoutInterval: 10.0)
|
|
8592
10038
|
request.httpMethod = "GET"
|
|
@@ -8952,7 +10398,6 @@ components:
|
|
|
8952
10398
|
required:
|
|
8953
10399
|
- attachment_id
|
|
8954
10400
|
- size
|
|
8955
|
-
- content_disposition
|
|
8956
10401
|
type_messages:MessageAttachments:
|
|
8957
10402
|
type: array
|
|
8958
10403
|
items:
|
|
@@ -9290,7 +10735,6 @@ components:
|
|
|
9290
10735
|
required:
|
|
9291
10736
|
- attachment_id
|
|
9292
10737
|
- size
|
|
9293
|
-
- content_disposition
|
|
9294
10738
|
type_messages:MessageAttachments:
|
|
9295
10739
|
type: array
|
|
9296
10740
|
items:
|
|
@@ -9558,10 +11002,9 @@ paths:
|
|
|
9558
11002
|
'200':
|
|
9559
11003
|
description: Response with status 200
|
|
9560
11004
|
content:
|
|
9561
|
-
application/
|
|
11005
|
+
application/json:
|
|
9562
11006
|
schema:
|
|
9563
|
-
|
|
9564
|
-
format: binary
|
|
11007
|
+
$ref: '#/components/schemas/type_attachments:AttachmentResponse'
|
|
9565
11008
|
'404':
|
|
9566
11009
|
description: Error response with status 404
|
|
9567
11010
|
content: {}
|
|
@@ -9573,6 +11016,46 @@ components:
|
|
|
9573
11016
|
type: string
|
|
9574
11017
|
type_attachments:AttachmentId:
|
|
9575
11018
|
type: string
|
|
11019
|
+
type_attachments:AttachmentFilename:
|
|
11020
|
+
type: string
|
|
11021
|
+
type_attachments:AttachmentSize:
|
|
11022
|
+
type: integer
|
|
11023
|
+
type_attachments:AttachmentContentType:
|
|
11024
|
+
type: string
|
|
11025
|
+
type_attachments:AttachmentContentDisposition:
|
|
11026
|
+
type: string
|
|
11027
|
+
enum:
|
|
11028
|
+
- value: inline
|
|
11029
|
+
- value: attachment
|
|
11030
|
+
type_attachments:AttachmentContentId:
|
|
11031
|
+
type: string
|
|
11032
|
+
type_attachments:AttachmentResponse:
|
|
11033
|
+
type: object
|
|
11034
|
+
properties:
|
|
11035
|
+
attachment_id:
|
|
11036
|
+
$ref: '#/components/schemas/type_attachments:AttachmentId'
|
|
11037
|
+
filename:
|
|
11038
|
+
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
|
|
11039
|
+
size:
|
|
11040
|
+
$ref: '#/components/schemas/type_attachments:AttachmentSize'
|
|
11041
|
+
content_type:
|
|
11042
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
|
|
11043
|
+
content_disposition:
|
|
11044
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
|
|
11045
|
+
content_id:
|
|
11046
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
|
|
11047
|
+
download_url:
|
|
11048
|
+
type: string
|
|
11049
|
+
description: URL to download the attachment.
|
|
11050
|
+
expires_at:
|
|
11051
|
+
type: string
|
|
11052
|
+
format: date-time
|
|
11053
|
+
description: Time at which the download URL expires.
|
|
11054
|
+
required:
|
|
11055
|
+
- attachment_id
|
|
11056
|
+
- size
|
|
11057
|
+
- download_url
|
|
11058
|
+
- expires_at
|
|
9576
11059
|
|
|
9577
11060
|
```
|
|
9578
11061
|
|
|
@@ -9586,7 +11069,7 @@ async function main() {
|
|
|
9586
11069
|
environment: "https://api.agentmail.to",
|
|
9587
11070
|
apiKey: "YOUR_TOKEN_HERE",
|
|
9588
11071
|
});
|
|
9589
|
-
await client.inboxes.messages.getAttachment("
|
|
11072
|
+
await client.inboxes.messages.getAttachment("inbox_id", "message_id", "attachment_id");
|
|
9590
11073
|
}
|
|
9591
11074
|
main();
|
|
9592
11075
|
|
|
@@ -9601,9 +11084,9 @@ client = AgentMail(
|
|
|
9601
11084
|
)
|
|
9602
11085
|
|
|
9603
11086
|
client.inboxes.messages.get_attachment(
|
|
9604
|
-
inbox_id="
|
|
9605
|
-
message_id="
|
|
9606
|
-
attachment_id="
|
|
11087
|
+
inbox_id="inbox_id",
|
|
11088
|
+
message_id="message_id",
|
|
11089
|
+
attachment_id="attachment_id"
|
|
9607
11090
|
)
|
|
9608
11091
|
|
|
9609
11092
|
```
|
|
@@ -9619,7 +11102,7 @@ import (
|
|
|
9619
11102
|
|
|
9620
11103
|
func main() {
|
|
9621
11104
|
|
|
9622
|
-
url := "https://api.agentmail.to/v0/inboxes
|
|
11105
|
+
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id"
|
|
9623
11106
|
|
|
9624
11107
|
req, _ := http.NewRequest("GET", url, nil)
|
|
9625
11108
|
|
|
@@ -9640,7 +11123,7 @@ func main() {
|
|
|
9640
11123
|
require 'uri'
|
|
9641
11124
|
require 'net/http'
|
|
9642
11125
|
|
|
9643
|
-
url = URI("https://api.agentmail.to/v0/inboxes
|
|
11126
|
+
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id")
|
|
9644
11127
|
|
|
9645
11128
|
http = Net::HTTP.new(url.host, url.port)
|
|
9646
11129
|
http.use_ssl = true
|
|
@@ -9653,7 +11136,7 @@ puts response.read_body
|
|
|
9653
11136
|
```
|
|
9654
11137
|
|
|
9655
11138
|
```java
|
|
9656
|
-
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
11139
|
+
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id")
|
|
9657
11140
|
.header("Authorization", "Bearer <api_key>")
|
|
9658
11141
|
.asString();
|
|
9659
11142
|
```
|
|
@@ -9663,7 +11146,7 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
|
9663
11146
|
|
|
9664
11147
|
$client = new \GuzzleHttp\Client();
|
|
9665
11148
|
|
|
9666
|
-
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes
|
|
11149
|
+
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id', [
|
|
9667
11150
|
'headers' => [
|
|
9668
11151
|
'Authorization' => 'Bearer <api_key>',
|
|
9669
11152
|
],
|
|
@@ -9673,7 +11156,7 @@ echo $response->getBody();
|
|
|
9673
11156
|
```
|
|
9674
11157
|
|
|
9675
11158
|
```csharp
|
|
9676
|
-
var client = new RestClient("https://api.agentmail.to/v0/inboxes
|
|
11159
|
+
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id");
|
|
9677
11160
|
var request = new RestRequest(Method.GET);
|
|
9678
11161
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
9679
11162
|
IRestResponse response = client.Execute(request);
|
|
@@ -9684,7 +11167,7 @@ import Foundation
|
|
|
9684
11167
|
|
|
9685
11168
|
let headers = ["Authorization": "Bearer <api_key>"]
|
|
9686
11169
|
|
|
9687
|
-
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes
|
|
11170
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id")! as URL,
|
|
9688
11171
|
cachePolicy: .useProtocolCachePolicy,
|
|
9689
11172
|
timeoutInterval: 10.0)
|
|
9690
11173
|
request.httpMethod = "GET"
|
|
@@ -10942,7 +12425,6 @@ components:
|
|
|
10942
12425
|
required:
|
|
10943
12426
|
- attachment_id
|
|
10944
12427
|
- size
|
|
10945
|
-
- content_disposition
|
|
10946
12428
|
type_messages:MessageAttachments:
|
|
10947
12429
|
type: array
|
|
10948
12430
|
items:
|
|
@@ -11334,7 +12816,6 @@ components:
|
|
|
11334
12816
|
required:
|
|
11335
12817
|
- attachment_id
|
|
11336
12818
|
- size
|
|
11337
|
-
- content_disposition
|
|
11338
12819
|
type_drafts:DraftAttachments:
|
|
11339
12820
|
type: array
|
|
11340
12821
|
items:
|
|
@@ -11652,7 +13133,6 @@ components:
|
|
|
11652
13133
|
required:
|
|
11653
13134
|
- attachment_id
|
|
11654
13135
|
- size
|
|
11655
|
-
- content_disposition
|
|
11656
13136
|
type_drafts:DraftAttachments:
|
|
11657
13137
|
type: array
|
|
11658
13138
|
items:
|
|
@@ -12007,7 +13487,6 @@ components:
|
|
|
12007
13487
|
required:
|
|
12008
13488
|
- attachment_id
|
|
12009
13489
|
- size
|
|
12010
|
-
- content_disposition
|
|
12011
13490
|
type_drafts:DraftAttachments:
|
|
12012
13491
|
type: array
|
|
12013
13492
|
items:
|
|
@@ -12372,7 +13851,6 @@ components:
|
|
|
12372
13851
|
required:
|
|
12373
13852
|
- attachment_id
|
|
12374
13853
|
- size
|
|
12375
|
-
- content_disposition
|
|
12376
13854
|
type_drafts:DraftAttachments:
|
|
12377
13855
|
type: array
|
|
12378
13856
|
items:
|
|
@@ -13193,6 +14671,7 @@ package main
|
|
|
13193
14671
|
|
|
13194
14672
|
import (
|
|
13195
14673
|
"fmt"
|
|
14674
|
+
"strings"
|
|
13196
14675
|
"net/http"
|
|
13197
14676
|
"io"
|
|
13198
14677
|
)
|
|
@@ -13201,9 +14680,12 @@ func main() {
|
|
|
13201
14680
|
|
|
13202
14681
|
url := "https://api.agentmail.to/v0/inboxes/inbox_id/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z"
|
|
13203
14682
|
|
|
13204
|
-
|
|
14683
|
+
payload := strings.NewReader("{}")
|
|
14684
|
+
|
|
14685
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
13205
14686
|
|
|
13206
14687
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
14688
|
+
req.Header.Add("Content-Type", "application/json")
|
|
13207
14689
|
|
|
13208
14690
|
res, _ := http.DefaultClient.Do(req)
|
|
13209
14691
|
|
|
@@ -13227,6 +14709,8 @@ http.use_ssl = true
|
|
|
13227
14709
|
|
|
13228
14710
|
request = Net::HTTP::Get.new(url)
|
|
13229
14711
|
request["Authorization"] = 'Bearer <api_key>'
|
|
14712
|
+
request["Content-Type"] = 'application/json'
|
|
14713
|
+
request.body = "{}"
|
|
13230
14714
|
|
|
13231
14715
|
response = http.request(request)
|
|
13232
14716
|
puts response.read_body
|
|
@@ -13235,6 +14719,8 @@ puts response.read_body
|
|
|
13235
14719
|
```java
|
|
13236
14720
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z")
|
|
13237
14721
|
.header("Authorization", "Bearer <api_key>")
|
|
14722
|
+
.header("Content-Type", "application/json")
|
|
14723
|
+
.body("{}")
|
|
13238
14724
|
.asString();
|
|
13239
14725
|
```
|
|
13240
14726
|
|
|
@@ -13244,8 +14730,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes
|
|
|
13244
14730
|
$client = new \GuzzleHttp\Client();
|
|
13245
14731
|
|
|
13246
14732
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z', [
|
|
14733
|
+
'body' => '{}',
|
|
13247
14734
|
'headers' => [
|
|
13248
14735
|
'Authorization' => 'Bearer <api_key>',
|
|
14736
|
+
'Content-Type' => 'application/json',
|
|
13249
14737
|
],
|
|
13250
14738
|
]);
|
|
13251
14739
|
|
|
@@ -13256,19 +14744,28 @@ echo $response->getBody();
|
|
|
13256
14744
|
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z");
|
|
13257
14745
|
var request = new RestRequest(Method.GET);
|
|
13258
14746
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
14747
|
+
request.AddHeader("Content-Type", "application/json");
|
|
14748
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
13259
14749
|
IRestResponse response = client.Execute(request);
|
|
13260
14750
|
```
|
|
13261
14751
|
|
|
13262
14752
|
```swift
|
|
13263
14753
|
import Foundation
|
|
13264
14754
|
|
|
13265
|
-
let headers = [
|
|
14755
|
+
let headers = [
|
|
14756
|
+
"Authorization": "Bearer <api_key>",
|
|
14757
|
+
"Content-Type": "application/json"
|
|
14758
|
+
]
|
|
14759
|
+
let parameters = [] as [String : Any]
|
|
14760
|
+
|
|
14761
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
13266
14762
|
|
|
13267
14763
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z")! as URL,
|
|
13268
14764
|
cachePolicy: .useProtocolCachePolicy,
|
|
13269
14765
|
timeoutInterval: 10.0)
|
|
13270
14766
|
request.httpMethod = "GET"
|
|
13271
14767
|
request.allHTTPHeaderFields = headers
|
|
14768
|
+
request.httpBody = postData as Data
|
|
13272
14769
|
|
|
13273
14770
|
let session = URLSession.shared
|
|
13274
14771
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -13441,7 +14938,6 @@ components:
|
|
|
13441
14938
|
required:
|
|
13442
14939
|
- attachment_id
|
|
13443
14940
|
- size
|
|
13444
|
-
- content_disposition
|
|
13445
14941
|
type_threads:ThreadAttachments:
|
|
13446
14942
|
type: array
|
|
13447
14943
|
items:
|
|
@@ -13560,6 +15056,7 @@ package main
|
|
|
13560
15056
|
|
|
13561
15057
|
import (
|
|
13562
15058
|
"fmt"
|
|
15059
|
+
"strings"
|
|
13563
15060
|
"net/http"
|
|
13564
15061
|
"io"
|
|
13565
15062
|
)
|
|
@@ -13568,9 +15065,12 @@ func main() {
|
|
|
13568
15065
|
|
|
13569
15066
|
url := "https://api.agentmail.to/v0/threads"
|
|
13570
15067
|
|
|
13571
|
-
|
|
15068
|
+
payload := strings.NewReader("{}")
|
|
15069
|
+
|
|
15070
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
13572
15071
|
|
|
13573
15072
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
15073
|
+
req.Header.Add("Content-Type", "application/json")
|
|
13574
15074
|
|
|
13575
15075
|
res, _ := http.DefaultClient.Do(req)
|
|
13576
15076
|
|
|
@@ -13594,6 +15094,8 @@ http.use_ssl = true
|
|
|
13594
15094
|
|
|
13595
15095
|
request = Net::HTTP::Get.new(url)
|
|
13596
15096
|
request["Authorization"] = 'Bearer <api_key>'
|
|
15097
|
+
request["Content-Type"] = 'application/json'
|
|
15098
|
+
request.body = "{}"
|
|
13597
15099
|
|
|
13598
15100
|
response = http.request(request)
|
|
13599
15101
|
puts response.read_body
|
|
@@ -13602,6 +15104,8 @@ puts response.read_body
|
|
|
13602
15104
|
```java
|
|
13603
15105
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/threads")
|
|
13604
15106
|
.header("Authorization", "Bearer <api_key>")
|
|
15107
|
+
.header("Content-Type", "application/json")
|
|
15108
|
+
.body("{}")
|
|
13605
15109
|
.asString();
|
|
13606
15110
|
```
|
|
13607
15111
|
|
|
@@ -13611,8 +15115,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/threads
|
|
|
13611
15115
|
$client = new \GuzzleHttp\Client();
|
|
13612
15116
|
|
|
13613
15117
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/threads', [
|
|
15118
|
+
'body' => '{}',
|
|
13614
15119
|
'headers' => [
|
|
13615
15120
|
'Authorization' => 'Bearer <api_key>',
|
|
15121
|
+
'Content-Type' => 'application/json',
|
|
13616
15122
|
],
|
|
13617
15123
|
]);
|
|
13618
15124
|
|
|
@@ -13623,19 +15129,28 @@ echo $response->getBody();
|
|
|
13623
15129
|
var client = new RestClient("https://api.agentmail.to/v0/threads");
|
|
13624
15130
|
var request = new RestRequest(Method.GET);
|
|
13625
15131
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
15132
|
+
request.AddHeader("Content-Type", "application/json");
|
|
15133
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
13626
15134
|
IRestResponse response = client.Execute(request);
|
|
13627
15135
|
```
|
|
13628
15136
|
|
|
13629
15137
|
```swift
|
|
13630
15138
|
import Foundation
|
|
13631
15139
|
|
|
13632
|
-
let headers = [
|
|
15140
|
+
let headers = [
|
|
15141
|
+
"Authorization": "Bearer <api_key>",
|
|
15142
|
+
"Content-Type": "application/json"
|
|
15143
|
+
]
|
|
15144
|
+
let parameters = [] as [String : Any]
|
|
15145
|
+
|
|
15146
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
13633
15147
|
|
|
13634
15148
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/threads")! as URL,
|
|
13635
15149
|
cachePolicy: .useProtocolCachePolicy,
|
|
13636
15150
|
timeoutInterval: 10.0)
|
|
13637
15151
|
request.httpMethod = "GET"
|
|
13638
15152
|
request.allHTTPHeaderFields = headers
|
|
15153
|
+
request.httpBody = postData as Data
|
|
13639
15154
|
|
|
13640
15155
|
let session = URLSession.shared
|
|
13641
15156
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -13758,7 +15273,6 @@ components:
|
|
|
13758
15273
|
required:
|
|
13759
15274
|
- attachment_id
|
|
13760
15275
|
- size
|
|
13761
|
-
- content_disposition
|
|
13762
15276
|
type_threads:ThreadAttachments:
|
|
13763
15277
|
type: array
|
|
13764
15278
|
items:
|
|
@@ -14121,10 +15635,9 @@ paths:
|
|
|
14121
15635
|
'200':
|
|
14122
15636
|
description: Response with status 200
|
|
14123
15637
|
content:
|
|
14124
|
-
application/
|
|
15638
|
+
application/json:
|
|
14125
15639
|
schema:
|
|
14126
|
-
|
|
14127
|
-
format: binary
|
|
15640
|
+
$ref: '#/components/schemas/type_attachments:AttachmentResponse'
|
|
14128
15641
|
'404':
|
|
14129
15642
|
description: Error response with status 404
|
|
14130
15643
|
content: {}
|
|
@@ -14134,6 +15647,46 @@ components:
|
|
|
14134
15647
|
type: string
|
|
14135
15648
|
type_attachments:AttachmentId:
|
|
14136
15649
|
type: string
|
|
15650
|
+
type_attachments:AttachmentFilename:
|
|
15651
|
+
type: string
|
|
15652
|
+
type_attachments:AttachmentSize:
|
|
15653
|
+
type: integer
|
|
15654
|
+
type_attachments:AttachmentContentType:
|
|
15655
|
+
type: string
|
|
15656
|
+
type_attachments:AttachmentContentDisposition:
|
|
15657
|
+
type: string
|
|
15658
|
+
enum:
|
|
15659
|
+
- value: inline
|
|
15660
|
+
- value: attachment
|
|
15661
|
+
type_attachments:AttachmentContentId:
|
|
15662
|
+
type: string
|
|
15663
|
+
type_attachments:AttachmentResponse:
|
|
15664
|
+
type: object
|
|
15665
|
+
properties:
|
|
15666
|
+
attachment_id:
|
|
15667
|
+
$ref: '#/components/schemas/type_attachments:AttachmentId'
|
|
15668
|
+
filename:
|
|
15669
|
+
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
|
|
15670
|
+
size:
|
|
15671
|
+
$ref: '#/components/schemas/type_attachments:AttachmentSize'
|
|
15672
|
+
content_type:
|
|
15673
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
|
|
15674
|
+
content_disposition:
|
|
15675
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
|
|
15676
|
+
content_id:
|
|
15677
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
|
|
15678
|
+
download_url:
|
|
15679
|
+
type: string
|
|
15680
|
+
description: URL to download the attachment.
|
|
15681
|
+
expires_at:
|
|
15682
|
+
type: string
|
|
15683
|
+
format: date-time
|
|
15684
|
+
description: Time at which the download URL expires.
|
|
15685
|
+
required:
|
|
15686
|
+
- attachment_id
|
|
15687
|
+
- size
|
|
15688
|
+
- download_url
|
|
15689
|
+
- expires_at
|
|
14137
15690
|
|
|
14138
15691
|
```
|
|
14139
15692
|
|
|
@@ -14147,7 +15700,7 @@ async function main() {
|
|
|
14147
15700
|
environment: "https://api.agentmail.to",
|
|
14148
15701
|
apiKey: "YOUR_TOKEN_HERE",
|
|
14149
15702
|
});
|
|
14150
|
-
await client.threads.getAttachment("
|
|
15703
|
+
await client.threads.getAttachment("thread_id", "attachment_id");
|
|
14151
15704
|
}
|
|
14152
15705
|
main();
|
|
14153
15706
|
|
|
@@ -14162,8 +15715,8 @@ client = AgentMail(
|
|
|
14162
15715
|
)
|
|
14163
15716
|
|
|
14164
15717
|
client.threads.get_attachment(
|
|
14165
|
-
thread_id="
|
|
14166
|
-
attachment_id="
|
|
15718
|
+
thread_id="thread_id",
|
|
15719
|
+
attachment_id="attachment_id"
|
|
14167
15720
|
)
|
|
14168
15721
|
|
|
14169
15722
|
```
|
|
@@ -14179,7 +15732,7 @@ import (
|
|
|
14179
15732
|
|
|
14180
15733
|
func main() {
|
|
14181
15734
|
|
|
14182
|
-
url := "https://api.agentmail.to/v0/threads
|
|
15735
|
+
url := "https://api.agentmail.to/v0/threads/thread_id/attachments/attachment_id"
|
|
14183
15736
|
|
|
14184
15737
|
req, _ := http.NewRequest("GET", url, nil)
|
|
14185
15738
|
|
|
@@ -14200,7 +15753,7 @@ func main() {
|
|
|
14200
15753
|
require 'uri'
|
|
14201
15754
|
require 'net/http'
|
|
14202
15755
|
|
|
14203
|
-
url = URI("https://api.agentmail.to/v0/threads
|
|
15756
|
+
url = URI("https://api.agentmail.to/v0/threads/thread_id/attachments/attachment_id")
|
|
14204
15757
|
|
|
14205
15758
|
http = Net::HTTP.new(url.host, url.port)
|
|
14206
15759
|
http.use_ssl = true
|
|
@@ -14213,7 +15766,7 @@ puts response.read_body
|
|
|
14213
15766
|
```
|
|
14214
15767
|
|
|
14215
15768
|
```java
|
|
14216
|
-
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/threads
|
|
15769
|
+
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/threads/thread_id/attachments/attachment_id")
|
|
14217
15770
|
.header("Authorization", "Bearer <api_key>")
|
|
14218
15771
|
.asString();
|
|
14219
15772
|
```
|
|
@@ -14223,7 +15776,7 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/threads
|
|
|
14223
15776
|
|
|
14224
15777
|
$client = new \GuzzleHttp\Client();
|
|
14225
15778
|
|
|
14226
|
-
$response = $client->request('GET', 'https://api.agentmail.to/v0/threads
|
|
15779
|
+
$response = $client->request('GET', 'https://api.agentmail.to/v0/threads/thread_id/attachments/attachment_id', [
|
|
14227
15780
|
'headers' => [
|
|
14228
15781
|
'Authorization' => 'Bearer <api_key>',
|
|
14229
15782
|
],
|
|
@@ -14233,7 +15786,7 @@ echo $response->getBody();
|
|
|
14233
15786
|
```
|
|
14234
15787
|
|
|
14235
15788
|
```csharp
|
|
14236
|
-
var client = new RestClient("https://api.agentmail.to/v0/threads
|
|
15789
|
+
var client = new RestClient("https://api.agentmail.to/v0/threads/thread_id/attachments/attachment_id");
|
|
14237
15790
|
var request = new RestRequest(Method.GET);
|
|
14238
15791
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
14239
15792
|
IRestResponse response = client.Execute(request);
|
|
@@ -14244,7 +15797,7 @@ import Foundation
|
|
|
14244
15797
|
|
|
14245
15798
|
let headers = ["Authorization": "Bearer <api_key>"]
|
|
14246
15799
|
|
|
14247
|
-
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/threads
|
|
15800
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/threads/thread_id/attachments/attachment_id")! as URL,
|
|
14248
15801
|
cachePolicy: .useProtocolCachePolicy,
|
|
14249
15802
|
timeoutInterval: 10.0)
|
|
14250
15803
|
request.httpMethod = "GET"
|
|
@@ -14411,7 +15964,6 @@ components:
|
|
|
14411
15964
|
required:
|
|
14412
15965
|
- attachment_id
|
|
14413
15966
|
- size
|
|
14414
|
-
- content_disposition
|
|
14415
15967
|
type_drafts:DraftAttachments:
|
|
14416
15968
|
type: array
|
|
14417
15969
|
items:
|
|
@@ -14721,7 +16273,6 @@ components:
|
|
|
14721
16273
|
required:
|
|
14722
16274
|
- attachment_id
|
|
14723
16275
|
- size
|
|
14724
|
-
- content_disposition
|
|
14725
16276
|
type_drafts:DraftAttachments:
|
|
14726
16277
|
type: array
|
|
14727
16278
|
items:
|
|
@@ -15062,6 +16613,7 @@ package main
|
|
|
15062
16613
|
|
|
15063
16614
|
import (
|
|
15064
16615
|
"fmt"
|
|
16616
|
+
"strings"
|
|
15065
16617
|
"net/http"
|
|
15066
16618
|
"io"
|
|
15067
16619
|
)
|
|
@@ -15070,9 +16622,12 @@ func main() {
|
|
|
15070
16622
|
|
|
15071
16623
|
url := "https://api.agentmail.to/v0/domains"
|
|
15072
16624
|
|
|
15073
|
-
|
|
16625
|
+
payload := strings.NewReader("{}")
|
|
16626
|
+
|
|
16627
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
15074
16628
|
|
|
15075
16629
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
16630
|
+
req.Header.Add("Content-Type", "application/json")
|
|
15076
16631
|
|
|
15077
16632
|
res, _ := http.DefaultClient.Do(req)
|
|
15078
16633
|
|
|
@@ -15096,6 +16651,8 @@ http.use_ssl = true
|
|
|
15096
16651
|
|
|
15097
16652
|
request = Net::HTTP::Get.new(url)
|
|
15098
16653
|
request["Authorization"] = 'Bearer <api_key>'
|
|
16654
|
+
request["Content-Type"] = 'application/json'
|
|
16655
|
+
request.body = "{}"
|
|
15099
16656
|
|
|
15100
16657
|
response = http.request(request)
|
|
15101
16658
|
puts response.read_body
|
|
@@ -15104,6 +16661,8 @@ puts response.read_body
|
|
|
15104
16661
|
```java
|
|
15105
16662
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/domains")
|
|
15106
16663
|
.header("Authorization", "Bearer <api_key>")
|
|
16664
|
+
.header("Content-Type", "application/json")
|
|
16665
|
+
.body("{}")
|
|
15107
16666
|
.asString();
|
|
15108
16667
|
```
|
|
15109
16668
|
|
|
@@ -15113,8 +16672,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/domains
|
|
|
15113
16672
|
$client = new \GuzzleHttp\Client();
|
|
15114
16673
|
|
|
15115
16674
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/domains', [
|
|
16675
|
+
'body' => '{}',
|
|
15116
16676
|
'headers' => [
|
|
15117
16677
|
'Authorization' => 'Bearer <api_key>',
|
|
16678
|
+
'Content-Type' => 'application/json',
|
|
15118
16679
|
],
|
|
15119
16680
|
]);
|
|
15120
16681
|
|
|
@@ -15125,19 +16686,28 @@ echo $response->getBody();
|
|
|
15125
16686
|
var client = new RestClient("https://api.agentmail.to/v0/domains");
|
|
15126
16687
|
var request = new RestRequest(Method.GET);
|
|
15127
16688
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
16689
|
+
request.AddHeader("Content-Type", "application/json");
|
|
16690
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
15128
16691
|
IRestResponse response = client.Execute(request);
|
|
15129
16692
|
```
|
|
15130
16693
|
|
|
15131
16694
|
```swift
|
|
15132
16695
|
import Foundation
|
|
15133
16696
|
|
|
15134
|
-
let headers = [
|
|
16697
|
+
let headers = [
|
|
16698
|
+
"Authorization": "Bearer <api_key>",
|
|
16699
|
+
"Content-Type": "application/json"
|
|
16700
|
+
]
|
|
16701
|
+
let parameters = [] as [String : Any]
|
|
16702
|
+
|
|
16703
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
15135
16704
|
|
|
15136
16705
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/domains")! as URL,
|
|
15137
16706
|
cachePolicy: .useProtocolCachePolicy,
|
|
15138
16707
|
timeoutInterval: 10.0)
|
|
15139
16708
|
request.httpMethod = "GET"
|
|
15140
16709
|
request.allHTTPHeaderFields = headers
|
|
16710
|
+
request.httpBody = postData as Data
|
|
15141
16711
|
|
|
15142
16712
|
let session = URLSession.shared
|
|
15143
16713
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -15748,7 +17318,7 @@ async function main() {
|
|
|
15748
17318
|
apiKey: "YOUR_TOKEN_HERE",
|
|
15749
17319
|
});
|
|
15750
17320
|
await client.domains.create({
|
|
15751
|
-
domain: "
|
|
17321
|
+
domain: "example.com",
|
|
15752
17322
|
feedbackEnabled: true,
|
|
15753
17323
|
});
|
|
15754
17324
|
}
|
|
@@ -15765,7 +17335,7 @@ client = AgentMail(
|
|
|
15765
17335
|
)
|
|
15766
17336
|
|
|
15767
17337
|
client.domains.create(
|
|
15768
|
-
domain="
|
|
17338
|
+
domain="example.com",
|
|
15769
17339
|
feedback_enabled=True
|
|
15770
17340
|
)
|
|
15771
17341
|
|
|
@@ -15785,7 +17355,7 @@ func main() {
|
|
|
15785
17355
|
|
|
15786
17356
|
url := "https://api.agentmail.to/v0/domains"
|
|
15787
17357
|
|
|
15788
|
-
payload := strings.NewReader("{\n \"domain\": \"
|
|
17358
|
+
payload := strings.NewReader("{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}")
|
|
15789
17359
|
|
|
15790
17360
|
req, _ := http.NewRequest("POST", url, payload)
|
|
15791
17361
|
|
|
@@ -15815,7 +17385,7 @@ http.use_ssl = true
|
|
|
15815
17385
|
request = Net::HTTP::Post.new(url)
|
|
15816
17386
|
request["Authorization"] = 'Bearer <api_key>'
|
|
15817
17387
|
request["Content-Type"] = 'application/json'
|
|
15818
|
-
request.body = "{\n \"domain\": \"
|
|
17388
|
+
request.body = "{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}"
|
|
15819
17389
|
|
|
15820
17390
|
response = http.request(request)
|
|
15821
17391
|
puts response.read_body
|
|
@@ -15825,7 +17395,7 @@ puts response.read_body
|
|
|
15825
17395
|
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/domains")
|
|
15826
17396
|
.header("Authorization", "Bearer <api_key>")
|
|
15827
17397
|
.header("Content-Type", "application/json")
|
|
15828
|
-
.body("{\n \"domain\": \"
|
|
17398
|
+
.body("{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}")
|
|
15829
17399
|
.asString();
|
|
15830
17400
|
```
|
|
15831
17401
|
|
|
@@ -15836,7 +17406,7 @@ $client = new \GuzzleHttp\Client();
|
|
|
15836
17406
|
|
|
15837
17407
|
$response = $client->request('POST', 'https://api.agentmail.to/v0/domains', [
|
|
15838
17408
|
'body' => '{
|
|
15839
|
-
"domain": "
|
|
17409
|
+
"domain": "example.com",
|
|
15840
17410
|
"feedback_enabled": true
|
|
15841
17411
|
}',
|
|
15842
17412
|
'headers' => [
|
|
@@ -15853,7 +17423,7 @@ var client = new RestClient("https://api.agentmail.to/v0/domains");
|
|
|
15853
17423
|
var request = new RestRequest(Method.POST);
|
|
15854
17424
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
15855
17425
|
request.AddHeader("Content-Type", "application/json");
|
|
15856
|
-
request.AddParameter("application/json", "{\n \"domain\": \"
|
|
17426
|
+
request.AddParameter("application/json", "{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}", ParameterType.RequestBody);
|
|
15857
17427
|
IRestResponse response = client.Execute(request);
|
|
15858
17428
|
```
|
|
15859
17429
|
|
|
@@ -15865,7 +17435,7 @@ let headers = [
|
|
|
15865
17435
|
"Content-Type": "application/json"
|
|
15866
17436
|
]
|
|
15867
17437
|
let parameters = [
|
|
15868
|
-
"domain": "
|
|
17438
|
+
"domain": "example.com",
|
|
15869
17439
|
"feedback_enabled": true
|
|
15870
17440
|
] as [String : Any]
|
|
15871
17441
|
|
|
@@ -17322,7 +18892,6 @@ components:
|
|
|
17322
18892
|
required:
|
|
17323
18893
|
- attachment_id
|
|
17324
18894
|
- size
|
|
17325
|
-
- content_disposition
|
|
17326
18895
|
type_messages:MessageAttachments:
|
|
17327
18896
|
type: array
|
|
17328
18897
|
items:
|
|
@@ -18478,7 +20047,6 @@ components:
|
|
|
18478
20047
|
required:
|
|
18479
20048
|
- attachment_id
|
|
18480
20049
|
- size
|
|
18481
|
-
- content_disposition
|
|
18482
20050
|
type_messages:MessageAttachments:
|
|
18483
20051
|
type: array
|
|
18484
20052
|
items:
|
|
@@ -19225,6 +20793,7 @@ package main
|
|
|
19225
20793
|
|
|
19226
20794
|
import (
|
|
19227
20795
|
"fmt"
|
|
20796
|
+
"strings"
|
|
19228
20797
|
"net/http"
|
|
19229
20798
|
"io"
|
|
19230
20799
|
)
|
|
@@ -19233,9 +20802,12 @@ func main() {
|
|
|
19233
20802
|
|
|
19234
20803
|
url := "https://api.agentmail.to/v0/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z"
|
|
19235
20804
|
|
|
19236
|
-
|
|
20805
|
+
payload := strings.NewReader("{}")
|
|
20806
|
+
|
|
20807
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
19237
20808
|
|
|
19238
20809
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
20810
|
+
req.Header.Add("Content-Type", "application/json")
|
|
19239
20811
|
|
|
19240
20812
|
res, _ := http.DefaultClient.Do(req)
|
|
19241
20813
|
|
|
@@ -19259,6 +20831,8 @@ http.use_ssl = true
|
|
|
19259
20831
|
|
|
19260
20832
|
request = Net::HTTP::Get.new(url)
|
|
19261
20833
|
request["Authorization"] = 'Bearer <api_key>'
|
|
20834
|
+
request["Content-Type"] = 'application/json'
|
|
20835
|
+
request.body = "{}"
|
|
19262
20836
|
|
|
19263
20837
|
response = http.request(request)
|
|
19264
20838
|
puts response.read_body
|
|
@@ -19267,6 +20841,8 @@ puts response.read_body
|
|
|
19267
20841
|
```java
|
|
19268
20842
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z")
|
|
19269
20843
|
.header("Authorization", "Bearer <api_key>")
|
|
20844
|
+
.header("Content-Type", "application/json")
|
|
20845
|
+
.body("{}")
|
|
19270
20846
|
.asString();
|
|
19271
20847
|
```
|
|
19272
20848
|
|
|
@@ -19276,8 +20852,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/metrics
|
|
|
19276
20852
|
$client = new \GuzzleHttp\Client();
|
|
19277
20853
|
|
|
19278
20854
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z', [
|
|
20855
|
+
'body' => '{}',
|
|
19279
20856
|
'headers' => [
|
|
19280
20857
|
'Authorization' => 'Bearer <api_key>',
|
|
20858
|
+
'Content-Type' => 'application/json',
|
|
19281
20859
|
],
|
|
19282
20860
|
]);
|
|
19283
20861
|
|
|
@@ -19288,19 +20866,28 @@ echo $response->getBody();
|
|
|
19288
20866
|
var client = new RestClient("https://api.agentmail.to/v0/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z");
|
|
19289
20867
|
var request = new RestRequest(Method.GET);
|
|
19290
20868
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
20869
|
+
request.AddHeader("Content-Type", "application/json");
|
|
20870
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
19291
20871
|
IRestResponse response = client.Execute(request);
|
|
19292
20872
|
```
|
|
19293
20873
|
|
|
19294
20874
|
```swift
|
|
19295
20875
|
import Foundation
|
|
19296
20876
|
|
|
19297
|
-
let headers = [
|
|
20877
|
+
let headers = [
|
|
20878
|
+
"Authorization": "Bearer <api_key>",
|
|
20879
|
+
"Content-Type": "application/json"
|
|
20880
|
+
]
|
|
20881
|
+
let parameters = [] as [String : Any]
|
|
20882
|
+
|
|
20883
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
19298
20884
|
|
|
19299
20885
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/metrics?start_timestamp=2024-01-15T09%3A30%3A00Z&end_timestamp=2024-01-15T09%3A30%3A00Z")! as URL,
|
|
19300
20886
|
cachePolicy: .useProtocolCachePolicy,
|
|
19301
20887
|
timeoutInterval: 10.0)
|
|
19302
20888
|
request.httpMethod = "GET"
|
|
19303
20889
|
request.allHTTPHeaderFields = headers
|
|
20890
|
+
request.httpBody = postData as Data
|
|
19304
20891
|
|
|
19305
20892
|
let session = URLSession.shared
|
|
19306
20893
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -19449,6 +21036,7 @@ package main
|
|
|
19449
21036
|
|
|
19450
21037
|
import (
|
|
19451
21038
|
"fmt"
|
|
21039
|
+
"strings"
|
|
19452
21040
|
"net/http"
|
|
19453
21041
|
"io"
|
|
19454
21042
|
)
|
|
@@ -19457,9 +21045,12 @@ func main() {
|
|
|
19457
21045
|
|
|
19458
21046
|
url := "https://api.agentmail.to/v0/api-keys"
|
|
19459
21047
|
|
|
19460
|
-
|
|
21048
|
+
payload := strings.NewReader("{}")
|
|
21049
|
+
|
|
21050
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
19461
21051
|
|
|
19462
21052
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
21053
|
+
req.Header.Add("Content-Type", "application/json")
|
|
19463
21054
|
|
|
19464
21055
|
res, _ := http.DefaultClient.Do(req)
|
|
19465
21056
|
|
|
@@ -19483,6 +21074,8 @@ http.use_ssl = true
|
|
|
19483
21074
|
|
|
19484
21075
|
request = Net::HTTP::Get.new(url)
|
|
19485
21076
|
request["Authorization"] = 'Bearer <api_key>'
|
|
21077
|
+
request["Content-Type"] = 'application/json'
|
|
21078
|
+
request.body = "{}"
|
|
19486
21079
|
|
|
19487
21080
|
response = http.request(request)
|
|
19488
21081
|
puts response.read_body
|
|
@@ -19491,6 +21084,8 @@ puts response.read_body
|
|
|
19491
21084
|
```java
|
|
19492
21085
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/api-keys")
|
|
19493
21086
|
.header("Authorization", "Bearer <api_key>")
|
|
21087
|
+
.header("Content-Type", "application/json")
|
|
21088
|
+
.body("{}")
|
|
19494
21089
|
.asString();
|
|
19495
21090
|
```
|
|
19496
21091
|
|
|
@@ -19500,8 +21095,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/api-key
|
|
|
19500
21095
|
$client = new \GuzzleHttp\Client();
|
|
19501
21096
|
|
|
19502
21097
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/api-keys', [
|
|
21098
|
+
'body' => '{}',
|
|
19503
21099
|
'headers' => [
|
|
19504
21100
|
'Authorization' => 'Bearer <api_key>',
|
|
21101
|
+
'Content-Type' => 'application/json',
|
|
19505
21102
|
],
|
|
19506
21103
|
]);
|
|
19507
21104
|
|
|
@@ -19512,19 +21109,28 @@ echo $response->getBody();
|
|
|
19512
21109
|
var client = new RestClient("https://api.agentmail.to/v0/api-keys");
|
|
19513
21110
|
var request = new RestRequest(Method.GET);
|
|
19514
21111
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
21112
|
+
request.AddHeader("Content-Type", "application/json");
|
|
21113
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
19515
21114
|
IRestResponse response = client.Execute(request);
|
|
19516
21115
|
```
|
|
19517
21116
|
|
|
19518
21117
|
```swift
|
|
19519
21118
|
import Foundation
|
|
19520
21119
|
|
|
19521
|
-
let headers = [
|
|
21120
|
+
let headers = [
|
|
21121
|
+
"Authorization": "Bearer <api_key>",
|
|
21122
|
+
"Content-Type": "application/json"
|
|
21123
|
+
]
|
|
21124
|
+
let parameters = [] as [String : Any]
|
|
21125
|
+
|
|
21126
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
19522
21127
|
|
|
19523
21128
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/api-keys")! as URL,
|
|
19524
21129
|
cachePolicy: .useProtocolCachePolicy,
|
|
19525
21130
|
timeoutInterval: 10.0)
|
|
19526
21131
|
request.httpMethod = "GET"
|
|
19527
21132
|
request.allHTTPHeaderFields = headers
|
|
21133
|
+
request.httpBody = postData as Data
|
|
19528
21134
|
|
|
19529
21135
|
let session = URLSession.shared
|
|
19530
21136
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -20080,6 +21686,7 @@ package main
|
|
|
20080
21686
|
|
|
20081
21687
|
import (
|
|
20082
21688
|
"fmt"
|
|
21689
|
+
"strings"
|
|
20083
21690
|
"net/http"
|
|
20084
21691
|
"io"
|
|
20085
21692
|
)
|
|
@@ -20088,9 +21695,12 @@ func main() {
|
|
|
20088
21695
|
|
|
20089
21696
|
url := "https://api.agentmail.to/v0/pods"
|
|
20090
21697
|
|
|
20091
|
-
|
|
21698
|
+
payload := strings.NewReader("{}")
|
|
21699
|
+
|
|
21700
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
20092
21701
|
|
|
20093
21702
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
21703
|
+
req.Header.Add("Content-Type", "application/json")
|
|
20094
21704
|
|
|
20095
21705
|
res, _ := http.DefaultClient.Do(req)
|
|
20096
21706
|
|
|
@@ -20114,6 +21724,8 @@ http.use_ssl = true
|
|
|
20114
21724
|
|
|
20115
21725
|
request = Net::HTTP::Get.new(url)
|
|
20116
21726
|
request["Authorization"] = 'Bearer <api_key>'
|
|
21727
|
+
request["Content-Type"] = 'application/json'
|
|
21728
|
+
request.body = "{}"
|
|
20117
21729
|
|
|
20118
21730
|
response = http.request(request)
|
|
20119
21731
|
puts response.read_body
|
|
@@ -20122,6 +21734,8 @@ puts response.read_body
|
|
|
20122
21734
|
```java
|
|
20123
21735
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods")
|
|
20124
21736
|
.header("Authorization", "Bearer <api_key>")
|
|
21737
|
+
.header("Content-Type", "application/json")
|
|
21738
|
+
.body("{}")
|
|
20125
21739
|
.asString();
|
|
20126
21740
|
```
|
|
20127
21741
|
|
|
@@ -20131,8 +21745,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods")
|
|
|
20131
21745
|
$client = new \GuzzleHttp\Client();
|
|
20132
21746
|
|
|
20133
21747
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods', [
|
|
21748
|
+
'body' => '{}',
|
|
20134
21749
|
'headers' => [
|
|
20135
21750
|
'Authorization' => 'Bearer <api_key>',
|
|
21751
|
+
'Content-Type' => 'application/json',
|
|
20136
21752
|
],
|
|
20137
21753
|
]);
|
|
20138
21754
|
|
|
@@ -20143,19 +21759,28 @@ echo $response->getBody();
|
|
|
20143
21759
|
var client = new RestClient("https://api.agentmail.to/v0/pods");
|
|
20144
21760
|
var request = new RestRequest(Method.GET);
|
|
20145
21761
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
21762
|
+
request.AddHeader("Content-Type", "application/json");
|
|
21763
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
20146
21764
|
IRestResponse response = client.Execute(request);
|
|
20147
21765
|
```
|
|
20148
21766
|
|
|
20149
21767
|
```swift
|
|
20150
21768
|
import Foundation
|
|
20151
21769
|
|
|
20152
|
-
let headers = [
|
|
21770
|
+
let headers = [
|
|
21771
|
+
"Authorization": "Bearer <api_key>",
|
|
21772
|
+
"Content-Type": "application/json"
|
|
21773
|
+
]
|
|
21774
|
+
let parameters = [] as [String : Any]
|
|
21775
|
+
|
|
21776
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
20153
21777
|
|
|
20154
21778
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods")! as URL,
|
|
20155
21779
|
cachePolicy: .useProtocolCachePolicy,
|
|
20156
21780
|
timeoutInterval: 10.0)
|
|
20157
21781
|
request.httpMethod = "GET"
|
|
20158
21782
|
request.allHTTPHeaderFields = headers
|
|
21783
|
+
request.httpBody = postData as Data
|
|
20159
21784
|
|
|
20160
21785
|
let session = URLSession.shared
|
|
20161
21786
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -20282,6 +21907,7 @@ package main
|
|
|
20282
21907
|
|
|
20283
21908
|
import (
|
|
20284
21909
|
"fmt"
|
|
21910
|
+
"strings"
|
|
20285
21911
|
"net/http"
|
|
20286
21912
|
"io"
|
|
20287
21913
|
)
|
|
@@ -20290,9 +21916,12 @@ func main() {
|
|
|
20290
21916
|
|
|
20291
21917
|
url := "https://api.agentmail.to/v0/pods/pod_id"
|
|
20292
21918
|
|
|
20293
|
-
|
|
21919
|
+
payload := strings.NewReader("{}")
|
|
21920
|
+
|
|
21921
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
20294
21922
|
|
|
20295
21923
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
21924
|
+
req.Header.Add("Content-Type", "application/json")
|
|
20296
21925
|
|
|
20297
21926
|
res, _ := http.DefaultClient.Do(req)
|
|
20298
21927
|
|
|
@@ -20316,6 +21945,8 @@ http.use_ssl = true
|
|
|
20316
21945
|
|
|
20317
21946
|
request = Net::HTTP::Get.new(url)
|
|
20318
21947
|
request["Authorization"] = 'Bearer <api_key>'
|
|
21948
|
+
request["Content-Type"] = 'application/json'
|
|
21949
|
+
request.body = "{}"
|
|
20319
21950
|
|
|
20320
21951
|
response = http.request(request)
|
|
20321
21952
|
puts response.read_body
|
|
@@ -20324,6 +21955,8 @@ puts response.read_body
|
|
|
20324
21955
|
```java
|
|
20325
21956
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id")
|
|
20326
21957
|
.header("Authorization", "Bearer <api_key>")
|
|
21958
|
+
.header("Content-Type", "application/json")
|
|
21959
|
+
.body("{}")
|
|
20327
21960
|
.asString();
|
|
20328
21961
|
```
|
|
20329
21962
|
|
|
@@ -20333,8 +21966,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/po
|
|
|
20333
21966
|
$client = new \GuzzleHttp\Client();
|
|
20334
21967
|
|
|
20335
21968
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id', [
|
|
21969
|
+
'body' => '{}',
|
|
20336
21970
|
'headers' => [
|
|
20337
21971
|
'Authorization' => 'Bearer <api_key>',
|
|
21972
|
+
'Content-Type' => 'application/json',
|
|
20338
21973
|
],
|
|
20339
21974
|
]);
|
|
20340
21975
|
|
|
@@ -20345,19 +21980,28 @@ echo $response->getBody();
|
|
|
20345
21980
|
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id");
|
|
20346
21981
|
var request = new RestRequest(Method.GET);
|
|
20347
21982
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
21983
|
+
request.AddHeader("Content-Type", "application/json");
|
|
21984
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
20348
21985
|
IRestResponse response = client.Execute(request);
|
|
20349
21986
|
```
|
|
20350
21987
|
|
|
20351
21988
|
```swift
|
|
20352
21989
|
import Foundation
|
|
20353
21990
|
|
|
20354
|
-
let headers = [
|
|
21991
|
+
let headers = [
|
|
21992
|
+
"Authorization": "Bearer <api_key>",
|
|
21993
|
+
"Content-Type": "application/json"
|
|
21994
|
+
]
|
|
21995
|
+
let parameters = [] as [String : Any]
|
|
21996
|
+
|
|
21997
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
20355
21998
|
|
|
20356
21999
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id")! as URL,
|
|
20357
22000
|
cachePolicy: .useProtocolCachePolicy,
|
|
20358
22001
|
timeoutInterval: 10.0)
|
|
20359
22002
|
request.httpMethod = "GET"
|
|
20360
22003
|
request.allHTTPHeaderFields = headers
|
|
22004
|
+
request.httpBody = postData as Data
|
|
20361
22005
|
|
|
20362
22006
|
let session = URLSession.shared
|
|
20363
22007
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -20921,6 +22565,7 @@ package main
|
|
|
20921
22565
|
|
|
20922
22566
|
import (
|
|
20923
22567
|
"fmt"
|
|
22568
|
+
"strings"
|
|
20924
22569
|
"net/http"
|
|
20925
22570
|
"io"
|
|
20926
22571
|
)
|
|
@@ -20929,9 +22574,12 @@ func main() {
|
|
|
20929
22574
|
|
|
20930
22575
|
url := "https://api.agentmail.to/v0/pods/pod_id/inboxes"
|
|
20931
22576
|
|
|
20932
|
-
|
|
22577
|
+
payload := strings.NewReader("{}")
|
|
22578
|
+
|
|
22579
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
20933
22580
|
|
|
20934
22581
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
22582
|
+
req.Header.Add("Content-Type", "application/json")
|
|
20935
22583
|
|
|
20936
22584
|
res, _ := http.DefaultClient.Do(req)
|
|
20937
22585
|
|
|
@@ -20955,6 +22603,8 @@ http.use_ssl = true
|
|
|
20955
22603
|
|
|
20956
22604
|
request = Net::HTTP::Get.new(url)
|
|
20957
22605
|
request["Authorization"] = 'Bearer <api_key>'
|
|
22606
|
+
request["Content-Type"] = 'application/json'
|
|
22607
|
+
request.body = "{}"
|
|
20958
22608
|
|
|
20959
22609
|
response = http.request(request)
|
|
20960
22610
|
puts response.read_body
|
|
@@ -20963,6 +22613,8 @@ puts response.read_body
|
|
|
20963
22613
|
```java
|
|
20964
22614
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/inboxes")
|
|
20965
22615
|
.header("Authorization", "Bearer <api_key>")
|
|
22616
|
+
.header("Content-Type", "application/json")
|
|
22617
|
+
.body("{}")
|
|
20966
22618
|
.asString();
|
|
20967
22619
|
```
|
|
20968
22620
|
|
|
@@ -20972,8 +22624,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/po
|
|
|
20972
22624
|
$client = new \GuzzleHttp\Client();
|
|
20973
22625
|
|
|
20974
22626
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/inboxes', [
|
|
22627
|
+
'body' => '{}',
|
|
20975
22628
|
'headers' => [
|
|
20976
22629
|
'Authorization' => 'Bearer <api_key>',
|
|
22630
|
+
'Content-Type' => 'application/json',
|
|
20977
22631
|
],
|
|
20978
22632
|
]);
|
|
20979
22633
|
|
|
@@ -20984,19 +22638,28 @@ echo $response->getBody();
|
|
|
20984
22638
|
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/inboxes");
|
|
20985
22639
|
var request = new RestRequest(Method.GET);
|
|
20986
22640
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
22641
|
+
request.AddHeader("Content-Type", "application/json");
|
|
22642
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
20987
22643
|
IRestResponse response = client.Execute(request);
|
|
20988
22644
|
```
|
|
20989
22645
|
|
|
20990
22646
|
```swift
|
|
20991
22647
|
import Foundation
|
|
20992
22648
|
|
|
20993
|
-
let headers = [
|
|
22649
|
+
let headers = [
|
|
22650
|
+
"Authorization": "Bearer <api_key>",
|
|
22651
|
+
"Content-Type": "application/json"
|
|
22652
|
+
]
|
|
22653
|
+
let parameters = [] as [String : Any]
|
|
22654
|
+
|
|
22655
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
20994
22656
|
|
|
20995
22657
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/inboxes")! as URL,
|
|
20996
22658
|
cachePolicy: .useProtocolCachePolicy,
|
|
20997
22659
|
timeoutInterval: 10.0)
|
|
20998
22660
|
request.httpMethod = "GET"
|
|
20999
22661
|
request.allHTTPHeaderFields = headers
|
|
22662
|
+
request.httpBody = postData as Data
|
|
21000
22663
|
|
|
21001
22664
|
let session = URLSession.shared
|
|
21002
22665
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -21134,6 +22797,7 @@ package main
|
|
|
21134
22797
|
|
|
21135
22798
|
import (
|
|
21136
22799
|
"fmt"
|
|
22800
|
+
"strings"
|
|
21137
22801
|
"net/http"
|
|
21138
22802
|
"io"
|
|
21139
22803
|
)
|
|
@@ -21142,9 +22806,12 @@ func main() {
|
|
|
21142
22806
|
|
|
21143
22807
|
url := "https://api.agentmail.to/v0/pods/pod_id/inboxes/inbox_id"
|
|
21144
22808
|
|
|
21145
|
-
|
|
22809
|
+
payload := strings.NewReader("{}")
|
|
22810
|
+
|
|
22811
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
21146
22812
|
|
|
21147
22813
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
22814
|
+
req.Header.Add("Content-Type", "application/json")
|
|
21148
22815
|
|
|
21149
22816
|
res, _ := http.DefaultClient.Do(req)
|
|
21150
22817
|
|
|
@@ -21168,6 +22835,8 @@ http.use_ssl = true
|
|
|
21168
22835
|
|
|
21169
22836
|
request = Net::HTTP::Get.new(url)
|
|
21170
22837
|
request["Authorization"] = 'Bearer <api_key>'
|
|
22838
|
+
request["Content-Type"] = 'application/json'
|
|
22839
|
+
request.body = "{}"
|
|
21171
22840
|
|
|
21172
22841
|
response = http.request(request)
|
|
21173
22842
|
puts response.read_body
|
|
@@ -21176,6 +22845,8 @@ puts response.read_body
|
|
|
21176
22845
|
```java
|
|
21177
22846
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/inboxes/inbox_id")
|
|
21178
22847
|
.header("Authorization", "Bearer <api_key>")
|
|
22848
|
+
.header("Content-Type", "application/json")
|
|
22849
|
+
.body("{}")
|
|
21179
22850
|
.asString();
|
|
21180
22851
|
```
|
|
21181
22852
|
|
|
@@ -21185,8 +22856,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/po
|
|
|
21185
22856
|
$client = new \GuzzleHttp\Client();
|
|
21186
22857
|
|
|
21187
22858
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/inboxes/inbox_id', [
|
|
22859
|
+
'body' => '{}',
|
|
21188
22860
|
'headers' => [
|
|
21189
22861
|
'Authorization' => 'Bearer <api_key>',
|
|
22862
|
+
'Content-Type' => 'application/json',
|
|
21190
22863
|
],
|
|
21191
22864
|
]);
|
|
21192
22865
|
|
|
@@ -21197,19 +22870,28 @@ echo $response->getBody();
|
|
|
21197
22870
|
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/inboxes/inbox_id");
|
|
21198
22871
|
var request = new RestRequest(Method.GET);
|
|
21199
22872
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
22873
|
+
request.AddHeader("Content-Type", "application/json");
|
|
22874
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
21200
22875
|
IRestResponse response = client.Execute(request);
|
|
21201
22876
|
```
|
|
21202
22877
|
|
|
21203
22878
|
```swift
|
|
21204
22879
|
import Foundation
|
|
21205
22880
|
|
|
21206
|
-
let headers = [
|
|
22881
|
+
let headers = [
|
|
22882
|
+
"Authorization": "Bearer <api_key>",
|
|
22883
|
+
"Content-Type": "application/json"
|
|
22884
|
+
]
|
|
22885
|
+
let parameters = [] as [String : Any]
|
|
22886
|
+
|
|
22887
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
21207
22888
|
|
|
21208
22889
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/inboxes/inbox_id")! as URL,
|
|
21209
22890
|
cachePolicy: .useProtocolCachePolicy,
|
|
21210
22891
|
timeoutInterval: 10.0)
|
|
21211
22892
|
request.httpMethod = "GET"
|
|
21212
22893
|
request.allHTTPHeaderFields = headers
|
|
22894
|
+
request.httpBody = postData as Data
|
|
21213
22895
|
|
|
21214
22896
|
let session = URLSession.shared
|
|
21215
22897
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -21818,7 +23500,6 @@ components:
|
|
|
21818
23500
|
required:
|
|
21819
23501
|
- attachment_id
|
|
21820
23502
|
- size
|
|
21821
|
-
- content_disposition
|
|
21822
23503
|
type_threads:ThreadAttachments:
|
|
21823
23504
|
type: array
|
|
21824
23505
|
items:
|
|
@@ -21939,6 +23620,7 @@ package main
|
|
|
21939
23620
|
|
|
21940
23621
|
import (
|
|
21941
23622
|
"fmt"
|
|
23623
|
+
"strings"
|
|
21942
23624
|
"net/http"
|
|
21943
23625
|
"io"
|
|
21944
23626
|
)
|
|
@@ -21947,9 +23629,12 @@ func main() {
|
|
|
21947
23629
|
|
|
21948
23630
|
url := "https://api.agentmail.to/v0/pods/pod_id/threads"
|
|
21949
23631
|
|
|
21950
|
-
|
|
23632
|
+
payload := strings.NewReader("{}")
|
|
23633
|
+
|
|
23634
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
21951
23635
|
|
|
21952
23636
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
23637
|
+
req.Header.Add("Content-Type", "application/json")
|
|
21953
23638
|
|
|
21954
23639
|
res, _ := http.DefaultClient.Do(req)
|
|
21955
23640
|
|
|
@@ -21973,6 +23658,8 @@ http.use_ssl = true
|
|
|
21973
23658
|
|
|
21974
23659
|
request = Net::HTTP::Get.new(url)
|
|
21975
23660
|
request["Authorization"] = 'Bearer <api_key>'
|
|
23661
|
+
request["Content-Type"] = 'application/json'
|
|
23662
|
+
request.body = "{}"
|
|
21976
23663
|
|
|
21977
23664
|
response = http.request(request)
|
|
21978
23665
|
puts response.read_body
|
|
@@ -21981,6 +23668,8 @@ puts response.read_body
|
|
|
21981
23668
|
```java
|
|
21982
23669
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/threads")
|
|
21983
23670
|
.header("Authorization", "Bearer <api_key>")
|
|
23671
|
+
.header("Content-Type", "application/json")
|
|
23672
|
+
.body("{}")
|
|
21984
23673
|
.asString();
|
|
21985
23674
|
```
|
|
21986
23675
|
|
|
@@ -21990,8 +23679,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/po
|
|
|
21990
23679
|
$client = new \GuzzleHttp\Client();
|
|
21991
23680
|
|
|
21992
23681
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/threads', [
|
|
23682
|
+
'body' => '{}',
|
|
21993
23683
|
'headers' => [
|
|
21994
23684
|
'Authorization' => 'Bearer <api_key>',
|
|
23685
|
+
'Content-Type' => 'application/json',
|
|
21995
23686
|
],
|
|
21996
23687
|
]);
|
|
21997
23688
|
|
|
@@ -22002,19 +23693,28 @@ echo $response->getBody();
|
|
|
22002
23693
|
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/threads");
|
|
22003
23694
|
var request = new RestRequest(Method.GET);
|
|
22004
23695
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
23696
|
+
request.AddHeader("Content-Type", "application/json");
|
|
23697
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
22005
23698
|
IRestResponse response = client.Execute(request);
|
|
22006
23699
|
```
|
|
22007
23700
|
|
|
22008
23701
|
```swift
|
|
22009
23702
|
import Foundation
|
|
22010
23703
|
|
|
22011
|
-
let headers = [
|
|
23704
|
+
let headers = [
|
|
23705
|
+
"Authorization": "Bearer <api_key>",
|
|
23706
|
+
"Content-Type": "application/json"
|
|
23707
|
+
]
|
|
23708
|
+
let parameters = [] as [String : Any]
|
|
23709
|
+
|
|
23710
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
22012
23711
|
|
|
22013
23712
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/threads")! as URL,
|
|
22014
23713
|
cachePolicy: .useProtocolCachePolicy,
|
|
22015
23714
|
timeoutInterval: 10.0)
|
|
22016
23715
|
request.httpMethod = "GET"
|
|
22017
23716
|
request.allHTTPHeaderFields = headers
|
|
23717
|
+
request.httpBody = postData as Data
|
|
22018
23718
|
|
|
22019
23719
|
let session = URLSession.shared
|
|
22020
23720
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -22145,7 +23845,6 @@ components:
|
|
|
22145
23845
|
required:
|
|
22146
23846
|
- attachment_id
|
|
22147
23847
|
- size
|
|
22148
|
-
- content_disposition
|
|
22149
23848
|
type_threads:ThreadAttachments:
|
|
22150
23849
|
type: array
|
|
22151
23850
|
items:
|
|
@@ -22515,10 +24214,9 @@ paths:
|
|
|
22515
24214
|
'200':
|
|
22516
24215
|
description: Response with status 200
|
|
22517
24216
|
content:
|
|
22518
|
-
application/
|
|
24217
|
+
application/json:
|
|
22519
24218
|
schema:
|
|
22520
|
-
|
|
22521
|
-
format: binary
|
|
24219
|
+
$ref: '#/components/schemas/type_attachments:AttachmentResponse'
|
|
22522
24220
|
'404':
|
|
22523
24221
|
description: Error response with status 404
|
|
22524
24222
|
content: {}
|
|
@@ -22530,6 +24228,46 @@ components:
|
|
|
22530
24228
|
type: string
|
|
22531
24229
|
type_attachments:AttachmentId:
|
|
22532
24230
|
type: string
|
|
24231
|
+
type_attachments:AttachmentFilename:
|
|
24232
|
+
type: string
|
|
24233
|
+
type_attachments:AttachmentSize:
|
|
24234
|
+
type: integer
|
|
24235
|
+
type_attachments:AttachmentContentType:
|
|
24236
|
+
type: string
|
|
24237
|
+
type_attachments:AttachmentContentDisposition:
|
|
24238
|
+
type: string
|
|
24239
|
+
enum:
|
|
24240
|
+
- value: inline
|
|
24241
|
+
- value: attachment
|
|
24242
|
+
type_attachments:AttachmentContentId:
|
|
24243
|
+
type: string
|
|
24244
|
+
type_attachments:AttachmentResponse:
|
|
24245
|
+
type: object
|
|
24246
|
+
properties:
|
|
24247
|
+
attachment_id:
|
|
24248
|
+
$ref: '#/components/schemas/type_attachments:AttachmentId'
|
|
24249
|
+
filename:
|
|
24250
|
+
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
|
|
24251
|
+
size:
|
|
24252
|
+
$ref: '#/components/schemas/type_attachments:AttachmentSize'
|
|
24253
|
+
content_type:
|
|
24254
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
|
|
24255
|
+
content_disposition:
|
|
24256
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
|
|
24257
|
+
content_id:
|
|
24258
|
+
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
|
|
24259
|
+
download_url:
|
|
24260
|
+
type: string
|
|
24261
|
+
description: URL to download the attachment.
|
|
24262
|
+
expires_at:
|
|
24263
|
+
type: string
|
|
24264
|
+
format: date-time
|
|
24265
|
+
description: Time at which the download URL expires.
|
|
24266
|
+
required:
|
|
24267
|
+
- attachment_id
|
|
24268
|
+
- size
|
|
24269
|
+
- download_url
|
|
24270
|
+
- expires_at
|
|
22533
24271
|
|
|
22534
24272
|
```
|
|
22535
24273
|
|
|
@@ -22543,7 +24281,7 @@ async function main() {
|
|
|
22543
24281
|
environment: "https://api.agentmail.to",
|
|
22544
24282
|
apiKey: "YOUR_TOKEN_HERE",
|
|
22545
24283
|
});
|
|
22546
|
-
await client.pods.threads.getAttachment("
|
|
24284
|
+
await client.pods.threads.getAttachment("pod_id", "thread_id", "attachment_id");
|
|
22547
24285
|
}
|
|
22548
24286
|
main();
|
|
22549
24287
|
|
|
@@ -22558,9 +24296,9 @@ client = AgentMail(
|
|
|
22558
24296
|
)
|
|
22559
24297
|
|
|
22560
24298
|
client.pods.threads.get_attachment(
|
|
22561
|
-
pod_id="
|
|
22562
|
-
thread_id="
|
|
22563
|
-
attachment_id="
|
|
24299
|
+
pod_id="pod_id",
|
|
24300
|
+
thread_id="thread_id",
|
|
24301
|
+
attachment_id="attachment_id"
|
|
22564
24302
|
)
|
|
22565
24303
|
|
|
22566
24304
|
```
|
|
@@ -22576,7 +24314,7 @@ import (
|
|
|
22576
24314
|
|
|
22577
24315
|
func main() {
|
|
22578
24316
|
|
|
22579
|
-
url := "https://api.agentmail.to/v0/pods
|
|
24317
|
+
url := "https://api.agentmail.to/v0/pods/pod_id/threads/thread_id/attachments/attachment_id"
|
|
22580
24318
|
|
|
22581
24319
|
req, _ := http.NewRequest("GET", url, nil)
|
|
22582
24320
|
|
|
@@ -22597,7 +24335,7 @@ func main() {
|
|
|
22597
24335
|
require 'uri'
|
|
22598
24336
|
require 'net/http'
|
|
22599
24337
|
|
|
22600
|
-
url = URI("https://api.agentmail.to/v0/pods
|
|
24338
|
+
url = URI("https://api.agentmail.to/v0/pods/pod_id/threads/thread_id/attachments/attachment_id")
|
|
22601
24339
|
|
|
22602
24340
|
http = Net::HTTP.new(url.host, url.port)
|
|
22603
24341
|
http.use_ssl = true
|
|
@@ -22610,7 +24348,7 @@ puts response.read_body
|
|
|
22610
24348
|
```
|
|
22611
24349
|
|
|
22612
24350
|
```java
|
|
22613
|
-
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods
|
|
24351
|
+
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/threads/thread_id/attachments/attachment_id")
|
|
22614
24352
|
.header("Authorization", "Bearer <api_key>")
|
|
22615
24353
|
.asString();
|
|
22616
24354
|
```
|
|
@@ -22620,7 +24358,7 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/%3
|
|
|
22620
24358
|
|
|
22621
24359
|
$client = new \GuzzleHttp\Client();
|
|
22622
24360
|
|
|
22623
|
-
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods
|
|
24361
|
+
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/threads/thread_id/attachments/attachment_id', [
|
|
22624
24362
|
'headers' => [
|
|
22625
24363
|
'Authorization' => 'Bearer <api_key>',
|
|
22626
24364
|
],
|
|
@@ -22630,7 +24368,7 @@ echo $response->getBody();
|
|
|
22630
24368
|
```
|
|
22631
24369
|
|
|
22632
24370
|
```csharp
|
|
22633
|
-
var client = new RestClient("https://api.agentmail.to/v0/pods
|
|
24371
|
+
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/threads/thread_id/attachments/attachment_id");
|
|
22634
24372
|
var request = new RestRequest(Method.GET);
|
|
22635
24373
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
22636
24374
|
IRestResponse response = client.Execute(request);
|
|
@@ -22641,7 +24379,7 @@ import Foundation
|
|
|
22641
24379
|
|
|
22642
24380
|
let headers = ["Authorization": "Bearer <api_key>"]
|
|
22643
24381
|
|
|
22644
|
-
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods
|
|
24382
|
+
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/threads/thread_id/attachments/attachment_id")! as URL,
|
|
22645
24383
|
cachePolicy: .useProtocolCachePolicy,
|
|
22646
24384
|
timeoutInterval: 10.0)
|
|
22647
24385
|
request.httpMethod = "GET"
|
|
@@ -22816,7 +24554,6 @@ components:
|
|
|
22816
24554
|
required:
|
|
22817
24555
|
- attachment_id
|
|
22818
24556
|
- size
|
|
22819
|
-
- content_disposition
|
|
22820
24557
|
type_drafts:DraftAttachments:
|
|
22821
24558
|
type: array
|
|
22822
24559
|
items:
|
|
@@ -23136,7 +24873,6 @@ components:
|
|
|
23136
24873
|
required:
|
|
23137
24874
|
- attachment_id
|
|
23138
24875
|
- size
|
|
23139
|
-
- content_disposition
|
|
23140
24876
|
type_drafts:DraftAttachments:
|
|
23141
24877
|
type: array
|
|
23142
24878
|
items:
|
|
@@ -23489,6 +25225,7 @@ package main
|
|
|
23489
25225
|
|
|
23490
25226
|
import (
|
|
23491
25227
|
"fmt"
|
|
25228
|
+
"strings"
|
|
23492
25229
|
"net/http"
|
|
23493
25230
|
"io"
|
|
23494
25231
|
)
|
|
@@ -23497,9 +25234,12 @@ func main() {
|
|
|
23497
25234
|
|
|
23498
25235
|
url := "https://api.agentmail.to/v0/pods/pod_id/domains"
|
|
23499
25236
|
|
|
23500
|
-
|
|
25237
|
+
payload := strings.NewReader("{}")
|
|
25238
|
+
|
|
25239
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
23501
25240
|
|
|
23502
25241
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
25242
|
+
req.Header.Add("Content-Type", "application/json")
|
|
23503
25243
|
|
|
23504
25244
|
res, _ := http.DefaultClient.Do(req)
|
|
23505
25245
|
|
|
@@ -23523,6 +25263,8 @@ http.use_ssl = true
|
|
|
23523
25263
|
|
|
23524
25264
|
request = Net::HTTP::Get.new(url)
|
|
23525
25265
|
request["Authorization"] = 'Bearer <api_key>'
|
|
25266
|
+
request["Content-Type"] = 'application/json'
|
|
25267
|
+
request.body = "{}"
|
|
23526
25268
|
|
|
23527
25269
|
response = http.request(request)
|
|
23528
25270
|
puts response.read_body
|
|
@@ -23531,6 +25273,8 @@ puts response.read_body
|
|
|
23531
25273
|
```java
|
|
23532
25274
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/pod_id/domains")
|
|
23533
25275
|
.header("Authorization", "Bearer <api_key>")
|
|
25276
|
+
.header("Content-Type", "application/json")
|
|
25277
|
+
.body("{}")
|
|
23534
25278
|
.asString();
|
|
23535
25279
|
```
|
|
23536
25280
|
|
|
@@ -23540,8 +25284,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/pods/po
|
|
|
23540
25284
|
$client = new \GuzzleHttp\Client();
|
|
23541
25285
|
|
|
23542
25286
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/pods/pod_id/domains', [
|
|
25287
|
+
'body' => '{}',
|
|
23543
25288
|
'headers' => [
|
|
23544
25289
|
'Authorization' => 'Bearer <api_key>',
|
|
25290
|
+
'Content-Type' => 'application/json',
|
|
23545
25291
|
],
|
|
23546
25292
|
]);
|
|
23547
25293
|
|
|
@@ -23552,19 +25298,28 @@ echo $response->getBody();
|
|
|
23552
25298
|
var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/domains");
|
|
23553
25299
|
var request = new RestRequest(Method.GET);
|
|
23554
25300
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
25301
|
+
request.AddHeader("Content-Type", "application/json");
|
|
25302
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
23555
25303
|
IRestResponse response = client.Execute(request);
|
|
23556
25304
|
```
|
|
23557
25305
|
|
|
23558
25306
|
```swift
|
|
23559
25307
|
import Foundation
|
|
23560
25308
|
|
|
23561
|
-
let headers = [
|
|
25309
|
+
let headers = [
|
|
25310
|
+
"Authorization": "Bearer <api_key>",
|
|
25311
|
+
"Content-Type": "application/json"
|
|
25312
|
+
]
|
|
25313
|
+
let parameters = [] as [String : Any]
|
|
25314
|
+
|
|
25315
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
23562
25316
|
|
|
23563
25317
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/pods/pod_id/domains")! as URL,
|
|
23564
25318
|
cachePolicy: .useProtocolCachePolicy,
|
|
23565
25319
|
timeoutInterval: 10.0)
|
|
23566
25320
|
request.httpMethod = "GET"
|
|
23567
25321
|
request.allHTTPHeaderFields = headers
|
|
25322
|
+
request.httpBody = postData as Data
|
|
23568
25323
|
|
|
23569
25324
|
let session = URLSession.shared
|
|
23570
25325
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|
|
@@ -23744,7 +25499,7 @@ async function main() {
|
|
|
23744
25499
|
apiKey: "YOUR_TOKEN_HERE",
|
|
23745
25500
|
});
|
|
23746
25501
|
await client.pods.domains.create("pod_id", {
|
|
23747
|
-
domain: "
|
|
25502
|
+
domain: "example.com",
|
|
23748
25503
|
feedbackEnabled: true,
|
|
23749
25504
|
});
|
|
23750
25505
|
}
|
|
@@ -23762,7 +25517,7 @@ client = AgentMail(
|
|
|
23762
25517
|
|
|
23763
25518
|
client.pods.domains.create(
|
|
23764
25519
|
pod_id="pod_id",
|
|
23765
|
-
domain="
|
|
25520
|
+
domain="example.com",
|
|
23766
25521
|
feedback_enabled=True
|
|
23767
25522
|
)
|
|
23768
25523
|
|
|
@@ -23782,7 +25537,7 @@ func main() {
|
|
|
23782
25537
|
|
|
23783
25538
|
url := "https://api.agentmail.to/v0/pods/pod_id/domains"
|
|
23784
25539
|
|
|
23785
|
-
payload := strings.NewReader("{\n \"domain\": \"
|
|
25540
|
+
payload := strings.NewReader("{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}")
|
|
23786
25541
|
|
|
23787
25542
|
req, _ := http.NewRequest("POST", url, payload)
|
|
23788
25543
|
|
|
@@ -23812,7 +25567,7 @@ http.use_ssl = true
|
|
|
23812
25567
|
request = Net::HTTP::Post.new(url)
|
|
23813
25568
|
request["Authorization"] = 'Bearer <api_key>'
|
|
23814
25569
|
request["Content-Type"] = 'application/json'
|
|
23815
|
-
request.body = "{\n \"domain\": \"
|
|
25570
|
+
request.body = "{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}"
|
|
23816
25571
|
|
|
23817
25572
|
response = http.request(request)
|
|
23818
25573
|
puts response.read_body
|
|
@@ -23822,7 +25577,7 @@ puts response.read_body
|
|
|
23822
25577
|
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/pods/pod_id/domains")
|
|
23823
25578
|
.header("Authorization", "Bearer <api_key>")
|
|
23824
25579
|
.header("Content-Type", "application/json")
|
|
23825
|
-
.body("{\n \"domain\": \"
|
|
25580
|
+
.body("{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}")
|
|
23826
25581
|
.asString();
|
|
23827
25582
|
```
|
|
23828
25583
|
|
|
@@ -23833,7 +25588,7 @@ $client = new \GuzzleHttp\Client();
|
|
|
23833
25588
|
|
|
23834
25589
|
$response = $client->request('POST', 'https://api.agentmail.to/v0/pods/pod_id/domains', [
|
|
23835
25590
|
'body' => '{
|
|
23836
|
-
"domain": "
|
|
25591
|
+
"domain": "example.com",
|
|
23837
25592
|
"feedback_enabled": true
|
|
23838
25593
|
}',
|
|
23839
25594
|
'headers' => [
|
|
@@ -23850,7 +25605,7 @@ var client = new RestClient("https://api.agentmail.to/v0/pods/pod_id/domains");
|
|
|
23850
25605
|
var request = new RestRequest(Method.POST);
|
|
23851
25606
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
23852
25607
|
request.AddHeader("Content-Type", "application/json");
|
|
23853
|
-
request.AddParameter("application/json", "{\n \"domain\": \"
|
|
25608
|
+
request.AddParameter("application/json", "{\n \"domain\": \"example.com\",\n \"feedback_enabled\": true\n}", ParameterType.RequestBody);
|
|
23854
25609
|
IRestResponse response = client.Execute(request);
|
|
23855
25610
|
```
|
|
23856
25611
|
|
|
@@ -23862,7 +25617,7 @@ let headers = [
|
|
|
23862
25617
|
"Content-Type": "application/json"
|
|
23863
25618
|
]
|
|
23864
25619
|
let parameters = [
|
|
23865
|
-
"domain": "
|
|
25620
|
+
"domain": "example.com",
|
|
23866
25621
|
"feedback_enabled": true
|
|
23867
25622
|
] as [String : Any]
|
|
23868
25623
|
|
|
@@ -24179,6 +25934,7 @@ package main
|
|
|
24179
25934
|
|
|
24180
25935
|
import (
|
|
24181
25936
|
"fmt"
|
|
25937
|
+
"strings"
|
|
24182
25938
|
"net/http"
|
|
24183
25939
|
"io"
|
|
24184
25940
|
)
|
|
@@ -24187,9 +25943,12 @@ func main() {
|
|
|
24187
25943
|
|
|
24188
25944
|
url := "https://api.agentmail.to/v0/organizations"
|
|
24189
25945
|
|
|
24190
|
-
|
|
25946
|
+
payload := strings.NewReader("{}")
|
|
25947
|
+
|
|
25948
|
+
req, _ := http.NewRequest("GET", url, payload)
|
|
24191
25949
|
|
|
24192
25950
|
req.Header.Add("Authorization", "Bearer <api_key>")
|
|
25951
|
+
req.Header.Add("Content-Type", "application/json")
|
|
24193
25952
|
|
|
24194
25953
|
res, _ := http.DefaultClient.Do(req)
|
|
24195
25954
|
|
|
@@ -24213,6 +25972,8 @@ http.use_ssl = true
|
|
|
24213
25972
|
|
|
24214
25973
|
request = Net::HTTP::Get.new(url)
|
|
24215
25974
|
request["Authorization"] = 'Bearer <api_key>'
|
|
25975
|
+
request["Content-Type"] = 'application/json'
|
|
25976
|
+
request.body = "{}"
|
|
24216
25977
|
|
|
24217
25978
|
response = http.request(request)
|
|
24218
25979
|
puts response.read_body
|
|
@@ -24221,6 +25982,8 @@ puts response.read_body
|
|
|
24221
25982
|
```java
|
|
24222
25983
|
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/organizations")
|
|
24223
25984
|
.header("Authorization", "Bearer <api_key>")
|
|
25985
|
+
.header("Content-Type", "application/json")
|
|
25986
|
+
.body("{}")
|
|
24224
25987
|
.asString();
|
|
24225
25988
|
```
|
|
24226
25989
|
|
|
@@ -24230,8 +25993,10 @@ HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/organiz
|
|
|
24230
25993
|
$client = new \GuzzleHttp\Client();
|
|
24231
25994
|
|
|
24232
25995
|
$response = $client->request('GET', 'https://api.agentmail.to/v0/organizations', [
|
|
25996
|
+
'body' => '{}',
|
|
24233
25997
|
'headers' => [
|
|
24234
25998
|
'Authorization' => 'Bearer <api_key>',
|
|
25999
|
+
'Content-Type' => 'application/json',
|
|
24235
26000
|
],
|
|
24236
26001
|
]);
|
|
24237
26002
|
|
|
@@ -24242,19 +26007,28 @@ echo $response->getBody();
|
|
|
24242
26007
|
var client = new RestClient("https://api.agentmail.to/v0/organizations");
|
|
24243
26008
|
var request = new RestRequest(Method.GET);
|
|
24244
26009
|
request.AddHeader("Authorization", "Bearer <api_key>");
|
|
26010
|
+
request.AddHeader("Content-Type", "application/json");
|
|
26011
|
+
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
|
|
24245
26012
|
IRestResponse response = client.Execute(request);
|
|
24246
26013
|
```
|
|
24247
26014
|
|
|
24248
26015
|
```swift
|
|
24249
26016
|
import Foundation
|
|
24250
26017
|
|
|
24251
|
-
let headers = [
|
|
26018
|
+
let headers = [
|
|
26019
|
+
"Authorization": "Bearer <api_key>",
|
|
26020
|
+
"Content-Type": "application/json"
|
|
26021
|
+
]
|
|
26022
|
+
let parameters = [] as [String : Any]
|
|
26023
|
+
|
|
26024
|
+
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
|
|
24252
26025
|
|
|
24253
26026
|
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/organizations")! as URL,
|
|
24254
26027
|
cachePolicy: .useProtocolCachePolicy,
|
|
24255
26028
|
timeoutInterval: 10.0)
|
|
24256
26029
|
request.httpMethod = "GET"
|
|
24257
26030
|
request.allHTTPHeaderFields = headers
|
|
26031
|
+
request.httpBody = postData as Data
|
|
24258
26032
|
|
|
24259
26033
|
let session = URLSession.shared
|
|
24260
26034
|
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
|