sendgrid 6.12.5


pip install sendgrid

  Latest version

Released: Sep 19, 2025

Project Links

Meta
Author: Elmer Thomas, Yamil Asusta
Requires Python: >=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*

Classifiers

Programming Language
  • Python :: 2.7
  • Python :: 3
  • Python :: 3.5
  • Python :: 3.6
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9
  • Python :: 3.10
  • Python :: 3.11
  • Python :: 3.12
  • Python :: 3.13
https://github.com/sendgrid/sendgrid-python/raw/HEAD/twilio_sendgrid_logo.png

Tests Badge Python Versions PyPI Version Docker Badge MIT licensed Twitter Follow GitHub contributors Open Source Helpers

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

NEW:

  • Version 6.X release is a BREAKING CHANGE from version 5.X, please see the release notes for details.

  • Send SMS messages with Twilio.

This library provides full support for all Twilio SendGrid Web API v3 endpoints, including v3 /mail/send.

We want this library to be community driven and Twilio SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create issues and pull requests or simply upvote or comment on existing issues or pull requests.

Please browse the rest of this README for further detail.

We appreciate your continued support, thank you!

Table of Contents

Installation

Prerequisites

  • Python version 2.7 and 3.5+

  • For email, you will need a Twilio SendGrid account, starting at the free level

  • For SMS messages, you will need a free Twilio account

Setup Environment Variables

Mac

Update the development environment with your SENDGRID_API_KEY (more info here), for example:

echo "export SENDGRID_API_KEY='YOUR_API_KEY'" > sendgrid.env
echo "sendgrid.env" >> .gitignore
source ./sendgrid.env

Twilio SendGrid also supports local environment file .env. Copy or rename .env_sample into .env and update SENDGRID_API_KEY with your key.

Windows

Temporarily set the environment variable (accessible only during the current CLI session):

set SENDGRID_API_KEY=YOUR_API_KEY

Permanently set the environment variable (accessible in all subsequent CLI sessions):

setx SENDGRID_API_KEY "YOUR_API_KEY"

Install Package

pip install sendgrid

Dependencies

Quick Start

Hello Email

The following is the minimum needed code to send an email with the /mail/send Helper (here is a full example):

With Mail Helper Class

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(str(e))

The Mail constructor creates a personalization object for you. Here is an example of how to add it.

Without Mail Helper Class

The following is the minimum needed code to send an email without the /mail/send Helper (here is a full example):

import os
from sendgrid import SendGridAPIClient

message = {
    'personalizations': [
        {
            'to': [
                {
                    'email': 'test@example.com'
                }
            ],
            'subject': 'Sending with Twilio SendGrid is Fun'
        }
    ],
    'from': {
        'email': 'test@example.com'
    },
    'content': [
        {
            'type': 'text/plain',
            'value': 'and easy to do anywhere, even with Python'
        }
    ]
}
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(str(e))

General v3 Web API Usage (With Fluent Interface)

import os
from sendgrid import SendGridAPIClient

sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.client.suppression.bounces.get()
print(response.status_code)
print(response.body)
print(response.headers)

General v3 Web API Usage (Without Fluent Interface)

import os
from sendgrid import SendGridAPIClient

sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.client._('suppression/bounces').get()
print(response.status_code)
print(response.body)
print(response.headers)

Processing Inbound Email

Please see our helper for utilizing our Inbound Parse webhook.

Usage

Use Cases

Examples of common API use cases, such as how to send an email with a transactional template or add an attachment or send an SMS message.

Announcements

All updates to this library are documented in our CHANGELOG and releases.

How to Contribute

We encourage contribution to our libraries (you might even score some nifty swag), please see our CONTRIBUTING guide for details.

Quick links:

Troubleshooting

Please see our troubleshooting guide for common library issues.

About

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

License

The MIT License (MIT)

7.0.0rc2 Oct 24, 2024
7.0.0rc1 Oct 04, 2024
6.12.5 Sep 19, 2025
6.12.4 Jun 12, 2025
6.12.3 May 29, 2025
6.12.2 May 13, 2025
6.12.1 May 13, 2025
6.12.0 May 05, 2025
6.11.0 Dec 01, 2023
6.10.0 Mar 22, 2023
6.9.7 Mar 09, 2022
6.9.6 Feb 09, 2022
6.9.5 Jan 26, 2022
6.9.4 Jan 12, 2022
6.9.3 Dec 15, 2021
6.9.2 Dec 01, 2021
6.9.1 Nov 17, 2021
6.9.0 Nov 03, 2021
6.8.3 Oct 18, 2021
6.8.2 Sep 22, 2021
6.8.1 Aug 25, 2021
6.8.0 Aug 11, 2021
6.7.1 Jun 16, 2021
6.7.0 Apr 21, 2021
6.6.0 Feb 10, 2021
6.5.0 Jan 13, 2021
6.4.8 Dec 02, 2020
6.4.7 Sep 16, 2020
6.4.6 Aug 19, 2020
6.4.5 Aug 05, 2020
6.4.4 Jul 22, 2020
6.4.3 Jul 10, 2020
6.4.2 Jul 08, 2020
6.4.1 Jun 25, 2020
6.4.0 Jun 24, 2020
6.3.1 May 13, 2020
6.3.0 Apr 29, 2020
6.2.2 Apr 15, 2020
6.2.1 Apr 01, 2020
6.2.0 Mar 18, 2020
6.1.3 Mar 05, 2020
6.1.2 Feb 20, 2020
6.1.1 Jan 24, 2020
6.1.0 Sep 12, 2019
6.0.5 May 02, 2019
6.0.4 Apr 06, 2019
6.0.3 Apr 06, 2019
6.0.2 Apr 03, 2019
6.0.1 Apr 03, 2019
6.0.0 Apr 03, 2019
5.6.0 Aug 21, 2018
5.5.0 Aug 16, 2018
5.4.1 Jun 26, 2018
5.4.0 Jun 07, 2018
5.3.0 Oct 23, 2017
5.2.1 Oct 22, 2017
5.2.0 Aug 31, 2017
5.1.0 Aug 31, 2017
5.0.1 Aug 29, 2017
5.0.0 Aug 11, 2017
4.2.1 Aug 04, 2017
4.2.0 Jun 01, 2017
4.1.0 May 09, 2017
4.0.0 Apr 05, 2017
3.6.5 Mar 30, 2017
3.6.4 Mar 29, 2017
3.6.3 Nov 14, 2016
3.6.2 Nov 11, 2016
3.6.1 Nov 11, 2016
3.6.0 Oct 11, 2016
3.5.0 Oct 11, 2016
3.4.0 Sep 03, 2016
3.3.1 Sep 01, 2016
3.3.0 Aug 31, 2016
3.2.10 Aug 17, 2016
3.2.3 Aug 31, 2016
3.2.2 Aug 24, 2016
3.2.1 Aug 17, 2016
3.2.0 Aug 17, 2016
3.1.10 Jul 28, 2016
3.1.9 Jul 26, 2016
3.1.8 Jul 25, 2016
3.1.7 Jul 25, 2016
3.0.7 Jul 20, 2016
3.0.6 Jul 12, 2016
3.0.5 Jul 11, 2016
3.0.4 Jul 08, 2016
3.0.3 Jul 08, 2016
3.0.2 Jul 08, 2016
3.0.1 Jul 05, 2016
3.0.0 Jun 14, 2016
2.2.1 Mar 03, 2016
2.1.1 Mar 03, 2016
2.1.0 Mar 03, 2016
2.0.0 Mar 02, 2016
1.6.22 Feb 08, 2016
1.6.21 Feb 08, 2016
1.6.20 Feb 04, 2016
1.5.20 Jan 12, 2016
1.5.19 Dec 04, 2015
1.5.18 Nov 24, 2015
1.5.17 Nov 18, 2015
1.5.16 Nov 17, 2015
1.5.15 Nov 17, 2015
1.5.14 Nov 10, 2015
1.5.13 Oct 29, 2015
1.5.12 Oct 28, 2015
1.5.11 Oct 27, 2015
1.5.10 Oct 26, 2015
1.5.9 Oct 26, 2015
1.5.8 Oct 21, 2015
1.5.7 Oct 19, 2015
1.5.6 Oct 16, 2015
1.5.5 Oct 16, 2015
1.5.4 Oct 15, 2015
1.5.3 Sep 29, 2015
1.4.3 Sep 25, 2015
1.4.2 Sep 15, 2015
1.4.0 Apr 27, 2015
1.3.0 Jan 23, 2015
1.2.4 Jan 21, 2015
1.2.3 Jan 12, 2015
1.2.2 Jan 10, 2015
1.2.1 Dec 31, 2014
1.2.0 Oct 21, 2014
1.1.2 Oct 08, 2014
1.1.1 Sep 09, 2014
1.1.0 Aug 25, 2014
1.0.1 Aug 05, 2014
1.0.0 Aug 05, 2014
0.5.4 Jul 18, 2014
0.5.3 Jul 18, 2014
0.5.2 Jul 18, 2014
0.5.1 Apr 23, 2014
0.5.0 Apr 14, 2014
0.4.1 Apr 13, 2014
0.4.0 Apr 09, 2014
0.3.7 Mar 27, 2014
0.3.6 Mar 26, 2014
0.3.5 Mar 20, 2014
0.3.4 Mar 19, 2014
0.3.3 Mar 18, 2014
0.3.2 Mar 14, 2014
0.3.1 Mar 08, 2014
0.3.0 Mar 08, 2014
0.2.9 Mar 04, 2014
0.2.8 Feb 22, 2014
0.2.7 Feb 22, 2014
0.2.6 Feb 12, 2014
0.2.5 Feb 07, 2014
0.2.4 Feb 04, 2014
0.2.3 Feb 03, 2014
0.2.2 Feb 02, 2014
0.2.1 Feb 01, 2014
0.2.0 Jan 31, 2014
0.1.4 Jun 29, 2013
0.1.3 Oct 26, 2012
0.1.2 Jul 27, 2012
0.1.1 Jul 16, 2012
0.1.0 Jun 28, 2012
1.6.22.macosx Feb 08, 2016
1.6.21.macosx Feb 08, 2016
1.6.20.macosx Feb 04, 2016
1.5.9.macosx Oct 26, 2015
1.5.8.macosx Oct 21, 2015
1.5.7.macosx Oct 19, 2015
1.5.6.macosx Oct 16, 2015
1.5.5.macosx Oct 16, 2015
1.5.4.macosx Oct 15, 2015
1.5.3.macosx Sep 29, 2015
1.5.19.macosx Dec 04, 2015
1.5.18.macosx Nov 24, 2015
1.5.17.macosx Nov 18, 2015
1.5.16.macosx Nov 17, 2015
1.5.15.macosx Nov 17, 2015
1.5.14.macosx Nov 10, 2015
1.5.13.macosx Oct 29, 2015
1.5.12.macosx Oct 28, 2015
1.5.11.macosx Oct 27, 2015
1.5.10.macosx Oct 26, 2015
1.4.3.macosx Sep 25, 2015
1.4.2.macosx Sep 15, 2015
1.4.0.macosx Apr 27, 2015
1.3.0.macosx Jan 23, 2015
1.2.4.macosx Jan 21, 2015
1.2.3.macosx Jan 12, 2015
1.2.2.macosx Jan 10, 2015
1.2.1.macosx Dec 31, 2014
1.2.0.macosx Oct 21, 2014
1.1.2.macosx Oct 08, 2014
1.1.1.macosx Sep 09, 2014
1.1.0.macosx Aug 25, 2014
1.0.1.macosx Aug 05, 2014
1.0.0.macosx Aug 05, 2014
0.5.4.macosx Jul 18, 2014
0.5.3.macosx Jul 18, 2014
0.5.2.macosx Jul 18, 2014
0.5.1.macosx Apr 23, 2014
0.5.0.macosx Apr 14, 2014
0.4.1.macosx Apr 13, 2014
0.4.0.macosx Apr 09, 2014
0.3.7.macosx Mar 27, 2014
0.3.6.macosx Mar 26, 2014
0.3.5.macosx Mar 20, 2014
0.3.4.macosx Mar 19, 2014
0.3.3.macosx Mar 18, 2014
0.3.2.macosx Mar 14, 2014
0.3.1.macosx Mar 08, 2014
0.3.0.macosx Mar 08, 2014
0.2.9.macosx Mar 04, 2014
0.2.8.macosx Feb 22, 2014
0.2.7.macosx Feb 22, 2014
0.2.6.macosx Feb 12, 2014
0.2.5.macosx Feb 07, 2014
0.2.4.macosx Feb 04, 2014
0.2.3.macosx Feb 03, 2014
0.2.2.macosx Feb 02, 2014
0.2.1.macosx Feb 01, 2014
0.2.0.macosx Jan 31, 2014

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
python-http-client (>=3.2.1)
cryptography (>=45.0.6)
werkzeug (<1.0.0,>=0.11.15)
werkzeug and (<2.0.0,>=0.15.0)
werkzeug and (<2.3.0,>=0.15.0)
werkzeug and (<3.1.0,>=0.16.0)
werkzeug (>=2.2.0)
werkzeug (>=2.3.5)
werkzeug (>=1.0.0)