Skip to content

Workflow: Real-Time Events

Fresh 🌱

Two ways to get events the instant they happen: webhooks (HTTP push to your URL) or WebSockets (persistent connection). Pick by your infrastructure.

flowchart LR
    E[AgentMail event] --> Q{Have a public HTTPS URL?}
    Q -->|Yes, server with public endpoint| W[Webhooks]
    Q -->|No, or behind NAT / serverless| S[WebSockets]
    W --> V[Verify signature -> handle]
    S --> H[Read events off the connection -> handle]

Choose

WebhooksWebSockets
TransportHTTP POST to your URLPersistent connection
Needs public URLYes (ngrok for local)No
Best forServers, cloud functions with public routesLocal dev, behind NAT, quick prototypes
SetupSOP: Webhook setupWebSockets quickstart

Events you can subscribe to

message.received, message.sent, message.delivered, message.bounced, message.rejected, message.complained, domain.verified.

Wire-up