Skip to content
Igor Balos edited this page Apr 3, 2018 · 4 revisions

With API client you can easily manage all your account domains. Check out the examples of some of the API requests you can do with the library.

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.

AccountApiClientclient = Postmark.getAccountApiClient(<accounttoken>);
// list domainsDomainsdomains = client.getDomains(Parameters.init().build("count",6).build("offset",0));
System.out.println(domains.getDomains().get(5).getName());

Retrieve single domain details.

// get domain detailsIntegerdomainId = domains.getDomains().get(5).getId();
DomainDetailsdomainDetails = client.getDomainDetails(domainId);
System.out.println(domainDetails.getDkimPendingHost());

Create a new domain.

// create domainDomaindomain = newDomain();
domain.setName("account.example.com");
DomainDetailsdomainDetails = client.createDomain(domain);
IntegerdomainId = domainDetails.getId();

Update existing domain details.

DomainDetailsdomainDetails = newDomainDetails();
domainDetails.setReturnPathDomain("rp.account.example.com");
// update domaindomainDetails = client.setDomain(domainId, domainDetails);
System.out.println(domainDetails.getReturnPathDomain());

Trigger SPF verification for your domain

// verify spfStringresponse = client.verifyDomainSPF(domainId);
System.out.println(response);

Trigger DKIM verification for your domain

// verify spfStringresponse = client.verifyDomainDKIM(domainId);
System.out.println(response);

Trigger Return Path verification for your domain

// verify spfStringresponse = client.verifyDomainReturnPath(domainId);
System.out.println(response);

Trigger rotation of domain DKIM key.

// rotate dkimStringresponse = client.rotateDomainDKIM(domainId);

Delete one of existing domains.

// delete domainStringresponse = client.deleteDomain(domainId);

Clone this wiki locally