twilio-sendgrid-email-send
Sends transactional and bulk email via SendGrid's v3 Mail Send API.
Identity proven by GitHub's verified organisation badge (twilio)
- Agents
- Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
- License
- MIT (permissive)
- Pin
- 8aba46fpinned Oct 9, 2026
- Context cost
- about 1,600 tokenswhen the skill loads
- GitHub stars
- 37on twilio/ai
- Scripts
- None found
What it does
“Send transactional and bulk email via the SendGrid v3 Mail Send API. Covers single sends, personalized batch sends with dynamic templates, scheduled sends with cancellation, attachments, and sandbox mode for testing. Use this skill when the caller has a SendGrid API key (SG.-prefix). Do NOT use this skill if the caller is using the Twilio Email API (comms.twilio.com) — that is a separate product with different credentials.”
Generated summary from the skill's own text
Sends transactional and bulk email via SendGrid's v3 Mail Send API. The skill handles single sends, personalized batch sends with dynamic templates, scheduled sends with cancellation, file attachments, and sandbox mode for testing. It requires a SendGrid API key and returns a 202 status code when email is queued for delivery.
When to use it
- Sending transactional emails like order confirmations or password resets
- Batch sending personalized emails to multiple recipients using templates
- Scheduling email sends up to 72 hours in advance with cancellation support
- Testing email logic in sandbox mode before production deployment
When not to
- Using Twilio Email API instead of SendGrid, which requires different credentials
- Sending to more than 1,000 recipients in a single API call
- Scheduling sends more than 72 hours in advance
Install
These commands install from the publisher's repository and need no account.
skills CLI
npx skills add twilio/ai --skill twilio-sendgrid-email-sendInstalls from the repository's default branch, which may have changed since the commit we checked.
GitHub CLI 2.90 or later
gh skill install twilio/ai twilio-sendgrid-email-send@8aba46fb65dc8d9a20f4b301a68352064b4159a5Installs the commit we checked (8aba46f).
Copy by hand
Download the folder at 8aba46f and put it in .claude/skills/twilio-sendgrid-email-send for Claude Code and in .agents/skills/twilio-sendgrid-email-send for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.
Claude Code plugin
/plugin install twilio-developer-kit@claude-plugins-officialThe publisher's plugin in Claude's official marketplace. It may hold more than this skill, and we have not pinned it.
Copy for your agent
A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.
Prompt
Install the agent skill "twilio-sendgrid-email-send" by Twilio. Source, pinned to commit 8aba46fb65dc8d9a20f4b301a68352064b4159a5: https://github.com/twilio/ai/tree/8aba46fb65dc8d9a20f4b301a68352064b4159a5/skills/sendgrid/twilio-sendgrid-email-send 1. Download that folder at exactly this commit. Do not use the default branch. 2. Copy every file unchanged, keeping the folder structure, into .claude/skills/twilio-sendgrid-email-send/ for Claude Code and .agents/skills/twilio-sendgrid-email-send/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist. 3. Do not edit the files, and do not run any script in the folder unless I ask you to. 4. When you are done, list the files you copied and where you put them. Listing and checks: https://www.agentnative.dev/skills/twilio/twilio-sendgrid-email-send
SKILL.md at the pin
---
name: twilio-sendgrid-email-send
description: >
Send transactional and bulk email via the SendGrid v3 Mail Send API.
Covers single sends, personalized batch sends with dynamic templates,
scheduled sends with cancellation, attachments, and sandbox mode for
testing. Use this skill when the caller has a SendGrid API key (SG.-prefix).
Do NOT use this skill if the caller is using the Twilio Email API
(comms.twilio.com) — that is a separate product with different credentials.
---
## Overview
> **Agent safety:** Always confirm recipients, subject, and content with the user before sending. Email is irreversible once delivered. Never send email autonomously without explicit user approval — especially for batch sends to multiple recipients.
All email sending goes through `POST /v3/mail/send`. This endpoint returns `202 Accepted` (queued) — NOT `200 OK` (delivered). Delivery confirmation comes asynchronously via Event Webhook. See `twilio-sendgrid-webhooks`.
---
## Basic Send
**Python**
```python
import os, sendgrid
from sendgrid.helpers.mail import Mail
sg = sendgrid.SendGridAPIClient(os.environ["SENDGRID_API_KEY"])
message = Mail(
from_email="verified@yourdomain.com",
to_emails="recipient@example.com",
subject="Order Confirmation",
html_content="<p>Your order #1234 is confirmed.</p>"
)
response = sg.send(message)
print(f"Status: {response.status_code}") # 202 = queued
```
**Node.js**
```javascript
const sgMail = require("@sendgrid/mail");
sgMail.setApiKey(process.env.SENDGRID_API_KEY);
const [response] = await sgMail.send({
to: "recipient@example.com",
from: "verified@yourdomain.com",
subject: "Order Confirmation",
html: "<p>Your order #1234 is confirmed.</p>",
});
console.log(`Status: ${response.statusCode}`); // 202 = queued
```
---
## Personalized Batch Send with Dynamic Templates
Dynamic templates use Handlebars syntax. Template IDs start with `d-`. Create templates in SendGrid Console > Email API > Dynamic Templates.
**Python**
```python
from sendgrid.helpers.mail import Mail, To
message = Mail(
from_email="noreply@yourdomain.com",
to_emails=[
To("alice@example.com", dynamic_template_data={"name": "Alice", "order_id": "123"}),
To("bob@example.com", dynamic_template_data={"name": "Bob", "order_id": "456"}),
],
)
message.template_id = "d-xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
sg.send(message)
```
**Node.js**
```javascript
await sgMail.send({
from: { email: "noreply@yourdomain.com" },
template_id: "d-xxxxxxxxxxxxxxxxxxxxxxxxxxxx",
personalizations: [
{ to: [{ email: "alice@example.com" }], dynamic_template_data: { name: "Alice", order_id: "123" } },
{ to: [{ email: "bob@example.com" }], dynamic_template_data: { name: "Bob", order_id: "456" } },
],
});
```
**Recipients in the same `to` array within a single personalization can see each other.** For private sends, use separate personalizations (one per recipient).
---
## Scheduled Sends
Schedule up to 72 hours in advance. Cancellation requires a batch ID assigned *before* sending.
**Python**
```python
import time, requests
headers = {"Authorization": f"Bearer {os.environ['SENDGRID_API_KEY']}", "Content-Type": "application/json"}
# Get batch ID first
batch = requests.post("https://api.sendgrid.com/v3/mail/batch", headers=headers).json()
# Include batch_id and send_at in the message
send_at = int(time.time()) + 3600 # Unix SECONDS, not ms
# Cancel if needed (before send_at)
requests.post("https://api.sendgrid.com/v3/user/scheduled_sends",
headers=headers,
json={"batch_id": batch["batch_id"], "status": "cancel"})
```
---
## Attachments
Base64-encode files in the `attachments` array. Total limit: 30MB per request (~22MB before encoding overhead).
```python
import base64
from sendgrid.helpers.mail import Mail, Attachment, FileContent, FileName, FileType, Disposition
with open("invoice.pdf", "rb") as f:
encoded = base64.b64encode(f.read()).decode()
message = Mail(from_email="billing@yourdomain.com", to_emails="customer@example.com",
subject="Your Invoice", html_content="<p>Invoice attached.</p>")
message.attachment = Attachment(FileContent(encoded), FileName("invoice.pdf"),
FileType("application/pdf"), Disposition("attachment"))
sg.send(message)
```
---
## Categories and Custom Args
**Categories** tag sends for analytics segmentation (up to 10 per message):
```python
message.category = ["transactional", "order-confirmation"]
```
**Custom Args** pass metadata through to Event Webhooks (key-value strings only):
```python
message.custom_args = {"order_id": "1234", "env": "production"}
```
These appear in webhook event payloads, enabling you to correlate delivery events back to your application data.
---
## Sandbox Mode (Testing)
Validates the request without delivering. Returns `200 OK` (not `202`).
```python
message.mail_settings = {"sandbox_mode": {"enable": True}}
response = sg.send(message) # 200 = validated, not sent
```
---
## CANNOT
- **Cannot send more than 1,000 recipients per API call** — Hard limit. Split into multiple requests.
- **Cannot schedule sends more than 72 hours in advance** — `send_at` rejects timestamps beyond 72h.
- **Cannot cancel a send after processing** — Only scheduled messages with a pre-assigned batch ID can be cancelled.
- **Cannot use `send_at` with milliseconds** — JS `Date.now()` returns ms. Divide by 1000 or the timestamp is silently rejected (>72h).
- **The `subject` field in personalizations is a plain string override** — To use dynamic subjects, set Handlebars variables (e.g., `{{{subject}}}`) in the Dynamic Template's subject field and pass values via `dynamic_template_data`. The personalizations `subject` key bypasses the template subject entirely.
- **Undefined template variables render as empty strings** — No error for typos in `dynamic_template_data` keys. Silent failures.
- **`413 Payload Too Large` returns nginx HTML, not JSON** — Exceeding 30MB returns HTML error page. Check Content-Type before parsing.
- **Empty `content` when using `template_id`** — Omit the `content` field. If you include both, `template_id` takes precedence and `content` is ignored.
> **Agent usage:** When sending email on behalf of a user, always report back what was sent — recipients, subject, and the API response status code. Maintain an application-level audit log for all sends.
---
## Next Steps
- **Account setup and domain auth:** `twilio-sendgrid-account-setup`
- **Templates and settings:** `twilio-sendgrid-email-settings`
- **Delivery tracking via webhooks:** `twilio-sendgrid-webhooks`
- **Manage bounces and unsubscribes:** `twilio-sendgrid-suppressions`
From twilio/ai at 8aba46f, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.
View SKILL.md on GitHub at 8aba46fFiles
- SKILL.md6.8 KB · 009f20484c8e
- agents/
- openai.yaml459 B · 988964dc98d2
- assets/
- icon-large.png9.6 KB · 0ba822e01172
- icon-small.png5.6 KB · 400e3f49b6c1
4 files, 22 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.
Skill folder on GitHub at 8aba46fMore from Twilio
twilio-account-setup
Sets up a Twilio account from scratch, including free trial signup, credential retrieval, phone number purchase, and enabling specific products like AI…
Claude Code, Codex, Cursor +4 · about 2.5K tokens · pinned 7 days ago
twilio-agent-augmentation-architect
This skill helps developers design AI-augmented contact center systems that enhance human agents with real-time intelligence.
Claude Code, Codex, Cursor +3 · about 3.6K tokens · pinned 7 days ago
twilio-agent-connect
Twilio Agent Connect is middleware that integrates LLM agents with Twilio communication channels (voice, SMS, RCS, WhatsApp, chat).
Claude Code, Codex, Cursor +4 · about 4.1K tokens · pinned 7 days ago
twilio-ai-agent-architect
Planning skill that helps developers design AI-powered conversational agents by assessing their use case across outcome sophistication, channels, and customer…
Claude Code, Codex, Cursor +3 · about 4.9K tokens · pinned 7 days ago
twilio-call-recordings
This skill teaches agents to record Twilio voice calls correctly using the appropriate method for the use case.
Claude Code, Codex, Cursor +4 · about 2.6K tokens · pinned 7 days ago
twilio-cli-reference
The Twilio CLI reference enables agents to manage Twilio resources directly from the terminal, including phone number provisioning, sending SMS and email…
Claude Code, Codex, Cursor +4 · about 1.8K tokens · pinned 7 days ago
Related in Backend and APIs
twilio-conference-calls
This skill enables multi-party call handling using Twilio Conference, covering warm and cold transfers, hold versus mute, supervisor coaching with whisper…
by TwilioOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.8K tokens · pinned 7 days ago
twilio-content-template-builder
This skill enables agents to create, manage, and send message templates through Twilio's Content API across WhatsApp, SMS, RCS, and MMS channels.
by TwilioOfficial publisher
Claude Code, Codex, Cursor +4 · about 1.3K tokens · pinned 7 days ago
twilio-conversation-orchestrator
This skill configures Twilio Conversation Orchestrator to automatically capture and route SMS, voice, WhatsApp, RCS, and web chat into unified conversations.
by TwilioOfficial publisher
Claude Code, Codex, Cursor +4 · about 8.3K tokens · pinned 7 days ago
twilio-conversations-classic-api
Build multi-channel messaging conversations using Twilio's classic API, combining SMS, WhatsApp, and web chat participants in persistent threads with message…
by TwilioOfficial publisher
Claude Code, Codex, Cursor +4 · about 4.2K tokens · pinned 7 days ago
twilio-iam-auth-setup
This skill guides agents through setting up Twilio authentication methods including Auth Tokens, API Keys (Standard, Main, Restricted), Access Tokens for…
by TwilioOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.3K tokens · pinned 7 days ago
twilio-isv-sms-best-practices
This skill guides ISVs building multi-tenant SMS platforms on Twilio through subaccount architecture, customer onboarding for A2P 10DLC and toll-free…
by TwilioOfficial publisher
Claude Code, Codex, Cursor +4 · about 2.7K tokens · pinned 7 days ago