Skip to content

Servers

Igor Balos edited this page Nov 13, 2017 · 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.

AccountApiClient client = Postmark.getAccountApiClient(<account token>);

Get server by ID

// get server id from list of servers
Integer serverId = client.getServers(Parameters.init().build("count", 5).build("offset", 0)).getServers().get(0).getId();

// get server by id
Server server = client.getServers(serverId);
System.out.println(server.getName());

Create server

server = new Server();
server.setName("NewServerName");

// create server
server = client.createServer(server);

Update server

server = new Server();
server.setName("CompletelyNewName");

// set server
server = client.setServer(serverId, server);

Get list of servers

Servers servers = client.getServers(Parameters.init().build("count", 5).build("offset", 0));
System.out.println(servers.getServers().get(0).getColor());

Delete a server

String response = client.deleteServer(serverId);