-
Notifications
You must be signed in to change notification settings - Fork 71
Domains
Matt Goldman edited this page Oct 8, 2018
·
6 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.
account_token = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
client = Postmark::AccountApiClient.new(account_token, secure: true)
client.get_domains(offset: 0, count: 30)
# => [{"name": "wildbit.com", "spf_verified": true, "dkim_verified": true, "weak_dkim": false, "return_path_domain_verified": false, "id": 3 }]
To retrieve domains enumerator:
client.domains.map { |s| s[:id] }
# => [2]
client.domains.lazy.select { |s| s[:name] == 'wildbit.com' }.first(2)
# => [{"name": "wildbit.com", "spf_verified": true, "dkim_verified": true, "weak_dkim": false, "return_path_domain_verified": false, "id": 3 }]
client.domains.size # Lazily evaluated on Ruby 2.0.0 and above, not supported on legacy Ruby versions
# => 1
client.domains.count # Calculates a count through iteration
# => 1
client.get_domain(1)
client.create_domain(name: 'postmarkapp.com', return_path_domain: 'return.postmarkapp.com')
# => {"name": "postmarkapp.com", return_path_domain:"return.postmarkapp.com", "spf_verified": false, "spf_host": "postmarkapp.com", "spf_text_value": "v=spf1 a mx include:spf.mtasv.net ~all", "dkimverified": false, ..., "id": 1}
client.update_domain(1, return_path_domain: 'updated-return.postmarkapp.com')
# => {"name": "postmarkapp.com", return_path_domain:"updated-return.postmarkapp.com", "spf_verified": false, "spf_host": "postmarkapp.com", "spf_text_value": "v=spf1 a mx include:spf.mtasv.net ~all", "dkimverified": false, ..., "id": 1}
client.verified_domain_spf?(1345)
# => true
client.rotate_domain_dkim(1)
# => {:dkim_text_value => '', ...}
client.delete_domain(1)
# => {:error_code=>0, :message=>"Domain postmarkapp.com removed."}
For additional information about the capabilities of the Postmark API, see Postmark Developers Documentation.
- Email sending
- Test email sending
- Bounces
- Templates
- Templates push
- Server
- Servers
- Message Streams
- Webhooks
- Messages
- Domains
- Sender Signatures
- Stats
- Trigger Tags
- Suppressions
- Data Removals
- Trigger Inbound Rules
- Parsing Inbound
- Using Postmark with Mail library
- Accessing Postmark Message ID
- Error Handling
- Integration Testing
- Troubleshooting
- Known issues and how to resolve them