Discover / Marketing
SendGrid Email API SDK
by sendgridPython
Official Python SDK for Twilio SendGrid email API and campaign automation.
Maturity: stable because 14y old, 6.12.5 released 318d ago. Derived from release and commit history, not a rating.
- Stars
- 1.6k
- Forks
- 723
- Downloads / mo
- 27.3M
- Last commit
- 2026-06-25
- License
- MIT
- Open issues
- 65
Market and trust evidence
Edition not yet matchedNo exact skills.sh identity match is available for this repository. Repository adoption and freshness remain visible above; install momentum is not inferred.
Trust analysis is a screening signal, not a security warranty. Read the ranking and trust methodology.
In practice
Written by AI from this repository’s README · high confidenceSending transactional email and calling SendGrid endpoints from Python otherwise means hand building requests.
Use it when
When a Python application must send email or manage SendGrid resources such as suppressions.
Not the right pick when
It is bound to the SendGrid service, so an account and API key are needed even on the free level.
Capabilities
- Mail helper class for composing and sending email
- Full support for Web API v3 endpoints
- Fluent interface for arbitrary API paths
- Inbound email parse helper
- Reads the API key from an environment variable
Requirements
- Python version 2.7+
- A SendGrid account, starting at the free level
- A SENDGRID_API_KEY environment variable
Cost: Open source with a paid cloud option
Install
Derived from the published package name in the repository, not from a model.
Video walkthroughs
How to Get Started with SendGrid – Everything You Need to Know in 2026
Automating Scheduled Emails using SendGrid, NodeJS, and Cron Jobs
Third-party YouTube uploads matched to this tool by title, channel and repository name on 2026-08-03. Not made, reviewed or endorsed by SkillPilot. View counts and publish months are as of the match date and the month is approximate. Nothing loads from YouTube until you press play.
What the repository ships
Detected from the actual files in the repository root.
Latest release 6.12.5
Published 2025-09-19
Release Notes
Library - Fix
- PR #1114: #1108 - Replace ecdsa with cryptography. Thanks to @dacevedo12!
Library - Chore
- PR #1117: use make-test instead of make test-docker. Thanks to @tiwarishubham635!
Tags
README
SendGrid Logo
This library allows you to quickly and easily use the SendGrid Web API v3 via Python.
Version 3.X.X+ of this library provides full support for all SendGrid Web API v3 endpoints, including the new v3 /mail/send.
This library represents the beginning of a new path for SendGrid. We want this library to be community driven and 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.
If you need help using SendGrid, please check the Twilio SendGrid Support Help Center.
Please browse the rest of this README for further detail.
Table of Contents
- Installation
- Quick Start
- Processing Inbound Email
- Usage
- Use Cases
- Announcements
- How to Contribute
- Troubleshooting
- About
- Support
- License
<a name="installation"></a>
Installation
Prerequisites
- Python version 2.7+
- The SendGrid service, starting at the free level
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
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
<a name="quick-start"></a>
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 sendgrid
import os
from sendgrid.helpers.mail import *
sg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))
from_email = Email("test@example.com")
to_email = To("test@example.com")
subject = "Sending with SendGrid is Fun"
content = Content("text/plain", "and easy to do anywhere, even with Python")
mail = Mail(from_email, to_email, subject, content)
response = sg.client.mail.send.post(request_body=mail.get())
print(response.status_code)
print(response.body)
print(response.headers)
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 sendgrid
import os
sg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))
data = {
"personalizations": [
{
"to": [
{
"email": "test@example.com"
}
],
"subject": "Sending with SendGrid is Fun"
}
],
"from": {
"email": "test@example.com"
},
"content": [
{
"type": "text/plain",
"value": "and easy to do anywhere, even with Python"
}
]
}
response = sg.client.mail.send.post(request_body=data)
print(response.status_code)
print(response.body)
print(response.headers)
General v3 Web API Usage (With Fluent Interface)
import sendgrid
import os
sg = sendgrid.SendGridAPIClient(api_key=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 sendgrid
import os
sg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY'))
response = sg.client._("suppression/bounces").get()
print(response.status_code)
print(response.body)
print(response.headers)
<a name="inbound"></a>
Processing Inbound Email
Please see our helper for utilizing our Inbound Parse webhook.
<a name="usage"></a>
Usage
- SendGrid Documentation
- Library Usage Documentation
- Example Code
- How-to: Migration from v2 to v3
- v3 Web API Mail Send Helper - build a request object payload for a v3 /mail/send API call.
- Processing Inbound Email
<a name="use-cases"></a>
Use Cases
Examples of common API use cases, such as how to send an email with a transactional template.
<a name="announcements"></a>
Announcements
All updates to this library are documented in our CHANGELOG and releases.
<a name="contribute"></a>
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:
- Feature Request
- Bug Reports
- Improvements to the Codebase
- Review Pull Requests
<a name="troubleshooting"></a>
Troubleshooting
Please see our troubleshooting guide for common library issues.
<a name="about"></a>
About
sendgrid-python is maintained and funded by Twilio SendGrid, Inc. The names and logos for sendgrid-python are trademarks of Twilio SendGrid, Inc.
<a name="support"></a>
Support
If you need support, please check the Twilio SendGrid Support Help Center.
<a name="license"></a>
License
The MIT License (MIT)