Demystifying APIs for Better Email Programs

A presentation at Litmus Live San Francisco in November 2018 in San Francisco, CA, USA by Heidi Olsen

Slide 1

Slide 1

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

Slide 2

Slide 2

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

Slide 3

Slide 3

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

Slide 4

Slide 4

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

Slide 5

Slide 5

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

Slide 6

Slide 6

#LitmusLive • @swisswebmiss

Slide 7

Slide 7

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

Slide 8

Slide 8

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

Slide 9

Slide 9

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

Slide 10

Slide 10

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

Slide 11

Slide 11

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

Slide 12

Slide 12

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

Slide 13

Slide 13

#LitmusLive • @swisswebmiss

Slide 14

Slide 14

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

Slide 15

Slide 15

Deliverability Marketing IP #LitmusLive • @swisswebmiss Transactional IP

Slide 16

Slide 16

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

Slide 17

Slide 17

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

Slide 18

Slide 18

What is an API? #LitmusLive • @swisswebmiss

Slide 19

Slide 19

Application Programming Interface #LitmusLive • @swisswebmiss

Slide 20

Slide 20

Application Programming Interface #LitmusLive • @swisswebmiss

Slide 21

Slide 21

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

Slide 22

Slide 22

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

Slide 23

Slide 23

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

Slide 24

Slide 24

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

Slide 25

Slide 25

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

Slide 26

Slide 26

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

Slide 27

Slide 27

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

Slide 28

Slide 28

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

Slide 29

Slide 29

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

Slide 30

Slide 30

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

Slide 31

Slide 31

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

Slide 32

Slide 32

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

Slide 33

Slide 33

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

Slide 34

Slide 34

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

Slide 35

Slide 35

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

Slide 36

Slide 36

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.

Slide 37

Slide 37

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

Slide 38

Slide 38

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

Slide 39

Slide 39

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

Slide 40

Slide 40

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

Slide 41

Slide 41

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

Slide 42

Slide 42

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

Slide 43

Slide 43

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

Slide 44

Slide 44

Response Status Code Download JSON Response #LitmusLive • @swisswebmiss

Slide 45

Slide 45

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

Slide 46

Slide 46

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

Slide 47

Slide 47

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

Slide 48

Slide 48

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

Slide 49

Slide 49

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

Slide 50

Slide 50

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

Slide 51

Slide 51

Enhance your customer journey #LitmusLive • @swisswebmiss

Slide 52

Slide 52

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

Slide 53

Slide 53

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

Slide 54

Slide 54

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!

Slide 55

Slide 55

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

Slide 56

Slide 56

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

Slide 57

Slide 57

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

Slide 58

Slide 58

API tricks and tips #LitmusLive • @swisswebmiss

Slide 59

Slide 59

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

Slide 60

Slide 60

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

Slide 61

Slide 61

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

Slide 62

Slide 62

#LitmusLive • @swisswebmiss

Slide 63

Slide 63

Thank you #LitmusLive • @swisswebmiss