Appearance
Messages
Fresh 🌱AgentMail REST API reference for Messages. Base URL
https://api.agentmail.to/v0. Authenticate withAuthorization: Bearer <API_KEY>.
Send Message
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/send Content-Type: application/json
CLI:
bash
agentmail inboxes:messages send --inbox-id <inbox_id> --to recipient@example.com --subject "Hello" --text "Body"OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/send:
post:
operationId: send
summary: Send Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages send --inbox-id <inbox_id> --to
recipient@example.com --subject "Hello" --text "Body"
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
'403':
description: Error response with status 403
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageRequest'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:Addresses:
oneOf:
- type: string
- type: array
items:
type: string
title: Addresses
type_messages:SendMessageReplyTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Reply-to address or addresses.
title: SendMessageReplyTo
type_messages:SendMessageTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Recipient address or addresses.
title: SendMessageTo
type_messages:SendMessageCc:
$ref: '#/components/schemas/type_messages:Addresses'
description: CC recipient address or addresses.
title: SendMessageCc
type_messages:SendMessageBcc:
$ref: '#/components/schemas/type_messages:Addresses'
description: BCC recipient address or addresses.
title: SendMessageBcc
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:MessageText:
type: string
description: Plain text body of message.
title: MessageText
type_messages:MessageHtml:
type: string
description: HTML body of message.
title: MessageHtml
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:SendAttachment:
type: object
properties:
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
content:
type: string
description: Base64 encoded content of attachment.
url:
type: string
description: URL to the attachment.
title: SendAttachment
type_messages:SendMessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:SendAttachment'
description: Attachments to include in message.
title: SendMessageAttachments
type_messages:SendMessageHeaders:
type: object
additionalProperties:
type: string
description: Headers to include in message.
title: SendMessageHeaders
type_messages:SendMessageRequest:
type: object
properties:
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
reply_to:
$ref: '#/components/schemas/type_messages:SendMessageReplyTo'
to:
$ref: '#/components/schemas/type_messages:SendMessageTo'
cc:
$ref: '#/components/schemas/type_messages:SendMessageCc'
bcc:
$ref: '#/components/schemas/type_messages:SendMessageBcc'
subject:
$ref: '#/components/schemas/type_messages:MessageSubject'
text:
$ref: '#/components/schemas/type_messages:MessageText'
html:
$ref: '#/components/schemas/type_messages:MessageHtml'
attachments:
$ref: '#/components/schemas/type_messages:SendMessageAttachments'
headers:
$ref: '#/components/schemas/type_messages:SendMessageHeaders'
title: SendMessageRequest
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:SendMessageResponse:
type: object
properties:
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
required:
- message_id
- thread_id
title: SendMessageResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Request
json
{}Response
json
{
"message_id": "message_id",
"thread_id": "thread_id"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.send("inbox_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.send(
inbox_id="inbox_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/send"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <api_key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/send")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes/inbox_id/messages/send")
.header("Authorization", "Bearer <api_key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/send', [
'body' => '{}',
'headers' => [
'Authorization' => 'Bearer <api_key>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/send");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = [
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/send")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Reply
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}/reply Content-Type: application/json
CLI:
bash
agentmail inboxes:messages reply --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}/reply:
post:
operationId: reply
summary: Reply To Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages reply --inbox-id <inbox_id> --message-id
<message_id> --text "Reply text"
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
'403':
description: Error response with status 403
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:ReplyToMessageRequest'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:Addresses:
oneOf:
- type: string
- type: array
items:
type: string
title: Addresses
type_messages:SendMessageReplyTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Reply-to address or addresses.
title: SendMessageReplyTo
type_messages:SendMessageTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Recipient address or addresses.
title: SendMessageTo
type_messages:SendMessageCc:
$ref: '#/components/schemas/type_messages:Addresses'
description: CC recipient address or addresses.
title: SendMessageCc
type_messages:SendMessageBcc:
$ref: '#/components/schemas/type_messages:Addresses'
description: BCC recipient address or addresses.
title: SendMessageBcc
type_messages:ReplyAll:
type: boolean
description: Reply to all recipients of the original message.
title: ReplyAll
type_messages:MessageText:
type: string
description: Plain text body of message.
title: MessageText
type_messages:MessageHtml:
type: string
description: HTML body of message.
title: MessageHtml
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:SendAttachment:
type: object
properties:
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
content:
type: string
description: Base64 encoded content of attachment.
url:
type: string
description: URL to the attachment.
title: SendAttachment
type_messages:SendMessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:SendAttachment'
description: Attachments to include in message.
title: SendMessageAttachments
type_messages:SendMessageHeaders:
type: object
additionalProperties:
type: string
description: Headers to include in message.
title: SendMessageHeaders
type_messages:ReplyToMessageRequest:
type: object
properties:
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
reply_to:
$ref: '#/components/schemas/type_messages:SendMessageReplyTo'
to:
$ref: '#/components/schemas/type_messages:SendMessageTo'
cc:
$ref: '#/components/schemas/type_messages:SendMessageCc'
bcc:
$ref: '#/components/schemas/type_messages:SendMessageBcc'
reply_all:
$ref: '#/components/schemas/type_messages:ReplyAll'
text:
$ref: '#/components/schemas/type_messages:MessageText'
html:
$ref: '#/components/schemas/type_messages:MessageHtml'
attachments:
$ref: '#/components/schemas/type_messages:SendMessageAttachments'
headers:
$ref: '#/components/schemas/type_messages:SendMessageHeaders'
title: ReplyToMessageRequest
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:SendMessageResponse:
type: object
properties:
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
required:
- message_id
- thread_id
title: SendMessageResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Request
json
{}Response
json
{
"message_id": "message_id",
"thread_id": "thread_id"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.reply("inbox_id", "message_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.reply(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <api_key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply")
.header("Authorization", "Bearer <api_key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply', [
'body' => '{}',
'headers' => [
'Authorization' => 'Bearer <api_key>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = [
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Reply All
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}/reply-all Content-Type: application/json
CLI:
bash
agentmail inboxes:messages reply-all --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}/reply-all:
post:
operationId: reply-all
summary: Reply All Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages reply-all --inbox-id <inbox_id> --message-id
<message_id> --text "Reply text"
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
'403':
description: Error response with status 403
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:ReplyAllMessageRequest'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:Addresses:
oneOf:
- type: string
- type: array
items:
type: string
title: Addresses
type_messages:SendMessageReplyTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Reply-to address or addresses.
title: SendMessageReplyTo
type_messages:MessageText:
type: string
description: Plain text body of message.
title: MessageText
type_messages:MessageHtml:
type: string
description: HTML body of message.
title: MessageHtml
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:SendAttachment:
type: object
properties:
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
content:
type: string
description: Base64 encoded content of attachment.
url:
type: string
description: URL to the attachment.
title: SendAttachment
type_messages:SendMessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:SendAttachment'
description: Attachments to include in message.
title: SendMessageAttachments
type_messages:SendMessageHeaders:
type: object
additionalProperties:
type: string
description: Headers to include in message.
title: SendMessageHeaders
type_messages:ReplyAllMessageRequest:
type: object
properties:
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
reply_to:
$ref: '#/components/schemas/type_messages:SendMessageReplyTo'
text:
$ref: '#/components/schemas/type_messages:MessageText'
html:
$ref: '#/components/schemas/type_messages:MessageHtml'
attachments:
$ref: '#/components/schemas/type_messages:SendMessageAttachments'
headers:
$ref: '#/components/schemas/type_messages:SendMessageHeaders'
title: ReplyAllMessageRequest
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:SendMessageResponse:
type: object
properties:
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
required:
- message_id
- thread_id
title: SendMessageResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Request
json
{}Response
json
{
"message_id": "message_id",
"thread_id": "thread_id"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.replyAll("inbox_id", "message_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.reply_all(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply-all"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <api_key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply-all")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply-all")
.header("Authorization", "Bearer <api_key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply-all', [
'body' => '{}',
'headers' => [
'Authorization' => 'Bearer <api_key>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply-all");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = [
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/reply-all")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Forward
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}/forward Content-Type: application/json
CLI:
bash
agentmail inboxes:messages forward --inbox-id <inbox_id> --message-id <message_id> --to recipient@example.comOpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}/forward:
post:
operationId: forward
summary: Forward Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages forward --inbox-id <inbox_id> --message-id
<message_id> --to recipient@example.com
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
'403':
description: Error response with status 403
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageRequest'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:Addresses:
oneOf:
- type: string
- type: array
items:
type: string
title: Addresses
type_messages:SendMessageReplyTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Reply-to address or addresses.
title: SendMessageReplyTo
type_messages:SendMessageTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Recipient address or addresses.
title: SendMessageTo
type_messages:SendMessageCc:
$ref: '#/components/schemas/type_messages:Addresses'
description: CC recipient address or addresses.
title: SendMessageCc
type_messages:SendMessageBcc:
$ref: '#/components/schemas/type_messages:Addresses'
description: BCC recipient address or addresses.
title: SendMessageBcc
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:MessageText:
type: string
description: Plain text body of message.
title: MessageText
type_messages:MessageHtml:
type: string
description: HTML body of message.
title: MessageHtml
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:SendAttachment:
type: object
properties:
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
content:
type: string
description: Base64 encoded content of attachment.
url:
type: string
description: URL to the attachment.
title: SendAttachment
type_messages:SendMessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:SendAttachment'
description: Attachments to include in message.
title: SendMessageAttachments
type_messages:SendMessageHeaders:
type: object
additionalProperties:
type: string
description: Headers to include in message.
title: SendMessageHeaders
type_messages:SendMessageRequest:
type: object
properties:
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
reply_to:
$ref: '#/components/schemas/type_messages:SendMessageReplyTo'
to:
$ref: '#/components/schemas/type_messages:SendMessageTo'
cc:
$ref: '#/components/schemas/type_messages:SendMessageCc'
bcc:
$ref: '#/components/schemas/type_messages:SendMessageBcc'
subject:
$ref: '#/components/schemas/type_messages:MessageSubject'
text:
$ref: '#/components/schemas/type_messages:MessageText'
html:
$ref: '#/components/schemas/type_messages:MessageHtml'
attachments:
$ref: '#/components/schemas/type_messages:SendMessageAttachments'
headers:
$ref: '#/components/schemas/type_messages:SendMessageHeaders'
title: SendMessageRequest
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:SendMessageResponse:
type: object
properties:
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
required:
- message_id
- thread_id
title: SendMessageResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Request
json
{}Response
json
{
"message_id": "message_id",
"thread_id": "thread_id"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.forward("inbox_id", "message_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.forward(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/forward"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <api_key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/forward")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/forward")
.header("Authorization", "Bearer <api_key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/forward', [
'body' => '{}',
'headers' => [
'Authorization' => 'Bearer <api_key>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/forward");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = [
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/forward")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Get Message
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}
CLI:
bash
agentmail inboxes:messages get --inbox-id <inbox_id> --message-id <message_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}:
get:
operationId: get
summary: Get Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages get --inbox-id <inbox_id> --message-id
<message_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:Message'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:MessageTimestamp:
type: string
format: date-time
description: Time at which message was sent or drafted.
title: MessageTimestamp
type_messages:MessageFrom:
type: string
description: >-
Address of sender. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: MessageFrom
type_messages:MessageTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageTo
type_messages:MessageCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageCc
type_messages:MessageBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageBcc
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:MessagePreview:
type: string
description: Text preview of message.
title: MessagePreview
type_messages:MessageText:
type: string
description: Plain text body of message.
title: MessageText
type_messages:MessageHtml:
type: string
description: HTML body of message.
title: MessageHtml
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_messages:MessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in message.
title: MessageAttachments
type_messages:MessageInReplyTo:
type: string
description: ID of message being replied to.
title: MessageInReplyTo
type_messages:MessageReferences:
type: array
items:
type: string
description: IDs of previous messages in thread.
title: MessageReferences
type_messages:MessageHeaders:
type: object
additionalProperties:
type: string
description: Headers in message.
title: MessageHeaders
type_messages:MessageSize:
type: integer
description: Size of message in bytes.
title: MessageSize
type_messages:MessageUpdatedAt:
type: string
format: date-time
description: Time at which message was last updated.
title: MessageUpdatedAt
type_messages:MessageCreatedAt:
type: string
format: date-time
description: Time at which message was created.
title: MessageCreatedAt
type_messages:Message:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
timestamp:
$ref: '#/components/schemas/type_messages:MessageTimestamp'
from:
$ref: '#/components/schemas/type_messages:MessageFrom'
reply_to:
type: array
items:
type: string
description: >-
Reply-to addresses. In format `username@domain.com` or `Display Name
<username@domain.com>`.
to:
$ref: '#/components/schemas/type_messages:MessageTo'
cc:
$ref: '#/components/schemas/type_messages:MessageCc'
bcc:
$ref: '#/components/schemas/type_messages:MessageBcc'
subject:
$ref: '#/components/schemas/type_messages:MessageSubject'
preview:
$ref: '#/components/schemas/type_messages:MessagePreview'
text:
$ref: '#/components/schemas/type_messages:MessageText'
html:
$ref: '#/components/schemas/type_messages:MessageHtml'
extracted_text:
type: string
description: Extracted new text content.
extracted_html:
type: string
description: Extracted new HTML content.
attachments:
$ref: '#/components/schemas/type_messages:MessageAttachments'
in_reply_to:
$ref: '#/components/schemas/type_messages:MessageInReplyTo'
references:
$ref: '#/components/schemas/type_messages:MessageReferences'
headers:
$ref: '#/components/schemas/type_messages:MessageHeaders'
size:
$ref: '#/components/schemas/type_messages:MessageSize'
updated_at:
$ref: '#/components/schemas/type_messages:MessageUpdatedAt'
created_at:
$ref: '#/components/schemas/type_messages:MessageCreatedAt'
required:
- inbox_id
- thread_id
- message_id
- labels
- timestamp
- from
- to
- size
- updated_at
- created_at
title: Message
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"inbox_id": "inbox_id",
"thread_id": "thread_id",
"message_id": "message_id",
"labels": [
"labels",
"labels"
],
"timestamp": "2024-01-15T09:30:00Z",
"from": "from",
"to": [
"to",
"to"
],
"size": 1,
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"reply_to": [
"reply_to",
"reply_to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"text": "text",
"html": "html",
"extracted_text": "extracted_text",
"extracted_html": "extracted_html",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"headers": {
"headers": "headers"
}
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.get("inbox_id", "message_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.get(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Batch Get Messages
POST https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/batch-get Content-Type: application/json
Fetch metadata for up to 500 messages in one request. Missing or restricted IDs are silently omitted; compare count against limit to detect misses.
CLI:
bash
agentmail inboxes:messages batch-get --inbox-id <inbox_id> --message-id <id1> --message-id <id2>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/batch-get:
post:
operationId: batch-get
summary: Batch Get Messages
description: >-
Fetch metadata for up to 500 messages in one request. Missing or
restricted IDs are silently omitted; compare `count` against `limit`
to detect misses.
**CLI:**
```bash
agentmail inboxes:messages batch-get --inbox-id <inbox_id> --message-id
<id1> --message-id <id2>
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:BatchGetMessagesResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:BatchGetMessagesRequest'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:BatchGetMessagesMessageIds:
type: array
items:
$ref: '#/components/schemas/type_messages:MessageId'
description: |-
IDs of messages to fetch. Maximum 500 ids per request. Duplicates are
rejected with a validation error. IDs not found in the inbox (including
cross-inbox or permission-restricted) are silently omitted from the
response; callers detect misses by comparing `count` against `limit`.
title: BatchGetMessagesMessageIds
type_messages:BatchGetMessagesRequest:
type: object
properties:
message_ids:
$ref: '#/components/schemas/type_messages:BatchGetMessagesMessageIds'
required:
- message_ids
title: BatchGetMessagesRequest
type_:Limit:
type: integer
description: Limit of number of items returned.
title: Limit
type_:Count:
type: integer
description: Number of items returned.
title: Count
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:MessageTimestamp:
type: string
format: date-time
description: Time at which message was sent or drafted.
title: MessageTimestamp
type_messages:MessageFrom:
type: string
description: >-
Address of sender. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: MessageFrom
type_messages:MessageTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageTo
type_messages:MessageCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageCc
type_messages:MessageBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageBcc
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:MessagePreview:
type: string
description: Text preview of message.
title: MessagePreview
type_messages:MessageText:
type: string
description: Plain text body of message.
title: MessageText
type_messages:MessageHtml:
type: string
description: HTML body of message.
title: MessageHtml
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_messages:MessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in message.
title: MessageAttachments
type_messages:MessageInReplyTo:
type: string
description: ID of message being replied to.
title: MessageInReplyTo
type_messages:MessageReferences:
type: array
items:
type: string
description: IDs of previous messages in thread.
title: MessageReferences
type_messages:MessageHeaders:
type: object
additionalProperties:
type: string
description: Headers in message.
title: MessageHeaders
type_messages:MessageSize:
type: integer
description: Size of message in bytes.
title: MessageSize
type_messages:MessageUpdatedAt:
type: string
format: date-time
description: Time at which message was last updated.
title: MessageUpdatedAt
type_messages:MessageCreatedAt:
type: string
format: date-time
description: Time at which message was created.
title: MessageCreatedAt
type_messages:Message:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
timestamp:
$ref: '#/components/schemas/type_messages:MessageTimestamp'
from:
$ref: '#/components/schemas/type_messages:MessageFrom'
reply_to:
type: array
items:
type: string
description: >-
Reply-to addresses. In format `username@domain.com` or `Display Name
<username@domain.com>`.
to:
$ref: '#/components/schemas/type_messages:MessageTo'
cc:
$ref: '#/components/schemas/type_messages:MessageCc'
bcc:
$ref: '#/components/schemas/type_messages:MessageBcc'
subject:
$ref: '#/components/schemas/type_messages:MessageSubject'
preview:
$ref: '#/components/schemas/type_messages:MessagePreview'
text:
$ref: '#/components/schemas/type_messages:MessageText'
html:
$ref: '#/components/schemas/type_messages:MessageHtml'
extracted_text:
type: string
description: Extracted new text content.
extracted_html:
type: string
description: Extracted new HTML content.
attachments:
$ref: '#/components/schemas/type_messages:MessageAttachments'
in_reply_to:
$ref: '#/components/schemas/type_messages:MessageInReplyTo'
references:
$ref: '#/components/schemas/type_messages:MessageReferences'
headers:
$ref: '#/components/schemas/type_messages:MessageHeaders'
size:
$ref: '#/components/schemas/type_messages:MessageSize'
updated_at:
$ref: '#/components/schemas/type_messages:MessageUpdatedAt'
created_at:
$ref: '#/components/schemas/type_messages:MessageCreatedAt'
required:
- inbox_id
- thread_id
- message_id
- labels
- timestamp
- from
- to
- size
- updated_at
- created_at
title: Message
type_messages:BatchGetMessagesResponse:
type: object
properties:
limit:
$ref: '#/components/schemas/type_:Limit'
count:
$ref: '#/components/schemas/type_:Count'
messages:
type: array
items:
$ref: '#/components/schemas/type_messages:Message'
description: |-
Found messages. Order matches `message_ids` in the request. Body
fields (`text`, `html`, `extracted_text`, `extracted_html`) are
never populated; use the single-message endpoint to retrieve bodies.
required:
- limit
- count
- messages
title: BatchGetMessagesResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Request
json
{
"message_ids": [
"message_ids",
"message_ids"
]
}Response
json
{
"limit": 1,
"count": 1,
"messages": [
{
"inbox_id": "inbox_id",
"thread_id": "thread_id",
"message_id": "message_id",
"labels": [
"labels",
"labels"
],
"timestamp": "2024-01-15T09:30:00Z",
"from": "from",
"to": [
"to",
"to"
],
"size": 1,
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"reply_to": [
"reply_to",
"reply_to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"text": "text",
"html": "html",
"extracted_text": "extracted_text",
"extracted_html": "extracted_html",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"headers": {
"headers": "headers"
}
},
{
"inbox_id": "inbox_id",
"thread_id": "thread_id",
"message_id": "message_id",
"labels": [
"labels",
"labels"
],
"timestamp": "2024-01-15T09:30:00Z",
"from": "from",
"to": [
"to",
"to"
],
"size": 1,
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"reply_to": [
"reply_to",
"reply_to"
],
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"text": "text",
"html": "html",
"extracted_text": "extracted_text",
"extracted_html": "extracted_html",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"headers": {
"headers": "headers"
}
}
]
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.batchGet("inbox_id", {
messageIds: [
"message_ids",
"message_ids",
],
});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.batch_get(
inbox_id="inbox_id",
message_ids=[
"message_ids",
"message_ids"
],
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/batch-get"
payload := strings.NewReader("{\n \"message_ids\": [\n \"message_ids\",\n \"message_ids\"\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <api_key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/batch-get")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"message_ids\": [\n \"message_ids\",\n \"message_ids\"\n ]\n}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/inboxes/inbox_id/messages/batch-get")
.header("Authorization", "Bearer <api_key>")
.header("Content-Type", "application/json")
.body("{\n \"message_ids\": [\n \"message_ids\",\n \"message_ids\"\n ]\n}")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('POST', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/batch-get', [
'body' => '{
"message_ids": [
"message_ids",
"message_ids"
]
}',
'headers' => [
'Authorization' => 'Bearer <api_key>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/batch-get");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n \"message_ids\": [\n \"message_ids\",\n \"message_ids\"\n ]\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = [
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
]
let parameters = ["message_ids": ["message_ids", "message_ids"]] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/batch-get")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()List Messages
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/messages
Lists messages in the inbox, most recent first. Pass from, to, or subject to filter by substring. Filtered requests are served by search, which caps limit at 100. For relevance-ranked full-text search across sender, recipients, subject, and message body, use Search Messages.
CLI:
bash
agentmail inboxes:messages list --inbox-id <inbox_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages:
get:
operationId: list
summary: List Messages
description: |-
Lists messages in the inbox, most recent first. Pass `from`, `to`, or
`subject` to filter by substring. Filtered requests are served by
search, which caps `limit` at 100. For relevance-ranked full-text
search across sender, recipients, subject, and message body, use
`Search Messages`.
**CLI:**
```bash
agentmail inboxes:messages list --inbox-id <inbox_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: limit
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Limit'
- name: page_token
in: query
required: false
schema:
$ref: '#/components/schemas/type_:PageToken'
- name: labels
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Labels'
- name: before
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Before'
- name: after
in: query
required: false
schema:
$ref: '#/components/schemas/type_:After'
- name: ascending
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Ascending'
- name: include_spam
in: query
required: false
schema:
$ref: '#/components/schemas/type_:IncludeSpam'
- name: include_blocked
in: query
required: false
schema:
$ref: '#/components/schemas/type_:IncludeBlocked'
- name: include_unauthenticated
in: query
required: false
schema:
$ref: '#/components/schemas/type_:IncludeUnauthenticated'
- name: include_trash
in: query
required: false
schema:
$ref: '#/components/schemas/type_:IncludeTrash'
- name: from
in: query
description: >-
Filter to messages whose sender contains this value (substring
match). Repeatable; all values must match.
required: false
schema:
type: array
items:
type: string
- name: to
in: query
description: >-
Filter to messages whose recipients (to, cc, or bcc) contain this
value (substring match). Repeatable; all values must match.
required: false
schema:
type: array
items:
type: string
- name: subject
in: query
description: >-
Filter to messages whose subject contains this value (substring
match). Repeatable; all values must match.
required: false
schema:
type: array
items:
type: string
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:ListMessagesResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_:Limit:
type: integer
description: Limit of number of items returned.
title: Limit
type_:PageToken:
type: string
description: Page token for pagination.
title: PageToken
type_:Labels:
type: array
items:
type: string
description: Labels to filter by.
title: Labels
type_:Before:
type: string
format: date-time
description: Timestamp before which to filter by.
title: Before
type_:After:
type: string
format: date-time
description: Timestamp after which to filter by.
title: After
type_:Ascending:
type: boolean
description: Sort in ascending temporal order.
title: Ascending
type_:IncludeSpam:
type: boolean
description: Include spam in results.
title: IncludeSpam
type_:IncludeBlocked:
type: boolean
description: Include blocked in results.
title: IncludeBlocked
type_:IncludeUnauthenticated:
type: boolean
description: Include unauthenticated in results.
title: IncludeUnauthenticated
type_:IncludeTrash:
type: boolean
description: Include trash in results.
title: IncludeTrash
type_:Count:
type: integer
description: Number of items returned.
title: Count
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:MessageTimestamp:
type: string
format: date-time
description: Time at which message was sent or drafted.
title: MessageTimestamp
type_messages:MessageFrom:
type: string
description: >-
Address of sender. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: MessageFrom
type_messages:MessageTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageTo
type_messages:MessageCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageCc
type_messages:MessageBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageBcc
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:MessagePreview:
type: string
description: Text preview of message.
title: MessagePreview
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_messages:MessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in message.
title: MessageAttachments
type_messages:MessageInReplyTo:
type: string
description: ID of message being replied to.
title: MessageInReplyTo
type_messages:MessageReferences:
type: array
items:
type: string
description: IDs of previous messages in thread.
title: MessageReferences
type_messages:MessageHeaders:
type: object
additionalProperties:
type: string
description: Headers in message.
title: MessageHeaders
type_messages:MessageSize:
type: integer
description: Size of message in bytes.
title: MessageSize
type_messages:MessageUpdatedAt:
type: string
format: date-time
description: Time at which message was last updated.
title: MessageUpdatedAt
type_messages:MessageCreatedAt:
type: string
format: date-time
description: Time at which message was created.
title: MessageCreatedAt
type_messages:MessageItem:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
timestamp:
$ref: '#/components/schemas/type_messages:MessageTimestamp'
from:
$ref: '#/components/schemas/type_messages:MessageFrom'
to:
$ref: '#/components/schemas/type_messages:MessageTo'
cc:
$ref: '#/components/schemas/type_messages:MessageCc'
bcc:
$ref: '#/components/schemas/type_messages:MessageBcc'
subject:
$ref: '#/components/schemas/type_messages:MessageSubject'
preview:
$ref: '#/components/schemas/type_messages:MessagePreview'
attachments:
$ref: '#/components/schemas/type_messages:MessageAttachments'
in_reply_to:
$ref: '#/components/schemas/type_messages:MessageInReplyTo'
references:
$ref: '#/components/schemas/type_messages:MessageReferences'
headers:
$ref: '#/components/schemas/type_messages:MessageHeaders'
size:
$ref: '#/components/schemas/type_messages:MessageSize'
updated_at:
$ref: '#/components/schemas/type_messages:MessageUpdatedAt'
created_at:
$ref: '#/components/schemas/type_messages:MessageCreatedAt'
required:
- inbox_id
- thread_id
- message_id
- labels
- timestamp
- from
- to
- size
- updated_at
- created_at
title: MessageItem
type_messages:ListMessagesResponse:
type: object
properties:
count:
$ref: '#/components/schemas/type_:Count'
limit:
$ref: '#/components/schemas/type_:Limit'
next_page_token:
$ref: '#/components/schemas/type_:PageToken'
messages:
type: array
items:
$ref: '#/components/schemas/type_messages:MessageItem'
description: Ordered by `timestamp` descending.
required:
- count
- messages
title: ListMessagesResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"count": 1,
"messages": [
{
"inbox_id": "inbox_id",
"thread_id": "thread_id",
"message_id": "message_id",
"labels": [
"labels",
"labels"
],
"timestamp": "2024-01-15T09:30:00Z",
"from": "from",
"to": [
"to",
"to"
],
"size": 1,
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"headers": {
"headers": "headers"
}
},
{
"inbox_id": "inbox_id",
"thread_id": "thread_id",
"message_id": "message_id",
"labels": [
"labels",
"labels"
],
"timestamp": "2024-01-15T09:30:00Z",
"from": "from",
"to": [
"to",
"to"
],
"size": 1,
"updated_at": "2024-01-15T09:30:00Z",
"created_at": "2024-01-15T09:30:00Z",
"cc": [
"cc",
"cc"
],
"bcc": [
"bcc",
"bcc"
],
"subject": "subject",
"preview": "preview",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"in_reply_to": "in_reply_to",
"references": [
"references",
"references"
],
"headers": {
"headers": "headers"
}
}
],
"limit": 1,
"next_page_token": "next_page_token"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.list("inbox_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.list(
inbox_id="inbox_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/messages")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Search Messages
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/search
Full-text search across messages in the inbox, ranked by relevance. The query is matched against the sender, recipients, and subject (substring) and the message body (tokenized full text). Spam, trash, blocked, and unauthenticated messages are always excluded. limit cannot exceed 100.
OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/search:
get:
operationId: search
summary: Search Messages
description: |-
Full-text search across messages in the inbox, ranked by relevance. The
query is matched against the sender, recipients, and subject (substring)
and the message body (tokenized full text). Spam, trash, blocked, and
unauthenticated messages are always excluded. `limit` cannot exceed 100.
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: q
in: query
required: true
schema:
$ref: '#/components/schemas/type_:Query'
- name: limit
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Limit'
- name: page_token
in: query
required: false
schema:
$ref: '#/components/schemas/type_:PageToken'
- name: before
in: query
required: false
schema:
$ref: '#/components/schemas/type_:Before'
- name: after
in: query
required: false
schema:
$ref: '#/components/schemas/type_:After'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SearchMessagesResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_:Query:
type: string
description: |-
Full-text search query. Matched against the sender, recipients, and
subject (substring) and the message body (tokenized full text).
title: Query
type_:Limit:
type: integer
description: Limit of number of items returned.
title: Limit
type_:PageToken:
type: string
description: Page token for pagination.
title: PageToken
type_:Before:
type: string
format: date-time
description: Timestamp before which to filter by.
title: Before
type_:After:
type: string
format: date-time
description: Timestamp after which to filter by.
title: After
type_:Count:
type: integer
description: Number of items returned.
title: Count
type_threads:ThreadId:
type: string
description: ID of thread.
title: ThreadId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:MessageTimestamp:
type: string
format: date-time
description: Time at which message was sent or drafted.
title: MessageTimestamp
type_messages:MessageFrom:
type: string
description: >-
Address of sender. In format `username@domain.com` or `Display Name
<username@domain.com>`.
title: MessageFrom
type_messages:MessageTo:
type: array
items:
type: string
description: >-
Addresses of recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageTo
type_messages:MessageCc:
type: array
items:
type: string
description: >-
Addresses of CC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageCc
type_messages:MessageBcc:
type: array
items:
type: string
description: >-
Addresses of BCC recipients. In format `username@domain.com` or `Display
Name <username@domain.com>`.
title: MessageBcc
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:MessagePreview:
type: string
description: Text preview of message.
title: MessagePreview
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:Attachment:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
required:
- attachment_id
- size
title: Attachment
type_messages:MessageAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in message.
title: MessageAttachments
type_messages:MessageInReplyTo:
type: string
description: ID of message being replied to.
title: MessageInReplyTo
type_messages:MessageReferences:
type: array
items:
type: string
description: IDs of previous messages in thread.
title: MessageReferences
type_messages:MessageHeaders:
type: object
additionalProperties:
type: string
description: Headers in message.
title: MessageHeaders
type_messages:MessageSize:
type: integer
description: Size of message in bytes.
title: MessageSize
type_messages:MessageUpdatedAt:
type: string
format: date-time
description: Time at which message was last updated.
title: MessageUpdatedAt
type_messages:MessageCreatedAt:
type: string
format: date-time
description: Time at which message was created.
title: MessageCreatedAt
type_messages:SearchMessageHighlights:
type: object
properties:
from:
type: array
items:
type: string
description: Matched fragments from the sender address.
recipients:
type: array
items:
type: string
description: Matched fragments from the recipient addresses (to, cc, or bcc).
subject:
type: array
items:
type: string
description: Matched fragments from the subject.
text:
type: array
items:
type: string
description: Matched fragments from the message body.
description: >-
Matched fragments per field on a message search result, with matched
terms
wrapped in `**`. A field key is present only when the query matched that
field, so the present keys also tell you which fields produced the hit.
title: SearchMessageHighlights
type_messages:SearchMessageItem:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
timestamp:
$ref: '#/components/schemas/type_messages:MessageTimestamp'
from:
$ref: '#/components/schemas/type_messages:MessageFrom'
to:
$ref: '#/components/schemas/type_messages:MessageTo'
cc:
$ref: '#/components/schemas/type_messages:MessageCc'
bcc:
$ref: '#/components/schemas/type_messages:MessageBcc'
subject:
$ref: '#/components/schemas/type_messages:MessageSubject'
preview:
$ref: '#/components/schemas/type_messages:MessagePreview'
attachments:
$ref: '#/components/schemas/type_messages:MessageAttachments'
in_reply_to:
$ref: '#/components/schemas/type_messages:MessageInReplyTo'
references:
$ref: '#/components/schemas/type_messages:MessageReferences'
headers:
$ref: '#/components/schemas/type_messages:MessageHeaders'
size:
$ref: '#/components/schemas/type_messages:MessageSize'
updated_at:
$ref: '#/components/schemas/type_messages:MessageUpdatedAt'
created_at:
$ref: '#/components/schemas/type_messages:MessageCreatedAt'
highlights:
$ref: '#/components/schemas/type_messages:SearchMessageHighlights'
description: >-
Matched fragments per field. Present only when the query matched an
indexed field.
required:
- inbox_id
- thread_id
- message_id
- labels
- timestamp
- from
- to
- size
- updated_at
- created_at
title: SearchMessageItem
type_messages:SearchMessagesResponse:
type: object
properties:
count:
$ref: '#/components/schemas/type_:Count'
limit:
$ref: '#/components/schemas/type_:Limit'
next_page_token:
$ref: '#/components/schemas/type_:PageToken'
messages:
type: array
items:
$ref: '#/components/schemas/type_messages:SearchMessageItem'
description: Ordered by relevance, best match first.
required:
- count
- messages
title: SearchMessagesResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"count": 1,
"messages": [
{
"created_at": "2024-01-15T09:30:00Z",
"from": "from",
"inbox_id": "inbox_id",
"labels": [
"labels",
"labels"
],
"message_id": "message_id",
"size": 1,
"thread_id": "thread_id",
"timestamp": "2024-01-15T09:30:00Z",
"to": [
"to",
"to"
],
"updated_at": "2024-01-15T09:30:00Z",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"bcc": [
"bcc",
"bcc"
],
"cc": [
"cc",
"cc"
],
"headers": {
"headers": "headers"
},
"highlights": {
"from": [
"from",
"from"
],
"recipients": [
"recipients",
"recipients"
],
"subject": [
"subject",
"subject"
],
"text": [
"text",
"text"
]
},
"in_reply_to": "in_reply_to",
"preview": "preview",
"references": [
"references",
"references"
],
"subject": "subject"
},
{
"created_at": "2024-01-15T09:30:00Z",
"from": "from",
"inbox_id": "inbox_id",
"labels": [
"labels",
"labels"
],
"message_id": "message_id",
"size": 1,
"thread_id": "thread_id",
"timestamp": "2024-01-15T09:30:00Z",
"to": [
"to",
"to"
],
"updated_at": "2024-01-15T09:30:00Z",
"attachments": [
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
},
{
"attachment_id": "attachment_id",
"size": 1,
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}
],
"bcc": [
"bcc",
"bcc"
],
"cc": [
"cc",
"cc"
],
"headers": {
"headers": "headers"
},
"highlights": {
"from": [
"from",
"from"
],
"recipients": [
"recipients",
"recipients"
],
"subject": [
"subject",
"subject"
],
"text": [
"text",
"text"
]
},
"in_reply_to": "in_reply_to",
"preview": "preview",
"references": [
"references",
"references"
],
"subject": "subject"
}
],
"limit": 1,
"next_page_token": "next_page_token"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.search("inbox_id", {
q: "q",
});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.search(
inbox_id="inbox_id",
q="q",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/search?q=q"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/search?q=q")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/messages/search?q=q")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/search?q=q', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/search?q=q");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/search?q=q")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Update Message
PATCH https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id} Content-Type: application/json
CLI:
bash
agentmail inboxes:messages update --inbox-id <inbox_id> --message-id <message_id> --add-label read --remove-label unreadOpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}:
patch:
operationId: update
summary: Update Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages update --inbox-id <inbox_id> --message-id
<message_id> --add-label read --remove-label unread
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:UpdateMessageResponse'
'400':
description: Error response with status 400
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ValidationErrorResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:UpdateMessageRequest'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:UpdateMessageLabels:
oneOf:
- type: string
- type: array
items:
type: string
description: Label or list of labels.
title: UpdateMessageLabels
type_messages:UpdateMessageRequest:
type: object
properties:
add_labels:
$ref: '#/components/schemas/type_messages:UpdateMessageLabels'
description: Label or labels to add to message.
remove_labels:
$ref: '#/components/schemas/type_messages:UpdateMessageLabels'
description: Label or labels to remove from message.
title: UpdateMessageRequest
type_messages:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_messages:UpdateMessageResponse:
type: object
properties:
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
labels:
$ref: '#/components/schemas/type_messages:MessageLabels'
required:
- message_id
- labels
title: UpdateMessageResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ValidationErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
errors:
description: Validation errors.
required:
- name
- errors
title: ValidationErrorResponse
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Request
json
{}Response
json
{
"message_id": "message_id",
"labels": [
"labels",
"labels"
]
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.update("inbox_id", "message_id", {});
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.update(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id"
payload := strings.NewReader("{}")
req, _ := http.NewRequest("PATCH", url, payload)
req.Header.Add("Authorization", "Bearer <api_key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Patch.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{}"
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.patch("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")
.header("Authorization", "Bearer <api_key>")
.header("Content-Type", "application/json")
.body("{}")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('PATCH', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id', [
'body' => '{}',
'headers' => [
'Authorization' => 'Bearer <api_key>',
'Content-Type' => 'application/json',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id");
var request = new RestRequest(Method.PATCH);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = [
"Authorization": "Bearer <api_key>",
"Content-Type": "application/json"
]
let parameters = [] as [String : Any]
let postData = JSONSerialization.data(withJSONObject: parameters, options: [])
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "PATCH"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Delete Message
DELETE https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}
Permanently deletes a message.
CLI:
bash
agentmail inboxes:messages delete --inbox-id <inbox_id> --message-id <message_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}:
delete:
operationId: delete
summary: Delete Message
description: >-
Permanently deletes a message.
**CLI:**
```bash
agentmail inboxes:messages delete --inbox-id <inbox_id> --message-id
<message_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Successful response
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.delete("inbox_id", "message_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.delete(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id"
req, _ := http.NewRequest("DELETE", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.delete("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('DELETE', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id");
var request = new RestRequest(Method.DELETE);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "DELETE"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Get Raw Message
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}/raw
CLI:
bash
agentmail inboxes:messages get-raw --inbox-id <inbox_id> --message-id <message_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}/raw:
get:
operationId: get-raw
summary: Get Raw Message
description: >-
**CLI:**
```bash
agentmail inboxes:messages get-raw --inbox-id <inbox_id> --message-id
<message_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:RawMessageResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_messages:MessageSize:
type: integer
description: Size of message in bytes.
title: MessageSize
type_messages:RawMessageResponse:
type: object
properties:
message_id:
$ref: '#/components/schemas/type_messages:MessageId'
description: ID of the message.
size:
$ref: '#/components/schemas/type_messages:MessageSize'
description: Size of the raw message in bytes.
download_url:
type: string
description: S3 presigned URL to download the raw message. Expires at expires_at.
expires_at:
type: string
format: date-time
description: Time at which the download URL expires.
required:
- message_id
- size
- download_url
- expires_at
description: S3 presigned URL to download the raw .eml file.
title: RawMessageResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"message_id": "message_id",
"size": 1,
"download_url": "download_url",
"expires_at": "2024-01-15T09:30:00Z"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.getRaw("inbox_id", "message_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.get_raw(
inbox_id="inbox_id",
message_id="message_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/raw"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/raw")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/raw")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/raw', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/raw");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/raw")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()Get Message Attachment
GET https://api.agentmail.to/v0/inboxes/{inbox_id}/messages/{message_id}/attachments/{attachment_id}
CLI:
bash
agentmail inboxes:messages get-attachment --inbox-id <inbox_id> --message-id <message_id> --attachment-id <attachment_id>OpenAPI Specification
yaml
openapi: 3.1.0
info:
title: api
version: 1.0.0
paths:
/v0/inboxes/{inbox_id}/messages/{message_id}/attachments/{attachment_id}:
get:
operationId: get-attachment
summary: Get Attachment
description: >-
**CLI:**
```bash
agentmail inboxes:messages get-attachment --inbox-id <inbox_id>
--message-id <message_id> --attachment-id <attachment_id>
```
tags:
- subpackage_inboxes.subpackage_inboxes/messages
parameters:
- name: inbox_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_inboxes:InboxId'
- name: message_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_messages:MessageId'
- name: attachment_id
in: path
required: true
schema:
$ref: '#/components/schemas/type_attachments:AttachmentId'
- name: Authorization
in: header
description: Bearer authentication
required: true
schema:
type: string
responses:
'200':
description: Response with status 200
content:
application/json:
schema:
$ref: '#/components/schemas/type_attachments:AttachmentResponse'
'404':
description: Error response with status 404
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
servers:
- url: https://api.agentmail.to
description: prod
- url: https://x402.api.agentmail.to
description: prod-x402
- url: https://mpp.api.agentmail.to
description: prod-mpp
- url: https://api.agentmail.eu
description: eu-prod
components:
schemas:
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
type_messages:MessageId:
type: string
description: ID of message.
title: MessageId
type_attachments:AttachmentId:
type: string
description: ID of attachment.
title: AttachmentId
type_attachments:AttachmentFilename:
type: string
description: Filename of attachment.
title: AttachmentFilename
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_attachments:AttachmentContentType:
type: string
description: Content type of attachment.
title: AttachmentContentType
type_attachments:AttachmentContentDisposition:
type: string
enum:
- inline
- attachment
description: Content disposition of attachment.
title: AttachmentContentDisposition
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_attachments:AttachmentResponse:
type: object
properties:
attachment_id:
$ref: '#/components/schemas/type_attachments:AttachmentId'
filename:
$ref: '#/components/schemas/type_attachments:AttachmentFilename'
size:
$ref: '#/components/schemas/type_attachments:AttachmentSize'
content_type:
$ref: '#/components/schemas/type_attachments:AttachmentContentType'
content_disposition:
$ref: '#/components/schemas/type_attachments:AttachmentContentDisposition'
content_id:
$ref: '#/components/schemas/type_attachments:AttachmentContentId'
download_url:
type: string
description: URL to download the attachment.
expires_at:
type: string
format: date-time
description: Time at which the download URL expires.
required:
- attachment_id
- size
- download_url
- expires_at
title: AttachmentResponse
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_:ErrorResponse:
type: object
properties:
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- name
- message
title: ErrorResponse
securitySchemes:
Bearer:
type: http
scheme: bearerExamples
Response
json
{
"attachment_id": "attachment_id",
"size": 1,
"download_url": "download_url",
"expires_at": "2024-01-15T09:30:00Z",
"filename": "filename",
"content_type": "content_type",
"content_disposition": "inline",
"content_id": "content_id"
}SDK Code
typescript
import { AgentMailClient } from "agentmail";
async function main() {
const client = new AgentMailClient({
apiKey: "YOUR_TOKEN_HERE",
});
await client.inboxes.messages.getAttachment("inbox_id", "message_id", "attachment_id");
}
main();python
from agentmail import AgentMail
client = AgentMail(
api_key="YOUR_TOKEN_HERE",
)
client.inboxes.messages.get_attachment(
inbox_id="inbox_id",
message_id="message_id",
attachment_id="attachment_id",
)go
package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <api_key>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}ruby
require 'uri'
require 'net/http'
url = URI("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <api_key>'
response = http.request(request)
puts response.read_bodyjava
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
HttpResponse<String> response = Unirest.get("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id")
.header("Authorization", "Bearer <api_key>")
.asString();php
<?php
require_once('vendor/autoload.php');
$client = new \GuzzleHttp\Client();
$response = $client->request('GET', 'https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id', [
'headers' => [
'Authorization' => 'Bearer <api_key>',
],
]);
echo $response->getBody();csharp
using RestSharp;
var client = new RestClient("https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Bearer <api_key>");
IRestResponse response = client.Execute(request);swift
import Foundation
let headers = ["Authorization": "Bearer <api_key>"]
let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/inboxes/inbox_id/messages/message_id/attachments/attachment_id")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error as Any)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()