AgentMail inboxes > messages API
The inboxes > messages API from AgentMail — 11 operation(s) for inboxes > messages.
The inboxes > messages API from AgentMail — 11 operation(s) for inboxes > messages.
openapi: 3.1.0
info:
title: API Reference agent inboxes > messages API
version: 1.0.0
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
tags:
- name: inboxes > messages
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:
- 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'
/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:
- 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'
/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:
- 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'
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:
- 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'
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:
- 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'
/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:
- 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'
/v0/inboxes/{inbox_id}/messages/batch-update:
post:
operationId: batch-update
summary: Batch Update Messages
description: 'Apply one label change to up to 50 messages in a single request. The
same add_labels and remove_labels apply to every message id, and at
least one of them must be provided. The update is atomic: either all
resolved messages are updated or none are. Missing or restricted ids
are silently excluded; compare `count` against `limit` to detect
exclusions.
**CLI:**
```bash
agentmail inboxes:messages batch-update --inbox-id <inbox_id> --message-id <id1> --message-id <id2> --add-label read --remove-label unread
```'
tags:
- 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:BatchUpdateMessagesResponse'
'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:BatchUpdateMessagesRequest'
/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:
- 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'
/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:
- 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'
/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:
- 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'
'409':
description: Error response with status 409
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageRequest'
/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:
- 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'
'409':
description: Error response with status 409
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:ReplyToMessageRequest'
/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:
- 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'
'409':
description: Error response with status 409
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:ReplyAllMessageRequest'
/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:
- 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'
'409':
description: Error response with status 409
content:
application/json:
schema:
$ref: '#/components/schemas/type_:ErrorResponse'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/type_messages:SendMessageRequest'
components:
schemas:
type_:IncludeUnauthenticated:
type: boolean
description: Include unauthenticated in results.
title: IncludeUnauthenticated
type_messages:Addresses:
oneOf:
- type: string
- type: array
items:
type: string
title: Addresses
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:MessageLabels:
type: array
items:
type: string
description: Labels of message.
title: MessageLabels
type_:After:
type: string
format: date-time
description: Timestamp after which to filter by.
title: After
type_messages:MessageCreatedAt:
type: string
format: date-time
description: Time at which message was created.
title: MessageCreatedAt
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:BatchGetMessagesRequest:
type: object
properties:
message_ids:
$ref: '#/components/schemas/type_messages:BatchGetMessagesMessageIds'
required:
- message_ids
title: BatchGetMessagesRequest
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_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_:Before:
type: string
format: date-time
description: Timestamp before which to filter by.
title: Before
type_messages:BatchUpdateMessagesResponse:
type: object
properties:
limit:
$ref: '#/components/schemas/type_:Limit'
count:
$ref: '#/components/schemas/type_:Count'
updates:
type: array
items:
$ref: '#/components/schemas/type_messages:UpdateMessageResponse'
description: 'Updated messages with their new labels. Order matches `message_ids`
in the request. Excluded ids are omitted, so `count` may be less than
`limit`.'
required:
- limit
- count
- updates
title: BatchUpdateMessagesResponse
type_messages:MessageReferences:
type: array
items:
type: string
description: IDs of previous messages in thread.
title: MessageReferences
type_:IncludeSpam:
type: boolean
description: Include spam in results.
title: IncludeSpam
type_attachments:AttachmentSize:
type: integer
description: Size of attachment in bytes.
title: AttachmentSize
type_:Count:
type: integer
description: Number of items returned.
title: Count
type_messages:MessageSubject:
type: string
description: Subject of message.
title: MessageSubject
type_messages:BatchUpdateMessagesRequest:
type: object
properties:
message_ids:
$ref: '#/components/schemas/type_messages:BatchUpdateMessagesMessageIds'
add_labels:
$ref: '#/components/schemas/type_messages:UpdateMessageLabels'
description: Label or labels to add to every message.
remove_labels:
$ref: '#/components/schemas/type_messages:UpdateMessageLabels'
description: Label or labels to remove from every message.
required:
- message_ids
title: BatchUpdateMessagesRequest
type_messages:SendMessageBcc:
$ref: '#/components/schemas/type_messages:Addresses'
description: BCC recipient address or addresses.
title: SendMessageBcc
type_attachments:AttachmentContentId:
type: string
description: Content ID of attachment.
title: AttachmentContentId
type_messages:MessageHeaders:
type: object
additionalProperties:
type: string
description: Headers in message.
title: MessageHeaders
type_messages:MessagePreview:
type: string
description: Text preview of message.
title: MessagePreview
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:SendMessageTo:
$ref: '#/components/schemas/type_messages:Addresses'
description: Recipient address or addresses.
title: SendMessageTo
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
# --- truncated at 32 KB (49 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/agentmail/refs/heads/main/openapi/agentmail-inboxes-messages-api-openapi.yml