Email API by developers, for developers

Create an email program with the Email API trusted by top brands to send at scale—delivering 148+ billion emails monthly.

Woman in glasses typing on a keyboard in a computer lab with multiple screens around.

TRUSTED BY TOP COMPANIES FOR WORRY-FREE SENDING:

How Email API works

Diagram of a secure messaging workflow with interconnected nodes and security indicators.

The Twilio Email API lets you create, send, and manage emails at scale with our RESTful APIs and SMTP relay (with support for various programming languages and frameworks).

Start sending quickly with features like dynamic templates, real-time email validation, and deliverability insights. Manage your email infrastructure with tools for authentication, ISP monitoring, and advanced analytics.

Email API use cases

Send at scale with the developer-first email platform

Alerts and notifications

Reach the inbox with Twilio’s industry-leading deliverability rates. Maximize your email campaign’s success with dedicated IPs, custom domains, and expert support.


Shopify uses Twilio’s Email API to help their 1.7 million merchants send important alerts about payments and shipping as well as marketing emails.

95.5%

average delivery rate

91.3%

inbox placement rate

1.7M

Shopify merchants

Smartphone screen showing notification of payment received for $135 with a thank you message.

Email API features

Your emails belong in the inbox—make sure they get there with our Email API.

Woman in glasses and yellow sweater holding a pencil during a meeting

Industry-leading 99% deliverability rate

Twilio ’s Email API leverages advanced infrastructure, authentication standards, and reputation management to land more emails where they belong—in the inbox.

  • Comprehensive email management

    Manage your email communications with features designed to improve performance, security, and user experience.

  • Dynamic Email Templates

    Create and customize beautiful, responsive emails with ease using our dynamic email templates.

  • Email Validation API

    Reduce bounce rates and improve sender reputation by validating email addresses in real time.

  • Authentication protocols

    Protect your email communications with comprehensive security features, including SPF, DKIM, DMARC, and TLS encryption.

  • Expert services

    Our team of email experts help set your email up for success, troubleshoot issues, and coach your program to higher deliverability and open rates.

  • Email testing

    Avoid spam filters, validate links, and render flawlessly across browsers and devices with our integrated email testing.

Start sending in your language

Integrate and deliver in minutes with our RESTful APIs and SMTP, libraries to support your programming language, and interactive documentation.

# using SendGrid's Python Library
# https://github.com/sendgrid/sendgrid-python
import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail

message = Mail(
    from_email='from_email@example.com',
    to_emails='to@example.com',
    subject='Sending with Twilio SendGrid is Fun',
    html_content='<strong>and easy to do anywhere, even with Python</strong>')
try:
    sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
    response = sg.send(message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e.message)
curl --request POST \
	--url https://api.sendgrid.com/v3/mail/send \
	--header "Authorization: Bearer $SENDGRID_API_KEY" \
	--header 'Content-Type: application/json' \
	--data '{"personalizations": [{"to": [{"email": "test@example.com"}]}],"from": {"email": "test@example.com"},"subject": "Sending with SendGrid is Fun","content": [{"type": "text/plain", "value": "and easy to do anywhere, even with cURL"}]}'
// using Twilio SendGrid's v3 Node.js Library
// https://github.com/sendgrid/sendgrid-nodejs
const sgMail = require('@sendgrid/mail');
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const msg = {
  to: 'test@example.com',
  from: 'test@example.com',
  subject: 'Sending with Twilio SendGrid is Fun',
  text: 'and easy to do anywhere, even with Node.js',
  html: '<strong>and easy to do anywhere, even with Node.js</strong>',
};
sgMail.send(msg);
# using SendGrid's Ruby Library
# https://github.com/sendgrid/sendgrid-ruby
require 'sendgrid-ruby'
include SendGrid

from = Email.new(email: 'test@example.com')
to = Email.new(email: 'test@example.com')
subject = 'Sending with SendGrid is Fun'
content = Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby')
mail = Mail.new(from, subject, to, content)

sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
response = sg.client.mail._('send').post(request_body: mail.to_json)
puts response.status_code
puts response.body
puts response.headers
// using SendGrid's Go Library
// https://github.com/sendgrid/sendgrid-go
package main

import (
	"fmt"
	"log"
	"os"

	"github.com/sendgrid/sendgrid-go"
	"github.com/sendgrid/sendgrid-go/helpers/mail"
)

func main() {
	from := mail.NewEmail("Example User", "test@example.com")
	subject := "Sending with SendGrid is Fun"
	to := mail.NewEmail("Example User", "test@example.com")
	plainTextContent := "and easy to do anywhere, even with Go"
	htmlContent := "<strong>and easy to do anywhere, even with Go</strong>"
	message := mail.NewSingleEmail(from, subject, to, plainTextContent, htmlContent)
	client := sendgrid.NewSendClient(os.Getenv("SENDGRID_API_KEY"))
	response, err := client.Send(message)
	if err != nil {
		log.Println(err)
	} else {
		fmt.Println(response.StatusCode)
		fmt.Println(response.Body)
		fmt.Println(response.Headers)
	}
}
<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing  with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$email = new \SendGrid\Mail\Mail(); 
$email->setFrom("test@example.com", "Example User");
$email->setSubject("Sending with SendGrid is Fun");
$email->addTo("test@example.com", "Example User");
$email->addContent("text/plain", "and easy to do anywhere, even with PHP");
$email->addContent(
    "text/html", "<strong>and easy to do anywhere, even with PHP</strong>"
);
$sendgrid = new \SendGrid(getenv('SENDGRID_API_KEY'));
try {
    $response = $sendgrid->send($email);
    print $response->statusCode() . "\n";
    print_r($response->headers());
    print $response->body() . "\n";
} catch (Exception $e) {
    echo 'Caught exception: '. $e->getMessage() ."\n";
}
// using SendGrid's Java Library
// https://github.com/sendgrid/sendgrid-java
import com.sendgrid.*;
import java.io.IOException;

public class Example {
  public static void main(String[] args) throws IOException {
    Email from = new Email("test@example.com");
    String subject = "Sending with SendGrid is Fun";
    Email to = new Email("test@example.com");
    Content content = new Content("text/plain", "and easy to do anywhere, even with Java");
    Mail mail = new Mail(from, subject, to, content);

    SendGrid sg = new SendGrid(System.getenv("SENDGRID_API_KEY"));
    Request request = new Request();
    try {
      request.setMethod(Method.POST);
      request.setEndpoint("mail/send");
      request.setBody(mail.build());
      Response response = sg.api(request);
      System.out.println(response.getStatusCode());
      System.out.println(response.getBody());
      System.out.println(response.getHeaders());
    } catch (IOException ex) {
      throw ex;
    }
  }
}
// using SendGrid's C# Library
// https://github.com/sendgrid/sendgrid-csharp
using SendGrid;
using SendGrid.Helpers.Mail;
using System;
using System.Threading.Tasks;

namespace Example
{
    internal class Example
    {
        private static void Main()
        {
            Execute().Wait();
        }

        static async Task Execute()
        {
            var apiKey = Environment.GetEnvironmentVariable("NAME_OF_THE_ENVIRONMENT_VARIABLE_FOR_YOUR_SENDGRID_KEY");
            var client = new SendGridClient(apiKey);
            var from = new EmailAddress("test@example.com", "Example User");
            var subject = "Sending with SendGrid is Fun";
            var to = new EmailAddress("test@example.com", "Example User");
            var plainTextContent = "and easy to do anywhere, even with C#";
            var htmlContent = "<strong>and easy to do anywhere, even with C#</strong>";
            var msg = MailHelper.CreateSingleEmail(from, to, subject, plainTextContent, htmlContent);
            var response = await client.SendEmailAsync(msg);
        }
    }
}

Need help building? No problem.

Build your one-of-a-kind email program with help from our partners. View partners 

Flowchart showing News and Trends leading to Delivered on a dark background.

2024 Email Deliverability Guide

Learn how to get your emails to the inbox with the latest industry trends, email news, and best practices.

Why Twilio Email

148+ billion

emails sent every month

99%

deliverability rate

99.99%

uptime SLA

1.9 second

median delivery speed

Get started for free

Sign up for a free trial to experience Twilio’s reliable, scalable email delivery.

Woman with curly hair and glasses working on a computer in a modern office environment.

FAQ

The Twilio Email API is a powerful tool that enables you to send, receive, and manage emails programmatically. It provides features like dynamic templates, real-time analytics, and robust security to ensure your emails reach the inbox and engage your audience effectively.

To get started, sign up for a free Twilio email account, obtain your API key, and integrate the API with your application using our comprehensive documentation. You can find guides and code examples for various programming languages in our docs section.

Yes, the Twilio Email API supports both transactional and marketing emails. You can use dynamic templates to customize your emails and target different segments of your audience with personalized content.

Twilio offers advanced analytics and reporting tools that provide detailed metrics on open rates, click-through rates, bounce rates, and more. You can access these insights through our user-friendly dashboards to optimize your email campaigns.

Twilio offers 24/7 support to help you troubleshoot issues and optimize your email campaigns. Our support team is available to assist you with any questions or problems you may encounter.

Twilio leverages a globally distributed, cloud-based architecture and advanced deliverability tools to ensure your emails reach the inbox. Features like ISP monitoring, sender authentication, and dedicated IP addresses help maintain optimal deliverability rates.

Yes, SendGrid was acquired by Twilio and the SendGrid Email API is now referred to as the Twilio Email API. You get the same infrastructure, excellent deliverability, easy integration, and developer tools to support your email program. Plus, you can access all the communication channels and customer data that’s available on the Twilio platform.