One of the reasons you send emails through Postmark is to handle all of the possible bounces that email servers can return. However, your application still needs the information about those bounces in an easy to use format. You could use the Bounce API to pull data about your bounces. For some applications, it’s easier to use a webhook for Postmark to push your bounce data as bounces occur. A bounce webhook will push data to your application in an easily parsable, JSON format, as soon as Postmark processes the bounce report.
Bounce webhooks are triggered for bounces that resulted from outgoing email. So, your webhook would receive data for Hard Bounces, Soft Bounces, Undeliverable bounces, etc.
It is also possible to generate fake bounces by using our black hole domain. This allows you to test your bounce webhook in a safe way, as the bounces won't affect your sending domain or reputation. Check out our help article on how to test bounces.
Note: The datetime for the BouncedAt
field will be in ISO 8601 format.
Side note: an easy way to get bounce notifications is through our official Slack App. Search for "Postmark Bot" in the Slack App Directory, or install directly from the Slack app page.
If you use Postmark and you're not at a point where you can custom build full bounce handling functionality into your application, you can use Rebound to quickly add in basic bounce handling functionality using JavaScript. Rebound prompts your customers to update their email address if an email you sent them hard bounced.
For a low effort method of using bounce webhooks to alert your senders of bounces, check out our help article on using Zapier to automatically alert your senders of bounces.
When logged into Postmark, select the Server, the Message Stream, and then go to the Webhooks tab. Choose Add webhook and input your webhook URL in Webhook URL and then select the Bounce checkbox.
You can modify the Bounce
field using the Webhooks API to edit an existing Webhook. You can also use the Webhooks API to create webhooks and set the Bounce
field at the same time.
An example of the full JSON document that would be POSTed to your webhook URL is to the right. A brief description of some of the more interesting fields is below:
{
"RecordType": "Bounce",
"MessageStream": "outbound",
"ID": 4323372036854775807,
"Type": "HardBounce",
"TypeCode": 1,
"Name": "Hard bounce",
"Tag": "Test",
"MessageID": "883953f4-6105-42a2-a16a-77a8eac79483",
"Metadata" : {
"a_key" : "a_value",
"b_key": "b_value"
},
"ServerID": 23,
"Description": "The server was unable to deliver your message (ex: unknown user, mailbox not found).",
"Details": "Test bounce details",
"Email": "john@example.com",
"From": "sender@example.com",
"BouncedAt": "2019-11-05T16:33:54.9070259Z",
"DumpAvailable": true,
"Inactive": true,
"CanActivate": true,
"Subject": "Test subject",
"Content": "<Full dump of bounce>"
}
If you’re developing on your local machine or don’t have a public URL for your API, the curl request to the right has an example webhook POST request. Replace <your-url>
with the API route that you want to use for your webhook URL. The curl request will allow you to verify that your webhook URL is able to accept requests with the same JSON format that the Postmark servers will use.
curl <your-url> \
-X POST \
-H "Content-Type: application/json" \
-d '{
"ID": 4323372036854775807,
"Type": "HardBounce",
"TypeCode": 1,
"Name": "Hard bounce",
"Tag": "Test",
"MessageID": "883953f4-6105-42a2-a16a-77a8eac79483",
"ServerID": 23,
"Description": "The server was unable to deliver your message (ex: unknown user, mailbox not found).",
"Details": "Test bounce details",
"Email": "john@example.com",
"From": "sender@example.com",
"BouncedAt": "2014-08-01T13:28:10.2735393-04:00",
"DumpAvailable": true,
"Inactive": true,
"CanActivate": true,
"RecordType": "Bounce",
"Subject": "Test subject"
}'
There are many possible uses for the data provided by using the bounce webhook: