Skip to content
SendGrid Python Library
Python Shell

Travis Badge

This library allows you to quickly and easily use the SendGrid Web API via Python.

Currently this library supports our v2 Mail endpoint and the v3 Web API.


pip install sendgrid


easy_install sendgrid


Environment Variables (for v3 Web API)

Sample .env, please rename to .env and add your SendGrid API Key, or you can pass your API Key into the SendGridClient constructor.

Quick Start

v2 Mail Send endpoint (Send an Email)

import sendgrid

sg = sendgrid.SendGridClient('YOUR_SENDGRID_API_KEY')

message = sendgrid.Mail()
message.add_to('John Doe <>')
message.set_from('Doe John <>')
status, msg = sg.send(message)
print(status, msg)


message = sendgrid.Mail(to='', subject='Example', html='Body', text='Body', from_email='')
status, msg = sg.send(message)
print(status, msg)

v3 Web API endpoints

import sendgrid

sg = sendgrid.SendGridAPIClient(apikey='YOUR_SENDGRID_API_KEY')
# You can also store your API key an .env variable 'SENDGRID_API_KEY'

response = sg.client.api_keys.get()


BREAKING CHANGE as of 2016.03.01

Version 2.0.0 is a breaking change for the Web API v3 endpoints. The mail send endpoint is not affected by this update.

Version 2.0.0 brings you full support for all Web API v3 endpoints. We have the following resources to get you started quickly:

Thank you for your continued support!

For the v2 Mail Send Endpoint, if you upgrade to version 1.2.x, the add_to method behaves differently. In the past this method defaulted to using the SMTPAPI header. Now you must explicitly call the smtpapi.add_to method. More on the SMTPAPI section.



How to Contribute

We encourage contribution to our libraries, please see our CONTRIBUTING guide for details.


Unsupported Libraries


SendGrid Logo

sendgrid-python is guided and supported by the SendGrid Developer Experience Team.

sendgrid-python is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-python are trademarks of SendGrid, Inc.

Something went wrong with that request. Please try again.