Webhook Events
As mentioned in the overview, webhooks allow us to create event-driven applications.
AgentMail supports multiple event types that allow you to build comprehensive, event-driven workflows for your email agents.
All webhook payloads follow the same basic structure:
Message Events
message.received
- Description: Triggered whenever a new email is successfully received and processed in one of your
Inboxes. This is the most common trigger to kick off agent workflows. - Example use-case: Kick off a internal workflow when a customer complaint email hits the support inbox
Something here to notice is message.received is the only webhook event that
includes both the metadata on the Thread and the Message in the payload.
Other event types send only metadata on the event. Let us know if you need
metadata on other event types by emailing support@agentmail.cc
message.sent
- Description: Triggered when a message is successfully sent from one of your
Inboxes. - Use Case: Track outgoing messages, update your database, or trigger follow-up workflows after sending.
message.delivered
- Description: Triggered when a sent message is successfully delivered to the recipient’s mail server.
- Use Case: Confirm successful delivery, update message status, or trigger delivery confirmation workflows.
What is the difference between message.sent and message.delivered?
What is the difference between message.sent and message.delivered?
message.sent means the message has succesfully left our servers and is out
to travel the network. This is typically happens before message.delivered
where message.delivered means the recieving email server(whether its Gmail
or Outlook) gives us the 200 OK saying the email has been received. What
they do with the email after is unknown.
Does message.delivered mean I landed in their inbox?
Does message.delivered mean I landed in their inbox?
Nope. As mentioned message.delivered means the receiving email server,
whether it’s Gmail or Outlook tells us “Hey AgentMail, we got your email,
we’ll take it from here!”. They typically have their own properitary
algorithms to determine whether the email is going to end up in the inbox or
spam, but rest assured we handle everything needed for providers like Gmail
to deem the emails primary inbox worthy
message.bounced
- Description: Triggered when a sent message fails to deliver and bounces back. Includes bounce type and sub-type information.
- Use Case: Handle bounced emails, update recipient status, or trigger bounce handling workflows.
message.complained
- Description: Triggered when a recipient marks your message as spam or files a complaint.
- Use Case: Handle spam complaints, update sender reputation, or trigger complaint handling workflows.
message.rejected
- Description: Triggered when a message is rejected before being sent, typically due to validation errors or policy violations.
- Use Case: Handle rejected messages, log rejection reasons, or trigger validation workflows.
If you send an email to a bounced address, rejected address, or
complained address we prevent you from sending to this email address ever
again to keep bounce rates low. Make sure to keep your account bounce rate
under 4%, otherwise we will put your account under review.
Domain Events
domain.verified
- Description: Triggered when a domain is successfully verified and ready to use for sending emails.
- Use Case: Automatically enable domain-specific features, update domain status, or trigger post-verification workflows.
Event Filtering
When creating a webhook, you can specify which events to subscribe to. This allows you to:
- Reduce webhook traffic by only subscribing to events you need
- Create specialized webhooks for specific workflows
For example, if you only need to trigger workflows on incoming messages, you can subscribe to just message.received. If you’re building a delivery tracking system, you might subscribe to message.sent, message.delivered, and message.bounced.
If you have any specific webhook notifications you would like, please ping us in the #feature-requests channel in the Discord
