| name | sendgrid-management |
| description | Use when managing SendGrid email services via CLI - sending emails, managing templates, contacts, lists,
suppressions, domains, API keys, webhooks, and viewing stats.
Triggers: "sendgrid send", "manage sendgrid", "sendgrid template", "sendgrid contacts", "sendgrid stats",
"sendgrid domain", "sendgrid api key", "sendgrid webhook", "email bounces", "sendgrid suppressions",
"verify sender", "sendgrid list", "marketing email", "transactional email".
Provides comprehensive CLI for all SendGrid API operations without needing the dashboard.
|
SendGrid Management
Complete CLI for managing SendGrid email services - send emails, manage templates, contacts, domains, and more.
Quick Reference
| Task | Command |
|---|
| Send email | sendgrid mail send --to user@example.com --subject "Hello" --text "Body" |
| Send with template | sendgrid mail send --to user@example.com --template-id d-xxx --data '{"name":"John"}' |
| List templates | sendgrid template list |
| Add contact | sendgrid contact add --email user@example.com --first-name John |
| View stats | sendgrid stats global --days 7 |
| List bounces | sendgrid suppression bounces |
| Create API key | sendgrid apikey create --name "My Key" --scopes mail.send |
Installation
deno run --allow-all ~/.claude/skills/sendgrid-management/cli/mod.ts [command]
cd ~/.claude/skills/sendgrid-management/cli && deno task compile
./dist/sendgrid --help
deno install --allow-all -n sendgrid ~/.claude/skills/sendgrid-management/cli/mod.ts
Authentication
sendgrid auth login --api-key SG.xxx
export SENDGRID_API_KEY="SG.xxx"
sendgrid auth status
Command Groups
| Group | Description |
|---|
auth | Authentication and config management |
mail | Send emails (transactional) |
template | Manage dynamic templates |
contact | Manage contacts |
list | Manage contact lists |
segment | Manage contact segments |
suppression | View/manage bounces, blocks, spam reports |
sender | Manage verified senders |
domain | Domain authentication (DKIM, SPF) |
stats | View email statistics |
webhook | Manage event webhooks |
apikey | Manage API keys |
validate | Validate email addresses |
Core Workflows
Workflow 1: Send Transactional Email
sendgrid mail send \
--to recipient@example.com \
--from sender@example.com \
--subject "Welcome!" \
--html "<h1>Hello</h1><p>Welcome to our service!</p>"
sendgrid mail send \
--to recipient@example.com \
--from sender@example.com \
--template-id d-f43daeeaef504760851f727007e0b5d0 \
--data '{"name": "John", "order_id": "12345"}'
sendgrid mail send \
--to user1@example.com,user2@example.com \
--from sender@example.com \
--subject "Announcement" \
--text "Important update..."
sendgrid mail send \
--to recipient@example.com \
--from sender@example.com \
--subject "Scheduled" \
--text "This was scheduled" \
--send-at "2024-12-25T10:00:00Z"
Workflow 2: Manage Templates
sendgrid template list
sendgrid template get <template-id>
sendgrid template create --name "Welcome Email" --generation dynamic
sendgrid template version create <template-id> \
--name "v1" \
--subject "Welcome {{name}}!" \
--html-file welcome.html \
--active
Workflow 3: Contact Management
sendgrid contact add \
--email user@example.com \
--first-name John \
--last-name Doe \
--list-ids abc123,def456
sendgrid contact import --file contacts.csv
sendgrid contact search --query "email LIKE '%@example.com'"
sendgrid contact export --list-id abc123 --output contacts.csv
sendgrid contact count
Workflow 4: List Management
sendgrid list create --name "Newsletter Subscribers"
sendgrid list all
sendgrid list add-contacts <list-id> --emails user1@example.com,user2@example.com
sendgrid list remove-contacts <list-id> --contact-ids id1,id2
sendgrid list delete <list-id>
Workflow 5: Suppression Management
sendgrid suppression bounces [--start-time 2024-01-01] [--end-time 2024-12-31]
sendgrid suppression blocks
sendgrid suppression spam-reports
sendgrid suppression unsubscribes
sendgrid suppression delete bounce user@example.com
sendgrid suppression add unsubscribe user@example.com
Workflow 6: Domain Authentication
sendgrid domain list
sendgrid domain create --domain example.com
sendgrid domain get <domain-id>
sendgrid domain validate <domain-id>
sendgrid domain set-default <domain-id>
Workflow 7: Sender Verification
sendgrid sender list
sendgrid sender create \
--from-email noreply@example.com \
--from-name "My Company" \
--reply-to support@example.com
sendgrid sender resend <sender-id>
sendgrid sender delete <sender-id>
Workflow 8: Statistics
sendgrid stats global --days 7
sendgrid stats category --categories transactional,marketing --days 30
sendgrid stats mailbox-providers --days 7
sendgrid stats browsers --days 7
sendgrid stats devices --days 7
Workflow 9: Webhooks
sendgrid webhook list
sendgrid webhook create \
--url https://example.com/webhook \
--events delivered,opened,clicked,bounced
sendgrid webhook update <webhook-id> --enabled false
sendgrid webhook test <webhook-id>
sendgrid webhook delete <webhook-id>
Workflow 10: API Keys
sendgrid apikey list
sendgrid apikey create \
--name "Production API" \
--scopes mail.send,templates.read
sendgrid apikey create --name "Admin Key" --full-access
sendgrid apikey update <key-id> --name "New Name"
sendgrid apikey delete <key-id>
JSON Output
All commands support --json for machine-readable output:
sendgrid template list --json | jq '.[].id'
sendgrid stats global --days 7 --json > stats.json
Environment Variables
| Variable | Description |
|---|
SENDGRID_API_KEY | API key (required) |
SENDGRID_FROM_EMAIL | Default from email |
SENDGRID_FROM_NAME | Default from name |
API Coverage
| Category | Endpoints | Status |
|---|
| Mail Send | send, schedule, batch | Complete |
| Templates | CRUD, versions | Complete |
| Contacts | add, import, search, export | Complete |
| Lists | CRUD, add/remove contacts | Complete |
| Segments | list, get | Partial |
| Suppressions | bounces, blocks, spam, unsubs | Complete |
| Senders | CRUD, verify | Complete |
| Domain Auth | CRUD, validate | Complete |
| Stats | global, category, geo, device | Complete |
| Webhooks | CRUD, test | Complete |
| API Keys | CRUD | Complete |
| Validation | single email | Complete |
Common Issues
| Error | Solution |
|---|
401 Unauthorized | Check API key is valid and has required scopes |
403 Forbidden | API key lacks permission for this action |
429 Rate Limited | Too many requests; wait and retry |
400 Bad Request | Check request parameters |
Resources