Skip to content

Senders

tomek-ac edited this page Jun 22, 2022 · 8 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)

You can easily list and manage all sender signatures within your account.

List sender signatures

client.get_signatures(offset: 0, count: 30)

# => [{:domain=>"example.com", :email_address=>"[email protected]", :reply_to_email_address=>"", :name=>"My Business", :confirmed=>true, :id=>2}]

Get a signatures enumerator:

client.signatures.map { |s| s[:id] }
# => [2]

client.signatures.lazy.select { |s| s[:domain] == 'example.com' }.first(2)
# => [{:domain=>"example.com", :email_address=>"[email protected]", :reply_to_email_address=>"", :name=>"My Business", :confirmed=>true, :id=>2}]

client.signatures.size # Lazily evaluated on Ruby 2.0.0 and above, not supported on legacy Ruby versions
# => 1

client.signatures.count # Calculates a count through iteration
# => 1

Retrieve sender signature details

client.get_sender(1)
# => {:domain=>"example.com", :email_address=>"[email protected]", ... }

Create a new sender signature

client.create_sender(name: 'Postmark', from_email: '[email protected]')

# => {:domain=>"postmarkapp.com", :email_address=>"[email protected]", :reply_to_email_address=>"", :name=>"Postmark", :confirmed=>false, ..., :id=>1}

Update sender signature

client.update_sender(1, name: 'Postmarkapp')

# => {:domain=>"example.com", :email_address=>"[email protected]", :reply_to_email_address=>"", :name=>"Postmarkapp", :confirmed=>false, ..., :id=>1}

Delete existing sender signature

client.delete_signature(1)

# => {:error_code=>0, :message=>"Signature [email protected] removed."}

Resend confirmation email

Re-send confirmation email for a signature:

client.resend_sender_confirmation(1)

# => {:error_code=>0, :message=>"Confirmation email for Sender Signature [email protected] was re-sent."} 

Request new Sender DKIM

client.request_new_sender_dkim(1)

# => {:dkim_text_value => '', ...}