-
Notifications
You must be signed in to change notification settings - Fork 21
Domains
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.
AccountApiClient client = Postmark.getAccountApiClient(<account token>);
// list domains
Domains domains = client.getDomains(Parameters.init().build("count",6).build("offset",0));
System.out.println(domains.getDomains().get(5).getName());
Retrieve single domain details.
// get domain details
Integer domainId = domains.getDomains().get(5).getId();
DomainDetails domainDetails = client.getDomainDetails(domainId);
System.out.println(domainDetails.getDkimPendingHost());
Create a new domain.
// create domain
Domain domain = new Domain();
domain.setName("account.example.com");
DomainDetails domainDetails = client.createDomain(domain);
Integer domainId = domainDetails.getId();
Update existing domain details.
DomainDetails domainDetails = new DomainDetails();
domainDetails.setReturnPathDomain("rp.account.example.com");
// update domain
domainDetails = client.setDomain(domainId, domainDetails);
System.out.println(domainDetails.getReturnPathDomain());
Trigger SPF verification for your domain
// verify spf
String response = client.verifyDomainSPF(domainId);
System.out.println(response);
Trigger DKIM verification for your domain
// verify spf
String response = client.verifyDomainDKIM(domainId);
System.out.println(response);
Trigger Return Path verification for your domain
// verify spf
String response = client.verifyDomainReturnPath(domainId);
System.out.println(response);
Trigger rotation of domain DKIM key.
// rotate dkim
String response = client.rotateDomainDKIM(domainId);
Delete one of existing domains.
// delete domain
String response = client.deleteDomain(domainId);
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.