Share
Embed
Transcript
35 slides
-
What is SendGrid? • Cloud-based SMTP provider • Massively scalable
• Analytics on emails you send • Robust APIS for developers to integrate -
What APIs does SendGrid Offer? API • Subuser API •
Credentials API • Event Webhook • Inbound Parse Webhook • SMTP API • Web API • Newsletter API • Reseller API APIs Overview -
Q: Why should I care about the SendGrid APIs? A:
There are a lot of reasons, but the short list is... • Reduce code complexity • Deeper analytics & tracking • Less resource consumption • Better UX APIs Overview -
SMTP API Custom SMTP header that contains instructions on how
to process your email Add extra information, filters, & manipulations: • Define multiple recipients • Text Substitutions • Categories • Unique arguments / Identifiers X-SMTPAPI: { ... } -
SMTP API Example: Billing notification X-SMTPAPI: { "to": ["[email protected]"], "category":
"billing_notifications", "unique_args": { "user_id": "12345" } } -
SMTP API X-SMTPAPI: { "to": ["[email protected]","[email protected]"], "sub": { "-intro-": ["-greetGuy-",
"-greetGirl-"], "-name-": ["John", "Jane"], }, "section": { "-greetGuy-": "Mr. -name-", "-greetGirl-": "Ms. -name-" } } -
SMTP API -intro-, Thanks for coming to SendGrid Delivered. You
rock! Sincerely, Swift -
Customer Highlight qup.tv Queue, rate, or watch movies on Netflix
instant with one click! -
Web API Send mail or manipulate SendGrid settings via HTTP
Anything (almost) you can do from the SendGrid dashboard, you can do from the Web API • Edit profile / account information • Add new Incoming Parse endpoints • Retrieve stats • Manage lists (Bounces, Blocks, Unsubscribes, etc.) • Add / Remove filters (apps) -
Web API Web API endpoints have the following format: https://sendgrid.com/api/<MODULE>.<ACTION>.<FORMAT>
Example: Send Email over HTTP curl -X POST http://sendgrid.com/api/mail.send.json \ -d “[email protected]” \ -d “[email protected]” \ -d “subject=hello world email” \ -d “text=some body text” \ -d “api_user=your_sendgrid_username” \ -d “api_key=your_sendgrid_key” -
Web API vs. SMTP API Q: Why would I use
HTTP instead of SMTP? (Don’t worry, this is a really common question) A: Normally, you won’t have to. Unless... • Your ISP is blocking common SMTP ports • There is high latency between your app and SendGrid • Difficult to install / configure SMTP drivers • Simplicity for developers -
Newsletter API Access the SendGrid newsletter app via the API
You can create & manage... • Newsletter content • Recipient lists • Sender identities • Scheduled deliveries https://sendgrid.com/api/newsletter/<ACTION>.<FORMAT> -
Webhooks Q: What are Webhooks? A: Webhooks are like inverse
API calls; you tell us where the data needs to go, we send it there. WEB HOOK -
•Processed •Dropped •Delivered •Bounced •Opened •Clicked •Spam Reported •Unsubscribed POST
Your Application receives an event POST (like a form submit) Receive notifications when SendGrid events happen Event Notification Webhook -
What does an event notification look like? { "email":"[email protected]", "timestamp":
1322000095, "unique_arg":"some argument", "category":"billing_notification", "event":"delivered" } Event Notification Webhook -
Q: Why would I want to use the event webhook?
A: Use it to enhance your existing email functionality and gain smart customer insight. Event Notification Webhook (It’s a very reactive API) -
Lets you receive email in your application EMAIL JSON 1.
User sends an email to *@yourapplication.com 2. SendGrid parses the email and attachments 3. You receive a JSON POST to your application Inbound Parse Webhook -
2. Point your domain’s MX records at SendGrid Type Value
MX 0 mx.sendgrid.net 3. Return a 200 status code from your application 1. Configure your hostname and URL settings http://sendgrid.com/developer/reply Inbound Parse Webhook -
{ "to":["[email protected]", "[email protected]"], "from":"Swift <[email protected]>", "subject":"SendGrid <3’s thoughbot", "text":"This is
some text body action", "html":"Supports <em>HTML</em> as well.", "attachments": 1, // ... } Inbound Parse Webhook -
Additional APIs Subuser API • Manage and control subuser accounts
Reseller API • For partners who want to integrate their platform directly Multiple Credentials API • Add new API keys and users to your account -
Pro Tip #1 UNOFFICIAL EVENT METRICS Delivered - Opened =
Time to Read Opened - Last Click = Time Spent Reading Processed - Delivered = SendGrid Delay For example: Opened + Clicks - (Click ∩ Opened) = Unofficial Clicks -
Pro Tip #2 EASY WEBHOOK TESTING • http://hookdebug.sendgrid.com • LocalTunnel
• RequestB.in Some Tools: -
Pro Tip #4 ENABLE / DISABLE FILTERS X-SMTPAPI: { "filters":
{ "footer": { "settings": { "enable": 1, "text/plain": "Sent from my flip phone." } } } } -
Additional Resources • Documentation: http://docs.sendgrid.com/ • Official Libraries: https://github.com/sendgrid/ •
Support: http://support.sendgrid.com/