On Receive (Streaming)
TheonReceive method provides a persistent connection to our event stream with typed callbacks for each event type. Unlike webhooks, you don’t need to expose a public URL or handle signature verification.
This is the recommended way to handle reply-to-bot flows, chat interfaces, or real-time dashboards.
Zero-Config Usage
Just pass the callbacks you need. No cursor tracking, no deduplication logic — we handle it all server-side.How It Works
Behind the scenes,onReceive:
- Server-side tracking: Uses your API key to track which events you’ve processed
- Automatic acknowledgment: Events are acknowledged after your handler completes
- Replay on reconnect: Unacknowledged events are replayed if your app disconnects
- No duplicates: You never see the same event twice
All Event Handlers
Event Types
Called when an email is successfully queued for sending.
Called when the receiving mail server confirms delivery.
Called when a recipient replies to your email.
Called when an email bounces (hard or soft bounce).
Called when sending fails permanently.
Called when a recipient marks your email as spam.
Manual Acknowledgment
For critical workflows where you need to ensure database writes complete before acknowledging:Resiliency
The stream automatically handles keep-alives (heartbeats). If the connection drops:- Your
onErrorcallback fires - SDK auto-reconnects with exponential backoff
- Server replays any unacknowledged events
- Your handlers process them normally