$ Demystifying APIs for Better Email Programs #LitmusLive • @swisswebmiss

Hello, my name is Heidi. Senior Front End Engineer @Bumped #LitmusLive • @swisswebmiss

https://eroi.com/profile-center #LitmusLive • @swisswebmiss

Behind the scenes Collect data about your subscribers Trigger emails based on behavior #LitmusLive • @swisswebmiss Automate tedious, time-consuming tasks

ESP vetting Free Plan • Create a list of 20 subscribers ¯_(ツ)_/¯ Sign Up #LitmusLive • @swisswebmiss Your Plan Platinum Plan • Will send email • • Will bend spacetime continuum Pre-built webform, add your logo! • Will also definitely send email Sign Up Contact Us

#LitmusLive • @swisswebmiss

If you develop emails, do you also work with APIs? #LitmusLive • @swisswebmiss Yes 36% No 64% Reporting from 55 people on Twitter and Women of Email Facebook Group

Job responsibilities Read API docs Put in requests for data Build and test dynamic logic Write SQL to query databases #LitmusLive • @swisswebmiss

Email developers !!= Real developers #LitmusLive • @swisswebmiss

Email developers !!=== Real developers Doubts? Check out amiarealdeveloper.com #LitmusLive • @swisswebmiss

We have the skills! (to avoid expensive ESP bills) Understand and analyze data #LitmusLive • @swisswebmiss Write complex logic in code Great at debugging

What’s so special about APIs? #LitmusLive • @swisswebmiss

#LitmusLive • @swisswebmiss

Automation Sync data between systems #LitmusLive • @swisswebmiss Build and trigger dynamic campaigns Analyze campaign metrics

Deliverability Marketing IP #LitmusLive • @swisswebmiss Transactional IP

Omnichannel Pulling data from multiple channels to build and deploy hyper-personalized messages. #LitmusLive • @swisswebmiss

Let’s dig in What is an API and what is not an API? Let’s write an API call! Enhance your customer journey API tips and tricks #LitmusLive • @swisswebmiss

What is an API? #LitmusLive • @swisswebmiss

Application Programming Interface #LitmusLive • @swisswebmiss

Application Programming Interface #LitmusLive • @swisswebmiss

Application Programming Interface HTTP REQUEST https://litmus.com #LitmusLive • @swisswebmiss

Application Programming Interface HTTP REQUEST https://litmus.com HTTP RESPONSE #LitmusLive • @swisswebmiss

Application Programming Interface HTTP REQUEST https://litmus.com HTTP RESPONSE #LitmusLive • @swisswebmiss

Types of APIs SOAP REST API Protocol API Architectural Style Reliable success and retry logic Excellent performance and scalability Server to server Client to server, optimized for the web #LitmusLive • @swisswebmiss

Authorization Since HTTP is stateless, every request will need to be authenticated. An API token or key acts as a password to an account, but more secure. #LitmusLive • @swisswebmiss

Anatomy of an API Call POST https:!//api.endpoint.com/3.0/lists/12345 HTTP Method: GET POST PATCH DELETE Fetching either a collection or a single resource Add a new resource to a collection Update a resource Delete a collection or record #LitmusLive • @swisswebmiss

Anatomy of an API Call POST https:!//api.endpoint.com/3.0/lists/12345 Endpoint URL #LitmusLive • @swisswebmiss

Anatomy of an API Call POST https:!//api.endpoint.com/3.0/lists/12345 API Version #LitmusLive • @swisswebmiss

Anatomy of an API Call POST https:!//api.endpoint.com/3.0/lists/12345 Resource (collection/ID) #LitmusLive • @swisswebmiss

Anatomy of an API Call POST Body https:!//api.endpoint.com/3.0/lists/12345 { } "email_address": "janet@thegoodplace.gov", "status": "subscribed", "first_name": "Janet", "last_name": "Demon" #LitmusLive • @swisswebmiss

API Responses HTTP/1.1 200 OK JSON { } "id": "666123666", "email_address": "janet@thegoodplace.gov", "first_name": "Janet", "last_name": "Demon", "ip_opt": "12.34.56.666", "timestamp_opt": "2018-10-31T12:00:07+00:00" #LitmusLive • @swisswebmiss

API Responses Status Code HTTP/1.1 200 OK { } "id": "666123666", "email_address": "janet@thegoodplace.gov", "first_name": "Janet", "last_name": "Demon", "ip_opt": "12.34.56.666", "timestamp_opt": "2018-10-31T12:00:07+00:00" #LitmusLive • @swisswebmiss

Status Codes 200-299 All good fam. 300-399 Try down the street. 400-499 Yo, you messed up. 500-599 Its not you, its me. The server. #LitmusLive • @swisswebmiss

What is not an API WTF is an SDK? #LitmusLive • @swisswebmiss

Software Development Kit API SDK An interface that allows software to talk to other software Set of tools, libraries, code samples, and/or guides Allow for the functioning of applications Allow for creation of applications #LitmusLive • @swisswebmiss

Webhook No request needed Register your URL with the service Avoids expensive rate limits #LitmusLive • @swisswebmiss Hey, what’s going on tonight? VS Hey, hit me up when you know what’s happening.

Let’s write an API call! #LitmusLive • @swisswebmiss

Tools Email Service Provider API Development Environment Terminal Application OR mailchimp.com #LitmusLive • @swisswebmiss getpostman.com iterm2.com

Setup Take note of the following values: • API Key • Datacenter: https://usXX.admin.mailchimp.com • List ID • Merge tags: Subscriber attributes #LitmusLive • @swisswebmiss

//TODO GET Get information about all segments in a list #LitmusLive • @swisswebmiss

Authenticate Type: Basic Auth Username: Your Mailchimp username Password: Your API Key #LitmusLive • @swisswebmiss

HTTP Request Select GET from HTTP request dropdown #LitmusLive • @swisswebmiss

API Endpoint Add API Endpoint to request URL: https:!//{datacenter}.api.mailchimp.com/3.0/lists/{list_id}/segments #LitmusLive • @swisswebmiss

Response Status Code Download JSON Response #LitmusLive • @swisswebmiss

//TODO POST Add a subscriber to a segment #LitmusLive • @swisswebmiss

Authenticate $ curl -H "Authorization: apikey 1234567890" #LitmusLive • @swisswebmiss

HTTP Request $ curl -H "Authorization: apikey 1234567890" -X POST #LitmusLive • @swisswebmiss

API Endpoint $ curl -H "Authorization: apikey 1234567890" -X POST https:"//{dc}.api.mailchimp.com/lists/ {list_id}/segments/{segment_id}/members #LitmusLive • @swisswebmiss

Body of request $ curl -H "Authorization: apikey 1234567890" -X POST https:"//{dc}.api.mailchimp.com/lists/ {list_id}/segments/{segment_id}/members -d '{"email_address" : "eleanor@earth.gov", "status" : "subscribed"}' #LitmusLive • @swisswebmiss

Response $ HTTP/1.1 200 OK { "id": "666-777-666", "email_address": "eleanor@earth.gov", "status": "subscribed" } #LitmusLive • @swisswebmiss

Enhance your customer journey #LitmusLive • @swisswebmiss

ONBOARDING Museum of Ice Cream To Heidi Olsen Welcome to the Museum of Ice Cream family! WELCOME EMAIL Welcome to the Museum of Ice Cream Why use an API? • • Specify a transaction-specific IP Faster deployment Which do you prefer? Tell us more about yourself and receive exclusive discounts, event invites and first dibs on new products! Chocolate Vanilla

https://www.museumoficecream.com/preference-center DATA GATHERING PREFERENCE CENTER Tell us more about yourself. Which flavor do you prefer? Chocolate Why use an API? • • Self-host page on your site Full control of the presentation and data Vanilla Both What would you like to hear about? Discounts Events New Products How do you like to receive messages? Email SMS/Text Update Snail Mail

STAY RELEVANT SMS MESSAGE Why use an API? • • Send to multiple channels from one platform Segment users based on preferences Use the code SPRINKLES to receive 20% off your order today!

AUTOMATED MSG PAYMENT ERROR Museum of Ice Cream To Heidi Olsen Important: Card payment did not go through. Why use a Webhook? • • Partner vendors like Stripe will ping your IP when there is an issue Automate program to send message to subscriber to ensure package ships on time. Oh no! There was a card error. The card you provided did not go through, please update your payment so your package can ship on time! Update Payment

Museum of Ice Cream To Heidi Olsen We found something you might like! OMNICHANNEL PERSONALIZED EMAIL Since you liked our sprinkle brushes… Sprinkles Makeup Case Why use an API? Channel your inner child and jump right into the sprinkle pool. Add to Cart • • Pull data from an eCommerce platform like Shopify Encourage your customers to engage across multiple channels including Instagram See the museum through our followers eyes View on Insta

MEASURE SUCCESS 100 70 REPORTING Why use an API? • • Expedites data transfer from multiple sources Parses data in readable format 75 52.5 50 35 25 17.5 0 0 April May June July

API tricks and tips #LitmusLive • @swisswebmiss

Vetting APIs Data architecture + language bindings Average downtime + availability Request limits + cost Documentation + support #LitmusLive • @swisswebmiss

Resources Mailchimp API documentation » Huge collection of free APIs » Curated list of fun APIs » Intro to REST APIs online course » #LitmusLive • @swisswebmiss

Next steps: Read through your ESP’s API documentation Practice writing calls in a sandbox account Strategize ways to enhance emails with APIs Believe in yourself #LitmusLive • @swisswebmiss

#LitmusLive • @swisswebmiss

Thank you #LitmusLive • @swisswebmiss