Skip to content

Bounces

Igor Balos edited this page Nov 12, 2019 · 4 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.

let postmark = require("postmark")
const serverToken = "xxxx-xxxxx-xxxx-xxxxx-xxxxxx"
let client = new postmark.ServerClient(serverToken);

Retrieve delivery statistics

client.getDeliveryStatistics().then(result => {
    console.log(result.Bounces[0].Name);
});

Retrieve all the bounces:

client.getBounces({count:1, offset:0}).then(result => {
    console.log("Get Bounces");
    console.log(result.Bounces[0].RecordType);
    console.log(result.Bounces[0].ID);
    console.log(result.Bounces.length);
});

Retrieve a single bounce by bounce ID

client.getBounce(134567).then(result => {
    console.log("Get Bounces by ID");
    console.log(result.BouncedAt);
});

Retrieve a single bounce dump

client.getBounceDump(1234567).then(result => {
    console.log("Get Bounces Dump");
    console.log(result.Body);
});

Activate a single bounce message

You can activate a bounce some of the bounced messages.

client.activateBounce(1234567).then(result => {
    console.log(result.Message);
    console.log(result.Bounce.ID)
});