Skip to content

Messages

Igor Balos edited this page Oct 29, 2018 · 1 revision

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 outbound sent messages

client.getOutboundMessages({count:10, offset:0}).then(result => {
    console.log(result.TotalCount);
    console.log(result.Messages);
    console.log(result.Messages[0].To);
    console.log(result.Messages[0].Metadata.test);
    console.log(result.Messages[0].MessageID);
});

Retrieve single message details

client.getOutboundMessageDetails("xxxx-427b-47fa-ba43-xxxxxxxxx").then(result => {
    console.log(result.Body);
    console.log(result.Metadata.test);
    console.log(result.MessageEvents.length);
});

Retriveve single message dump content

client.getOutboundMessageDump("64812d80-427b-47fa-ba43-f27c6537025b").then(result => {
    console.log(result.Body);
});

Retrieve processed messages

client.getInboundMessages({count: 1, offset:0}).then(result => {
    console.log(result);
    console.log(result.InboundMessages[0].FromFull.Email);
});

Retrieve single processed message details.

client.getInboundMessageDetails("xxxx-291a-4d9d-ac1f-xxxxx").then(result => {
    console.log(result.HtmlBody);
    console.log(result);
});

Retry failed inbound message

client.retryInboundHookForMessage("xxxx-291a-4d9d-ac1f-xxxx").then(result => {
    console.log(result.Message);
});

Bypass inbound message

client.bypassBlockedInboundMessage("xxxx-291a-4d9d-ac1f-xxxx").then(result => {
    console.log(result.Message);
});