Skip to content

Bounces

Igor Balos edited this page Nov 12, 2019 · 13 revisions

In order to manage bounces, there are many different options within Postmark API client. Check out the code examples on how to use the bounces API feature.

For these API requests you will need to use a server API token. Once you obtain it, you will need to use server API client.

ApiClient client = Postmark.getApiClient(<server token>);
// retrieve delivery stats
DeliveryStats deliveryStats = client.getDeliveryStats();
deliveryStats.getBounces().get(0).getName();

List all the bounces:

// retrieve a list of bounces
Bounces bounces = client.getBounces(Parameters.init().build("count", 1).build("offset", 0));
bounces.getBounces().get(0).getBouncedAt();
// retrieve first bounce from bounce list and it's id
Bounces bounces client.getBounces(Parameters.init().build("count", 1).build("offset", 0));
Integer bounceId = bounces.getBounces().get(0).getId()

// retrieve a single bounce by bounce ID
Bounce bounce = client.getBounce(bounceId);
System.out.println(bounce.getDescription());
// retrieve a single bounce dump
BounceDump bounceDump = client.getBounceDump(bounceId);
// activate a single bounce message
Bounces bounces = client.getBounces(Parameters.init().build("count", 1).build("offset", 0).build("inactive",true));
client.activateBounce(bounces.getBounces().get(0).getId());