Mailflow Ruby library

This is Mailflow's official Ruby library. It allows convenient access to the Mailflow API, which allows you to:

  • Get, create and delete contacts
  • Update attributes for a specific contact
  • Tag and untag a specific contact
  • Trigger sequences on contact tag

Getting started

Install the gem

gem install mailflow-ruby

Provide API credentials

You can find your API credentials in the Integrations section of the Mailflow app.

require 'mailflow-ruby'

Mailflow.setup('API_KEY', 'SECRET_KEY')

Test authentication

Mailflow::Client.test

Returns 200 if authentication passes.

Contacts

Basic contact operations

List all contacts

Mailflow::Contact.list

Get a contact by email address or contact ID:

Mailflow::Contact.get({email: '[email protected]'})
Mailflow::Contact.get({contact_id: 'a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11'})

Create an unconfirmed contact (this will send the contact an opt-in email):

Mailflow::Contact.create({email: '[email protected]'})

Create a confirmed contact (and don't send an opt-in email)

Mailflow::Contact.create({email: '[email protected]', confirmed: true})

Contact tag operations

List a contact's tags:

contact = Mailflow::Contact.get({email: '[email protected]'})
contact.tags

Tag a contact (accepts an array only):

contact = Mailflow::Contact.get({email: '[email protected]'})
contact.tag(['Foo', 'Bar'])

Tag a contact and trigger any relevant sequences:

contact = Mailflow::Contact.get({email: '[email protected]'})
contact.tag(['Foo', 'Bar'], true)

Untag a contact (accepts an array only):

contact = Mailflow::Contact.get({email: '[email protected]'})
contact.untag(['Foo', 'Bar'])

Contact attribute operations

List a contact's attributes:

contact = Mailflow::Contact.get({email: '[email protected]'})
contact.attributes

Set attributes on a contact:

contact = Mailflow::Contact.get({email: '[email protected]'})
contact.set_attributes({'First name' => 'Foo', 'Last name' => 'Bar' })

More information

Contact [email protected] for more information.