AgentMail · AsyncAPI Specification
API Reference
Version 1.0.0
View Spec
View on GitHub
CompanyAiEmailAPIAI AgentsInboxMessagingWebhooksWebSocketsSMTPIMAPMCPAgenticDeveloper ToolsAsyncAPIWebhooksEvents
Channels
/v0
publish
websockets-publishServer messages
Messages
✉
subpackage_websockets.websockets-server-0-subscribed
subpackage_websockets.websockets-server-0-subscribed
✉
subpackage_websockets.websockets-server-1-message_received
subpackage_websockets.websockets-server-1-message_received
✉
subpackage_websockets.websockets-server-2-message_sent
subpackage_websockets.websockets-server-2-message_sent
✉
subpackage_websockets.websockets-server-3-message_delivered
subpackage_websockets.websockets-server-3-message_delivered
✉
subpackage_websockets.websockets-server-4-message_bounced
subpackage_websockets.websockets-server-4-message_bounced
✉
subpackage_websockets.websockets-server-5-message_complained
subpackage_websockets.websockets-server-5-message_complained
✉
subpackage_websockets.websockets-server-6-message_rejected
subpackage_websockets.websockets-server-6-message_rejected
✉
subpackage_websockets.websockets-server-7-domain_verified
subpackage_websockets.websockets-server-7-domain_verified
✉
subpackage_websockets.websockets-server-8-error
subpackage_websockets.websockets-server-8-error
Servers
wss
prod
wss://ws.agentmail.to/
wss
prod-x402
wss://x402.ws.agentmail.to/
wss
prod-mpp
wss://mpp.ws.agentmail.to/
wss
eu-prod
wss://ws.agentmail.eu/
AsyncAPI Specification
asyncapi: 2.6.0
info:
title: API Reference
version: 1.0.0
channels:
/v0:
bindings:
ws:
query:
type: object
properties:
api_key:
type: string
publish:
operationId: websockets-publish
summary: Server messages
message:
oneOf:
- $ref: '#/components/messages/subpackage_websockets.websockets-server-0-subscribed'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-1-message_received'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-2-message_sent'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-3-message_delivered'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-4-message_bounced'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-5-message_complained'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-6-message_rejected'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-7-domain_verified'
- $ref: '#/components/messages/subpackage_websockets.websockets-server-8-error'
subscribe:
operationId: websockets-subscribe
summary: Client message
message:
name: subscribe
payload:
$ref: '#/components/schemas/type_websockets:Subscribe'
servers:
prod:
url: wss://ws.agentmail.to/
protocol: wss
x-default: true
prod-x402:
url: wss://x402.ws.agentmail.to/
protocol: wss
prod-mpp:
url: wss://mpp.ws.agentmail.to/
protocol: wss
eu-prod:
url: wss://ws.agentmail.eu/
protocol: wss
components:
messages:
subpackage_websockets.websockets-server-0-subscribed:
name: subscribed
payload:
$ref: '#/components/schemas/type_websockets:Subscribed'
subpackage_websockets.websockets-server-1-message_received:
name: message_received
payload:
$ref: '#/components/schemas/type_events:MessageReceivedEvent'
subpackage_websockets.websockets-server-2-message_sent:
name: message_sent
payload:
$ref: '#/components/schemas/type_events:MessageSentEvent'
subpackage_websockets.websockets-server-3-message_delivered:
name: message_delivered
payload:
$ref: '#/components/schemas/type_events:MessageDeliveredEvent'
subpackage_websockets.websockets-server-4-message_bounced:
name: message_bounced
payload:
$ref: '#/components/schemas/type_events:MessageBouncedEvent'
subpackage_websockets.websockets-server-5-message_complained:
name: message_complained
payload:
$ref: '#/components/schemas/type_events:MessageComplainedEvent'
subpackage_websockets.websockets-server-6-message_rejected:
name: message_rejected
payload:
$ref: '#/components/schemas/type_events:MessageRejectedEvent'
subpackage_websockets.websockets-server-7-domain_verified:
name: domain_verified
payload:
$ref: '#/components/schemas/type_events:DomainVerifiedEvent'
subpackage_websockets.websockets-server-8-error:
name: error
payload:
$ref: '#/components/schemas/type_websockets:Error'
schemas:
type_events:EventType:
type: string
enum:
- message.received
- message.received.spam
- message.received.blocked
- message.received.unauthenticated
- message.sent
- message.delivered
- message.bounced
- message.complained
- message.rejected
- domain.verified
title: EventType
type_events:EventTypes:
type: array
items:
$ref: '#/components/schemas/type_events:EventType'
description: Event types for which to send events.
title: EventTypes
type_events:InboxIds:
type: array
items:
type: string
description: Inboxes for which to send events. Maximum 10 per webhook.
title: InboxIds
type_events:PodIds:
type: array
items:
type: string
description: Pods for which to send events. Maximum 10 per webhook.
title: PodIds
type_websockets:Subscribed:
type: object
properties:
type:
type: string
enum:
- subscribed
event_types:
$ref: '#/components/schemas/type_events:EventTypes'
inbox_ids:
$ref: '#/components/schemas/type_events:InboxIds'
pod_ids:
$ref: '#/components/schemas/type_events:PodIds'
required:
- type
title: Subscribed
type_events:MessageReceivedEventType:
type: string
enum:
- message.received
- message.received.spam
- message.received.blocked
- message.received.unauthenticated
title: MessageReceivedEventType
type_events:EventId:
type: string
description: ID of event.
title: EventId
type_inboxes:InboxId:
type: string
description: The ID of the inbox.
title: InboxId
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_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_threads:ThreadLabels:
type: array
items:
type: string
description: Labels of thread.
title: ThreadLabels
type_threads:ThreadTimestamp:
type: string
format: date-time
description: Timestamp of last sent or received message.
title: ThreadTimestamp
type_threads:ThreadReceivedTimestamp:
type: string
format: date-time
description: Timestamp of last received message.
title: ThreadReceivedTimestamp
type_threads:ThreadSentTimestamp:
type: string
format: date-time
description: Timestamp of last sent message.
title: ThreadSentTimestamp
type_threads:ThreadSenders:
type: array
items:
type: string
description: Senders in thread. In format `username@domain.com` or `Display Name <username@domain.com>`.
title: ThreadSenders
type_threads:ThreadRecipients:
type: array
items:
type: string
description: Recipients in thread. In format `username@domain.com` or `Display Name <username@domain.com>`.
title: ThreadRecipients
type_threads:ThreadSubject:
type: string
description: Subject of thread.
title: ThreadSubject
type_threads:ThreadPreview:
type: string
description: Text preview of last message in thread.
title: ThreadPreview
type_threads:ThreadAttachments:
type: array
items:
$ref: '#/components/schemas/type_attachments:Attachment'
description: Attachments in thread.
title: ThreadAttachments
type_threads:ThreadLastMessageId:
type: string
description: ID of last message in thread.
title: ThreadLastMessageId
type_threads:ThreadMessageCount:
type: integer
description: Number of messages in thread.
title: ThreadMessageCount
type_threads:ThreadSize:
type: integer
description: Size of thread in bytes.
title: ThreadSize
type_threads:ThreadUpdatedAt:
type: string
format: date-time
description: Time at which thread was last updated.
title: ThreadUpdatedAt
type_threads:ThreadCreatedAt:
type: string
format: date-time
description: Time at which thread was created.
title: ThreadCreatedAt
type_threads:ThreadItem:
type: object
properties:
inbox_id:
$ref: '#/components/schemas/type_inboxes:InboxId'
thread_id:
$ref: '#/components/schemas/type_threads:ThreadId'
labels:
$ref: '#/components/schemas/type_threads:ThreadLabels'
timestamp:
$ref: '#/components/schemas/type_threads:ThreadTimestamp'
received_timestamp:
$ref: '#/components/schemas/type_threads:ThreadReceivedTimestamp'
sent_timestamp:
$ref: '#/components/schemas/type_threads:ThreadSentTimestamp'
senders:
$ref: '#/components/schemas/type_threads:ThreadSenders'
recipients:
$ref: '#/components/schemas/type_threads:ThreadRecipients'
subject:
$ref: '#/components/schemas/type_threads:ThreadSubject'
preview:
$ref: '#/components/schemas/type_threads:ThreadPreview'
attachments:
$ref: '#/components/schemas/type_threads:ThreadAttachments'
last_message_id:
$ref: '#/components/schemas/type_threads:ThreadLastMessageId'
message_count:
$ref: '#/components/schemas/type_threads:ThreadMessageCount'
size:
$ref: '#/components/schemas/type_threads:ThreadSize'
updated_at:
$ref: '#/components/schemas/type_threads:ThreadUpdatedAt'
created_at:
$ref: '#/components/schemas/type_threads:ThreadCreatedAt'
required:
- inbox_id
- thread_id
- labels
- timestamp
- senders
- recipients
- last_message_id
- message_count
- size
- updated_at
- created_at
title: ThreadItem
type_events:MessageReceivedEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
$ref: '#/components/schemas/type_events:MessageReceivedEventType'
event_id:
$ref: '#/components/schemas/type_events:EventId'
message:
$ref: '#/components/schemas/type_messages:Message'
thread:
$ref: '#/components/schemas/type_threads:ThreadItem'
required:
- type
- event_type
- event_id
- message
- thread
description: >-
A message was received. Spam, blocked, and unauthenticated received-message events use the same payload shape
with different `event_type` values.
title: MessageReceivedEvent
type_events:Timestamp:
type: string
format: date-time
description: Timestamp of event.
title: Timestamp
type_events:Send:
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'
timestamp:
$ref: '#/components/schemas/type_events:Timestamp'
recipients:
type: array
items:
type: string
description: Sent recipients.
required:
- inbox_id
- thread_id
- message_id
- timestamp
- recipients
title: Send
type_events:MessageSentEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
type: string
enum:
- message.sent
event_id:
$ref: '#/components/schemas/type_events:EventId'
send:
$ref: '#/components/schemas/type_events:Send'
required:
- type
- event_type
- event_id
- send
title: MessageSentEvent
type_events:Delivery:
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'
timestamp:
$ref: '#/components/schemas/type_events:Timestamp'
recipients:
type: array
items:
type: string
description: Delivered recipients.
required:
- inbox_id
- thread_id
- message_id
- timestamp
- recipients
title: Delivery
type_events:MessageDeliveredEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
type: string
enum:
- message.delivered
event_id:
$ref: '#/components/schemas/type_events:EventId'
delivery:
$ref: '#/components/schemas/type_events:Delivery'
required:
- type
- event_type
- event_id
- delivery
title: MessageDeliveredEvent
type_events:Recipient:
type: object
properties:
address:
type: string
description: Recipient address.
status:
type: string
description: Recipient status.
required:
- address
- status
title: Recipient
type_events:Bounce:
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'
timestamp:
$ref: '#/components/schemas/type_events:Timestamp'
type:
type: string
description: Bounce type.
sub_type:
type: string
description: Bounce sub-type.
recipients:
type: array
items:
$ref: '#/components/schemas/type_events:Recipient'
description: Bounced recipients.
required:
- inbox_id
- thread_id
- message_id
- timestamp
- type
- sub_type
- recipients
title: Bounce
type_events:MessageBouncedEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
type: string
enum:
- message.bounced
event_id:
$ref: '#/components/schemas/type_events:EventId'
bounce:
$ref: '#/components/schemas/type_events:Bounce'
required:
- type
- event_type
- event_id
- bounce
title: MessageBouncedEvent
type_events:Complaint:
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'
timestamp:
$ref: '#/components/schemas/type_events:Timestamp'
type:
type: string
description: Complaint type.
sub_type:
type: string
description: Complaint sub-type.
recipients:
type: array
items:
type: string
description: Complained recipients.
required:
- inbox_id
- thread_id
- message_id
- timestamp
- type
- sub_type
- recipients
title: Complaint
type_events:MessageComplainedEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
type: string
enum:
- message.complained
event_id:
$ref: '#/components/schemas/type_events:EventId'
complaint:
$ref: '#/components/schemas/type_events:Complaint'
required:
- type
- event_type
- event_id
- complaint
title: MessageComplainedEvent
type_events:Reject:
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'
timestamp:
$ref: '#/components/schemas/type_events:Timestamp'
reason:
type: string
description: Reject reason.
required:
- inbox_id
- thread_id
- message_id
- timestamp
- reason
title: Reject
type_events:MessageRejectedEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
type: string
enum:
- message.rejected
event_id:
$ref: '#/components/schemas/type_events:EventId'
reject:
$ref: '#/components/schemas/type_events:Reject'
required:
- type
- event_type
- event_id
- reject
title: MessageRejectedEvent
type_pods:PodId:
type: string
description: ID of pod.
title: PodId
type_domains:DomainId:
type: string
description: The ID of the domain.
title: DomainId
type_domains:DomainName:
type: string
description: The name of the domain (e.g., `example.com`).
title: DomainName
type_domains:VerificationStatus:
type: string
enum:
- NOT_STARTED
- PENDING
- INVALID
- FAILED
- VERIFYING
- VERIFIED
title: VerificationStatus
type_domains:Status:
$ref: '#/components/schemas/type_domains:VerificationStatus'
description: The verification status of the domain.
title: Status
type_domains:FeedbackEnabled:
type: boolean
description: Bounce and complaint notifications are sent to your inboxes.
title: FeedbackEnabled
type_domains:SubdomainsEnabled:
type: boolean
description: |-
Allow inboxes on any subdomain of this domain. Adds a required wildcard MX
record (`*.<domain>`) to `records`.
title: SubdomainsEnabled
type_domains:RecordType:
type: string
enum:
- TXT
- CNAME
- MX
title: RecordType
type_domains:RecordStatus:
type: string
enum:
- MISSING
- INVALID
- VALID
title: RecordStatus
type_domains:VerificationRecord:
type: object
properties:
type:
$ref: '#/components/schemas/type_domains:RecordType'
description: The type of the DNS record.
name:
type: string
description: The name or host of the record.
value:
type: string
description: The value of the record.
status:
$ref: '#/components/schemas/type_domains:RecordStatus'
description: The verification status of this specific record.
priority:
type: integer
description: The priority of the MX record.
required:
- type
- name
- value
- status
title: VerificationRecord
type_domains:ClientId:
type: string
description: Client ID of domain.
title: ClientId
type_domains:Domain:
type: object
properties:
pod_id:
$ref: '#/components/schemas/type_pods:PodId'
domain_id:
$ref: '#/components/schemas/type_domains:DomainId'
domain:
$ref: '#/components/schemas/type_domains:DomainName'
status:
$ref: '#/components/schemas/type_domains:Status'
feedback_enabled:
$ref: '#/components/schemas/type_domains:FeedbackEnabled'
subdomains_enabled:
$ref: '#/components/schemas/type_domains:SubdomainsEnabled'
records:
type: array
items:
$ref: '#/components/schemas/type_domains:VerificationRecord'
description: |-
A list of DNS records required to verify the domain. Includes a
wildcard MX record (`*.<domain>`) when `subdomains_enabled` is true.
client_id:
$ref: '#/components/schemas/type_domains:ClientId'
updated_at:
type: string
format: date-time
description: Time at which the domain was last updated.
created_at:
type: string
format: date-time
description: Time at which the domain was created.
required:
- domain_id
- domain
- status
- feedback_enabled
- subdomains_enabled
- records
- updated_at
- created_at
title: Domain
type_events:DomainVerifiedEvent:
type: object
properties:
type:
type: string
enum:
- event
event_type:
type: string
enum:
- domain.verified
event_id:
$ref: '#/components/schemas/type_events:EventId'
domain:
$ref: '#/components/schemas/type_domains:Domain'
required:
- type
- event_type
- event_id
- domain
title: DomainVerifiedEvent
type_:ErrorName:
type: string
description: Name of error.
title: ErrorName
type_:ErrorMessage:
type: string
description: Error message.
title: ErrorMessage
type_websockets:Error:
type: object
properties:
type:
type: string
enum:
- error
name:
$ref: '#/components/schemas/type_:ErrorName'
message:
$ref: '#/components/schemas/type_:ErrorMessage'
required:
- type
- name
- message
title: Error
type_websockets:Subscribe:
type: object
properties:
type:
type: string
enum:
- subscribe
event_types:
$ref: '#/components/schemas/type_events:EventTypes'
inbox_ids:
$ref: '#/components/schemas/type_events:InboxIds'
pod_ids:
$ref: '#/components/schemas/type_events:PodIds'
required:
- type
title: Subscribe