-
Notifications
You must be signed in to change notification settings - Fork 69
Servers
Igor Balos edited this page Oct 3, 2018
·
6 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.
account_token = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
client = Postmark::AccountApiClient.new(account_token, secure: true)
client.get_server(2)
# => {:id=>2, :name=>"Server", ... }
client.create_server(name: 'Server', color: 'red')
# => {:id=>2, :name=>"Server", :api_tokens=>[...], :server_link=>"...", :color=>"red", :smtp_api_activated=>false, :raw_email_enabled=>false, :inbound_address=>"...", :inbound_hook_url=>"", :bounce_hook_url=>"", :inbound_domain=>"", :inbound_hash=>"..."}
client.update_server(1, {
"Name": "Staging Testing",
"Color": "red",
"SmtpApiActivated": true,
"RawEmailEnabled": false
})
You can automatically scale your architecture by exploiting the Servers API. Start with loading a list of your first 10 servers:
client.get_servers(count: 10)
# => [{:id=>1, :name=>"postmark", :api_tokens=>[...], :color=>"blue", :smtp_api_activated=>false, :raw_email_enabled=>false, :inbound_address=>"...", :inbound_hook_url=>"", :bounce_hook_url=>"", :inbound_domain=>"", :inbound_hash=>"..."}]
You can also access the full servers list using a handy enumerator:
client.servers.take(3).map { |s| s[:id] }
# => [1]
client.delete_server(2)
# => {:error_code=>0, :message=>"Server Server 2 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