Emma API Documentation

Emma API

A word to the wise...

Use the information on this page to set up and troubleshoot your API calls. If you are interested in paid API support, visit our Custom Integrations page and fill out a request. Our system is monitored around the clock – and if there’s ever a dropped connection or outage, we’ll be sure to notify users on our status page.

All JSON payloads must not exceed 10MB

Overview

Emma’s platform is accessible through our public API, which provides access to the following areas:

  • Managing member lists:
    • Importing, editing and deleting
    • Organizing members into groups
    • Searching for members
  • Mailings:
    • Viewing past mailings
    • Controlling the status of pending mailings
  • Retrieving response:
    • Accessing mailing response information by mailing or member of time period
    • Accessing response at summary and detail levels

Note: If you are an HQ customer, please be sure to use a subaccount's ID in the path of your API call.

API wrappers

Emma’s wrappers make it a breeze to connect to our API no matter which programming language you like to use. Just select your language and you’ll be able to integrate with Emma without the hassle of having to study all the ins and outs of our API first.

This collection is young (but growing!) and includes wrappers commissioned by Emma as well as some built by members of our community. Unless otherwise noted, all wrappers provide full coverage of our current API. If you see something that needs to be fixed or improved, please don’t hesitate submit a pull request. And if you’ve built a wrapper that you’d like to have listed here, let us know!

PHP

EmmaPHP : Commissioned by Emma and built by Nashville developer Dennis Monsewicz.

OhMyEmma: Built by Nashville developer Jacques Woodcock.

Emma: Built by Nashville-based Abenity, Inc.

Python
EmmaPython: Built by Emma’s own Doug Hurst.
Ruby
EmmaRuby: Commissioned by Emma and built by Nashville developer Dennis Monsewicz.
Objective-C
EmmaSDK: Commissioned by Emma and built by Portland developer Benjamin Van Der Veen.
Node.js
emma-sdk: Built by New York City developer Nathan Peck for StoryDesk.
.NET
EmmaSharp: Built by developer Kyle Gregory

Quickstart

Let’s get started by building some PHP code that will add a member to our audience.

Before you do this, you will need a valid set of API keys. If you have a regular account you can generate your API keys using these steps:

  1. Go to account settings
  2. Find the "API Key" tab
  3. Click "Generate API Key"

If your account is part of an agency account, you will need to follow these steps instead:

  1. Go to "Menu" and select "Accounts"
  2. Click the downward-pointing arrow to the right of the account you need a key for and select its settings
  3. Scroll to the API key section to generate the key

Next, let’s add these authentication bits to our code.

// Authentication Variables
$account_id = "xxx";
$public_api_key = "xxx";
$private_api_key = "xxx";

Then we’ll want to capture the POSTed form variables from the request.

// Form variable(s)
$email = $_POST['email'];
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$groups = array(123456, 654321);

// Member data other than email should be passed in an array called "fields"
$member_data = array(
  "email" => $email,
  "fields" => array(
    "first_name" => $first_name,
    "last_name" => $last_name
  ),
  "group_ids" => $groups
);

Please note that the group_ids that you’re adding members to are passed as an array of integers. In addition, you’ll always want to make sure that you sanitize any of these form inputs to protect your application.

Now we’ll need to set the URL for the API call. The endpoint for all of our API calls is https://api.e2ma.net/. NOTE: You must use TLS version 1.1 or higher to connect. TLSv1 and all versions of SSL ciphers (e.g. SSLv2, SSLv3) are not supported.
In this case, we’re using the endpoint that corresponds to adding a single member. There’s a separate call for adding bulk members.

// Set URL
$url = "https://api.e2ma.net/".$account_id."/members/add";

Next, we’ll do a little dance with cURL that should look familiar to you. We’ll explain some particulars below the code block.

// setup and execute the cURL command
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, $public_api_key . ":" . $private_api_key);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($member_data));
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($member_data));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSLVERSION, 6);
$head = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);

Line 3 is where we use the public/private keys to authenticate our call. On lines 6-7, we force the API call to make its request in JSON and expect JSON in return.

At this point, the API call has been made. We might also want to inspect the result to see what happened. The API returns true HTTP response codes that you can examine to determine a request’s disposition.

//execute post
if($http_code > 200) {
  $app_message = "Error sending subscription request";
} else {
  $app_message = "Success!";
}

echo $app_message;

You can see the complete PHP script here. There’s also a PHP example to get members using their email address.

To extend this example further, you could make the API call associate the new member with a particular signup form. As written above, the member would be added to the audience but would not appear in the “recent activity” type searches or really any searches related to signups. Don’t worry – we’re currently working on a cleaner way to handle this signup form issue in the future.

API calls by category

In the following sections, we’ve organized API calls by their main entity type. Each call includes sample request and response data.

API rate limit

To prevent accidental overuse, calls to Emma's API are limited to 180 calls per minute. If you exceed the limit, you‘ll receive a response of 403 Rate Limit Exceeded until enough time has elapsed between calls.

Table Of Contents