Skip to content

Servers

Igor Balos edited this page Oct 29, 2018 · 2 revisions

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

let postmark = require("postmark")
const accountToken = "xxxx-xxxxx-xxxx-xxxxx-xxxxxx"
let accountClient = new postmark.AccountClient(accountToken);

Get server by ID

accountClient.getServer(1234567).then(result => {
    console.log(result.ID);
    console.log(result.Name);
});

Create server

accountClient.createServer({Name: "ServerBlue"}).then(result => {
    console.log(result);
});

Update server

accountClient.editServer(1234567, {Name: "ServerNewName"}).then(result => {
    console.log(result.ID);
    console.log(result.Name);
});

Get list of servers

accountClient.getServers().then( result => {
    console.log(result.Servers.length);
});

Delete a server

accountClient.deleteServer(1234567).then(result => {
    console.log(result.Message);
    console.log(result.ErrorCode);
});