SendGrid Integration Guide
Technology: sendgrid · Category: comms · Last reviewed: 2026-10-20
Source: https://tech-stack.codeamanilabs.org/guide/sendgrid
Insight:
Resend + React Email is codeAmani's primary email provider; SendGrid is the alternative for client projects that require it (an existing SendGrid account, subusers per tenant, dedicated IPs and IP pools, EU data residency, or a Twilio consolidation). There is no free plan any more (retired May 2025; new accounts get a 60-day, 100/day trial, then Essentials from $19.95/mo). Authenticate the domain, publish DMARC, send marketing mail with an unsubscribe group so SendGrid adds RFC 8058 one-click headers, and verify the ECDSA signature on both the Event Webhook and Inbound Parse against the raw body.
███████╗███████╗███╗ ██╗██████╗ ██████╗ ██████╗ ██╗██████╗
██╔════╝██╔════╝████╗ ██║██╔══██╗██╔════╝ ██╔══██╗██║██╔══██╗
███████╗█████╗ ██╔██╗ ██║██║ ██║██║ ███╗██████╔╝██║██║ ██║
╚════██║██╔══╝ ██║╚██╗██║██║ ██║██║ ██║██╔══██╗██║██║ ██║
███████║███████╗██║ ╚████║██████╔╝╚██████╔╝██║ ██║██║██████╔╝
╚══════╝╚══════╝╚═╝ ╚═══╝╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝╚═════╝
SendGrid Integration Guide
Focus: When and how codeAmani uses Twilio SendGrid as the alternative to its primary email provider, Resend. Covers sending with
@sendgrid/mail(Mail Send v3), dynamic templates, domain authentication and link branding, DMARC and the Gmail/Yahoo/Microsoft bulk-sender rules, the signed Event Webhook, signed Inbound Parse, suppressions and unsubscribe groups, subusers, IP pools, and EU data residency.
Overview
Twilio SendGrid is a high-volume email platform: Web API v3 and SMTP, Handlebars dynamic templates, Marketing Campaigns, subusers, dedicated IPs, and a detailed event pipeline. It is advertised as an email option on motionstackstudios.com.
Resend + React Email is codeAmani's primary email provider (see ../resend/). It has cleaner DX, React-rendered templates, a permanent free tier, and fewer moving parts. Use SendGrid only when a client project needs something Resend doesn't give you:
- the client already runs a SendGrid account and won't migrate,
- subusers: per-tenant sending with isolated reputation, stats, and credit limits (Pro and up),
- dedicated IPs and IP pools to split transactional from marketing reputation (Pro includes 1 IP),
- EU data residency for email event data (Pro and up, EU subuser),
- consolidating SMS, WhatsApp, Verify, and email on one Twilio account and bill.
What changed since the last review (details in NOTES.md):
| Change | Date | Impact |
|---|---|---|
| Free plan retired; new accounts get a 60-day trial (100 emails/day) | Trial from 25 Mar 2025; retirement announced 27 May 2025 | No free tier for side projects. Budget Essentials $19.95/mo minimum |
| Event Webhook must be HTTPS | New configs from Oct 2025; existing ones by 11 Feb 2026 | HTTP webhooks have stopped receiving events |
| Event Webhook security: OAuth 2.0 option alongside ECDSA signing; multiple webhooks per account (1 / 2 / 5 by plan) | current | Each webhook has its own key pair |
| Signed Inbound Parse via webhook security policies | current | Inbound Parse can now be verified. The old "Inbound Parse is unsigned" advice is out of date |
EU data residency (api.eu.sendgrid.com) GA |
15 Jul 2025 | client.setDataResidency('eu') in the Node SDK |
| v2 Mail Send capped at 1,000 recipients per request | 9 Jul 2025 | Use v3 anyway |
| Email Activity API limited to 6 requests/minute | 9 Dec 2025 | Use the Event Webhook for status, not polling |
| "Send to Coworker" removed from domain authentication setup | 3 Aug 2026 | Hand DNS records to whoever owns DNS yourself |
flowchart LR
A["Your App"] -->|"templateId + dynamicTemplateData + customArgs"| B["@sendgrid/mail"]
B --> C["POST /v3/mail/send<br/>(202 Accepted)"]
C --> D["Recipient inbox"]
C -->|"batched delivery + engagement events"| E["Event Webhook (HTTPS)"]
E -->|"X-Twilio-Email-Event-Webhook-Signature"| F["Your route (Node runtime)"]
F -->|"ECDSA verify over timestamp + raw body"| G{"Valid?"}
G -->|"yes"| H["Dedupe sg_event_id, update DB, mirror suppressions"]
G -->|"no"| I["403"]
Check first. Before wiring SendGrid into a build, query the
codeAmani-tech-stackMCP (search_guides/get_guide) and confirm Resend can't meet the requirement. SendGrid adds a second vendor and a second deliverability footprint.
Official Documentation
More links in RESOURCES.md; API cheatsheet in reference/api-cheatsheet.md; plans in reference/limits-and-pricing.md.
SDK Setup
npm install @sendgrid/mail@8.1.6 @sendgrid/client@8.1.6 @sendgrid/eventwebhook@8.0.0 -E
Versions (npm, 2026-10-20):
@sendgrid/mailand@sendgrid/client8.1.6 (published Sep 2025, still latest),@sendgrid/eventwebhookand@sendgrid/helpers8.0.0. They ship from thesendgrid-nodejsmonorepo and share the v8 major. Types are bundled.@sendgrid/clientusesaxiosunder the hood, so these packages are Node-only: run send and webhook routes on the Node runtime, not Edge. From an Edge or Workers runtime, callPOST https://api.sendgrid.com/v3/mail/sendwithfetchinstead.
Initialize the client
// lib/sendgrid.ts (server-only)
import sgMail from '@sendgrid/mail';
import client from '@sendgrid/client';
const apiKey = process.env.SENDGRID_API_KEY;
if (!apiKey) throw new Error('SENDGRID_API_KEY is not set');
client.setApiKey(apiKey);
// client.setDataResidency('eu'); // EU subuser on Pro+: routes to https://api.eu.sendgrid.com/
sgMail.setClient(client);
sgMail.setTimeout(10_000);
export { sgMail, client };
Create the key under Settings → API Keys as Restricted Access with only Mail Send for the app. Keep a separate key with suppression or webhook scopes for admin scripts.
Core Patterns
Send with a dynamic template
Dynamic templates are Handlebars templates built in the dashboard (Email API → Dynamic Templates). You reference one by templateId (always d-…) and pass dynamicTemplateData. The template owns the subject and body, so don't set subject or html.
import { sgMail } from '@/lib/sendgrid';
const [res] = await sgMail.send({
to: 'user@example.com',
from: { email: 'no-reply@mail.client.example', name: 'Client App' },
templateId: 'd-0123456789abcdef0123456789abcdef',
dynamicTemplateData: { userName: 'Amani', dashboardUrl: 'https://app.client.example' },
customArgs: { user_id: 'usr_123', kind: 'welcome' }, // strings only; echoed on every event
categories: ['welcome'],
trackingSettings: { clickTracking: { enable: false, enableText: false }, openTracking: { enable: false } },
});
// 202 Accepted. Store the message id so webhook events can be matched back.
const messageId = String(res.headers['x-message-id'] ?? '');
Full route with input validation and error handling: examples/send-email.ts. Turn click and open tracking off for transactional mail (receipts, password resets): rewritten links and pixels hurt trust and add nothing.
Errors
The SDK rejects with a ResponseError. Field-level detail is in err.response.body.errors[] ({ message, field, help }). Log the messages, never the API key or recipient list.
Many recipients without leaking the list
A bare to: [...] puts everyone in one To: header. Use personalizations (one per recipient, up to 1,000 per request) or pass true as the second argument to send (isMultiple), which does the same thing.
await sgMail.send({
from: { email: 'news@mail.client.example', name: 'Client' },
templateId: 'd-...',
personalizations: recipients.map((r) => ({ to: [{ email: r.email }], dynamicTemplateData: { name: r.name } })),
asm: { groupId: 12345, groupsToDisplay: [12345] }, // unsubscribe group: see Bulk-sender rules
});
Other Mail Send fields worth knowing
| Field (SDK name) | Use | Limit |
|---|---|---|
sendAt |
Schedule (Unix seconds) | At most 72 hours ahead |
batchId |
Group a scheduled send so you can cancel or pause it | Create via POST /v3/mail/batch |
ipPoolName |
Send from a dedicated IP pool | 2–64 chars |
categories |
Stats grouping | Max 10, each ≤ 255 chars |
customArgs |
Correlation ids returned on events | ≤ 10,000 bytes |
asm |
Unsubscribe group (groupId, groupsToDisplay ≤ 25) |
|
mailSettings.sandboxMode |
Validate without sending (CI) | |
mailSettings.bypassListManagement |
Skip suppressions. Only for legally required notices (for example a security alert) | Can't combine with other bypass flags |
replyToList |
Several reply-to addresses | ≤ 1,000 |
You can't override To, From, Subject, Reply-To, CC, BCC, Content-Type, DKIM-Signature, or the x-sg-* headers through headers.
Domain Authentication, Link Branding, and DMARC
Deliverability depends on authentication. An unauthenticated send lands in spam or shows "via sendgrid.net". Authenticate the domain before sending anything real. codeAmani manages DNS in Porkbun or Cloudflare (see ../porkbun/ and ../domain-portfolio/).
flowchart TD
A["Settings → Sender Authentication →<br/>Authenticate Your Domain"] --> B["SendGrid returns 3 CNAMEs<br/>(em#### return-path + s1/s2._domainkey)"]
B --> C["Add them in Porkbun / Cloudflare<br/>(host part only, DNS-only / unproxied)"]
C --> D["Verify in SendGrid"]
D --> E{"Verified?"}
E -->|"no"| F["Wait for propagation, recheck"]
F --> D
E -->|"yes"| G["Link branding (url####, ####.domain)"]
G --> H["Add _dmarc TXT yourself"]
H --> I["Send from the authenticated domain"]
- Settings → Sender Authentication → Authenticate Your Domain. Use a sending subdomain (for example
mail.client.example). Keep automated security on: SendGrid then gives you CNAMEs and rotates DKIM keys and manages SPF behind them. API:POST /v3/whitelabel/domains. - Add the three CNAMEs exactly as listed:
em####(return path, which carries SPF),s1._domainkey, ands2._domainkey. Don't hand-write an SPFincludeon the apex. The "Send to Coworker" button was removed on 3 Aug 2026, so send the records to the DNS owner yourself. - Link branding (
POST /v3/whitelabel/links) rewrites tracked links and theList-UnsubscribeURL onto your domain instead ofsendgrid.net. Do it whenever click tracking or subscription tracking is on. If you put the branded link host behind a CDN for SSL click tracking, the CDN must allow POST from non-browser user agents, or one-click unsubscribes never reach SendGrid. - DMARC is yours to publish. SendGrid doesn't create it.
# Porkbun / Cloudflare records (host part only; Cloudflare: DNS-only, grey cloud)
CNAME em1234 u1234567.wl123.sendgrid.net
CNAME s1._domainkey s1.domainkey.u1234567.wl123.sendgrid.net
CNAME s2._domainkey s2.domainkey.u1234567.wl123.sendgrid.net
CNAME url5678 sendgrid.net # link branding (values come from the dashboard)
CNAME 1234567 sendgrid.net
TXT _dmarc v=DMARC1; p=none; rua=mailto:dmarc@client.example; fo=1
Start DMARC at p=none, read the aggregate reports, then move to p=quarantine and p=reject. Give SendGrid its own subdomain: Porkbun won't let a CNAME share a host with other records, and a separate subdomain keeps SendGrid's reputation apart from Resend's or the client's mailbox provider.
Bulk-sender rules (Gmail, Yahoo, Microsoft)
These rules are the same whichever provider sends the mail; see ../domain-portfolio/ for the full table and ../resend/ for the Resend side. They apply once a domain sends about 5,000 messages a day to a provider's consumer inboxes (Gmail counts all subdomains together, and bulk status never expires):
- SPF and DKIM pass, plus a DMARC record (at least
p=none) aligned with the From domain. - RFC 8058 one-click unsubscribe on marketing mail:
List-Unsubscribe+List-Unsubscribe-Post: List-Unsubscribe=One-Click. Honor unsubscribes within 2 days. - Spam-complaint rate below 0.3% (aim for under 0.1%).
- Microsoft (Outlook.com, Hotmail, Live) has rejected non-compliant bulk mail with
550 5.7.515since 5 May 2025. Gmail has been ramping up enforcement (temporary4.7.xand permanent5.7.xerrors) since November 2025.
How SendGrid meets the unsubscribe rule: turn on subscription tracking (Settings → Tracking) or send with an ASM unsubscribe group (asm.groupId). Either way, SendGrid inserts both List-Unsubscribe (an HTTPS URL on your link-branding domain plus a mailto:) and List-Unsubscribe-Post, and processes the unsubscribe for you. Marketing Campaigns always adds them unless you use a custom unsubscribe link. If neither is on, you must add both headers yourself in headers and handle the POST. Transactional mail (receipts, resets) doesn't need one-click unsubscribe.
Event Webhook (signed)
SendGrid POSTs batched JSON arrays of events: delivery (processed, delivered, deferred, dropped, bounce), engagement (open, click, spamreport, unsubscribe, group_unsubscribe, group_resubscribe), and account status changes.
- HTTPS only. Required for new webhooks since Oct 2025; HTTP webhooks stopped receiving events after 11 Feb 2026.
- Multiple webhooks: 1 on the trial, 2 on Essentials, 5 on Pro and Premier (
POST /v3/user/webhooks/event/settings). Each has its own key pair, so store one public key per webhook id. - Security: enable signature verification (ECDSA, P-256, SHA-256 over
timestamp + raw body) and/or OAuth 2.0 client credentials (SendGrid fetches a token from your token URL and sends it asAuthorization: Bearer). Use at least signing. - Retries: any non-2xx is retried at increasing intervals for up to 24 hours (rolling, per event). Return 2xx fast and do the work afterwards.
- Dedupe on
sg_event_id. Match to your send throughcustom_argsorsg_message_id, which can be missing on async bounces. bouncewithtype: "bounce"is a hard bounce;type: "blocked"is temporary.bounce_classificationgives the reason (Invalid Address, Technical, Content, Reputation, Frequency/Volume, Mailbox Unavailable, Unclassified).openevents carrysg_machine_open: truewhen Apple Mail Privacy Protection fetched the pixel. Don't count those as human opens.
// app/api/webhooks/sendgrid/route.ts
import { EventWebhook, EventWebhookHeader } from '@sendgrid/eventwebhook';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
export async function POST(req: Request): Promise<Response> {
const rawBody = await req.text(); // exact bytes: never req.json() first, never .trim()
const signature = req.headers.get(EventWebhookHeader.SIGNATURE()); // X-Twilio-Email-Event-Webhook-Signature
const timestamp = req.headers.get(EventWebhookHeader.TIMESTAMP()); // X-Twilio-Email-Event-Webhook-Timestamp
const publicKey = process.env.SENDGRID_WEBHOOK_PUBLIC_KEY;
if (!publicKey || !signature || !timestamp) return new Response(null, { status: 400 });
const ew = new EventWebhook();
const valid = ew.verifySignature(ew.convertPublicKeyToECDSA(publicKey), rawBody, signature, timestamp);
if (!valid) return new Response(null, { status: 403 });
const events = JSON.parse(rawBody) as { sg_event_id: string; event: string; email: string }[];
for (const e of events) {
// dedupe on e.sg_event_id, then update status / mirror suppressions
}
return new Response(null, { status: 204 });
}
The full handler with typed events, hard/soft bounce handling, and machine-open filtering is examples/event-webhook-route.ts. It uses the dependency-free node:crypto verifier in examples/verify-signature.ts, which also adds a replay window and caches the key.
Gotcha: raw bytes. The signature covers the exact payload, including its trailing
\r\ncharacters.req.text()keeps them;req.json(), ExpressbodyParser.json(), or.trim()break a valid signature. On Express, mountexpress.raw({ type: 'application/json' })on this route only.
Inbound Parse (now signable)
Inbound Parse turns mail sent to a subdomain into a multipart/form-data POST to your app: reply-to-ticket, document intake, +tag routing.
- DNS:
MX parse 10 mx.sendgrid.neton the receiving subdomain. - Create a webhook security policy with signing on:
POST /v3/user/webhooks/security/policieswith{ "name": "...", "signature": { "enabled": true } }. The response holdspolicy.signature.public_key. OAuth (client_id,client_secret,token_url,scopes) is also supported, alone or together. - Create the Parse setting (Settings → Inbound Parse, or the API) and attach the policy:
PATCH /v3/user/webhooks/parse/settings/{hostname}with{ "security_policy": "<policy id>" }. - Verify with the same headers as the Event Webhook, over the raw multipart bytes, before any form parser touches the body.
Gotcha: binary attachments.
@sendgrid/eventwebhook'sverifySignature()turns a Buffer into a UTF-8 string before hashing. A multipart body with binary attachments then fails verification. Our local test with a generated P-256 key confirmed it: valid on JSON, invalid on a body with non-UTF-8 bytes. Use thenode:cryptoverifier inexamples/verify-signature.ts, which hashes the bytes directly. Full route:examples/inbound-parse-route.ts.
Treat every inbound field as untrusted: sanitize html with DOMPurify before rendering, check the SPF and dkim fields if sender identity matters, and size-limit attachments. On an unsigned (legacy) Parse setting, at least use a hard-to-guess path; SendGrid recommends signing over IP allowlists because its webhook IPs change.
Suppressions and Unsubscribe Groups
SendGrid won't deliver to an address on a suppression list (bounces, blocks, spam reports, invalid emails, global unsubscribes, group unsubscribes). Mirror these locally from the Event Webhook so your app never queues a dead address, and use @sendgrid/client to read or clear entries.
import client from '@sendgrid/client';
client.setApiKey(process.env.SENDGRID_API_KEY ?? '');
// Clear a bounce after the user fixes a typo
await client.request({ method: 'DELETE', url: `/v3/suppression/bounces/${encodeURIComponent('user@example.com')}` });
// Add an address to an unsubscribe group from your own preference centre
await client.request({ method: 'POST', url: '/v3/asm/groups/12345/suppressions', body: { recipient_emails: ['user@example.com'] } });
More (global unsubscribe check, subuser-scoped calls): examples/suppressions.ts. Create one unsubscribe group per mail type (product news, digest, offers) so recipients can opt out of one without losing receipts. Never remove an unsubscribe or spam report on your own: it's a CAN-SPAM obligation and a reputation risk.
Subusers, IP Pools, and Data Residency
| Feature | What it gives you | API | Plan |
|---|---|---|---|
| Subusers | Separate reputation, stats, suppressions, and credit limits per tenant or brand. Parent keys act as a subuser with the on-behalf-of: <username> header (client.setImpersonateSubuser() in the SDK) |
POST /v3/subusers |
Pro+ |
| Domain auth per subuser | Assign an authenticated domain (up to 5) or a branded link to a subuser | POST /v3/whitelabel/domains/{id}/subuser:add, POST /v3/whitelabel/links/{id}/subuser |
Pro+ |
| Dedicated IPs | Your own sending reputation; automated warmup | IP Address Management API | Pro includes 1; more as add-ons |
| IP pools | Group IPs (for example transactional vs marketing) and pick one per send with ipPoolName |
POST /v3/send_ips/pools (newer) or POST /v3/ips/pools (legacy) |
Pro+ |
| EU data residency | Mail and event data processed and stored in the EU; host https://api.eu.sendgrid.com |
client.setDataResidency('eu') |
Pro+, EU subuser and EU IP |
Warm a new dedicated IP gradually. A fresh IP at full volume gets throttled. Under roughly 100k emails a month, shared IPs usually deliver better than a cold dedicated one.
SendGrid vs Resend (primary)
| Concern | Resend (primary) | SendGrid (alternative) |
|---|---|---|
| When to pick | Default. Start here | A client requires it, or you need subusers, IP pools, or EU residency |
| Free tier | 3,000 emails/mo, permanent | None. 60-day trial at 100/day, then Essentials from $19.95/mo |
| Templates | React Email (.tsx) in your repo |
Handlebars dynamic templates in the dashboard (d-…) |
| SDK | resend (works on Edge) |
@sendgrid/mail + @sendgrid/client (Node only; axios) |
| Webhook signing | Svix (HMAC) | ECDSA P-256 via @sendgrid/eventwebhook or node:crypto; OAuth 2.0 optional |
| Inbound | email.received webhook |
Inbound Parse (multipart), signable |
| One-click unsubscribe | Add the headers yourself / Broadcasts add them | Subscription tracking or ASM group adds them |
| Multi-tenant | One account; domains per project | Subusers with isolated reputation |
| Dedicated IPs | Scale add-on | Pro includes 1, plus IP pools |
Environment Variables
Secrets (store in the vault, .env.local, and Vercel; never in the client bundle):
SENDGRID_API_KEY=SG.xxxxxxxxxxxxxxxxxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Non-secret settings (plain config):
| Variable | Example | Notes |
|---|---|---|
SENDGRID_FROM_EMAIL |
no-reply@mail.client.example |
Must be on an authenticated domain |
SENDGRID_WEBHOOK_PUBLIC_KEY |
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE… |
Public key for one Event Webhook. Not secret, but keep it in config, not code |
SENDGRID_INBOUND_PUBLIC_KEY |
MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE… |
From the Inbound Parse security policy |
SENDGRID_WELCOME_TEMPLATE_ID |
d-… |
Dynamic template ids |
SENDGRID_DIGEST_TEMPLATE_ID |
d-… |
|
SENDGRID_UNSUBSCRIBE_GROUP_ID |
12345 |
ASM group for marketing sends |
If you enable Event Webhook OAuth, the client secret you give SendGrid is a secret and belongs in the vault too. Add the variables to ENV_MASTER.md and each project's .env.example.
Common Use Cases
| Use case | Approach |
|---|---|
| Default transactional email | Resend + React Email. SendGrid only when the client requires it |
| Templated transactional send | sgMail.send with templateId + dynamicTemplateData, tracking off |
| Newsletter / marketing | personalizations + asm.groupId (one-click unsubscribe headers added for you) |
| Delivery and bounce tracking | Signed Event Webhook → verify → dedupe sg_event_id → update DB |
| Honor opt-outs | Mirror suppressions locally; check before every send |
| Reply or intake by email | Inbound Parse + security policy + raw-bytes verification |
| Multi-tenant client | One subuser per tenant, each with its own authenticated domain |
| Separate transactional and marketing reputation | Two IP pools (or two subusers) + ipPoolName |
| EU customer data | EU subuser + client.setDataResidency('eu') |
| CI check of payloads | mailSettings.sandboxMode.enable = true |
codeAmani notes
- Resend is primary; SendGrid is the alternative. Pick SendGrid only for the client-driven reasons listed above, and write the reason into the project's README. The lack of a free tier makes it a poor fit for prototypes.
- Server-side only.
SENDGRID_API_KEYnever reaches the browser. Use a Restricted Access key (Mail Send only) in the app. - Webhooks: verify every Event Webhook and Inbound Parse request (ECDSA on the raw body) before acting, as with the Stripe signing secret, Svix for Clerk and Resend, and M-Pesa callback validation. Run them on the Node runtime.
- Payments: Stripe is the default. A SendGrid receipt should be triggered from the verified Stripe webhook, keyed on the Stripe event id. For Kenya-targeted projects that use M-Pesa, key it on the
CheckoutRequestIDafter the callback is validated. - AI routing: if Claude drafts email copy, generate it server-side and put the result into
dynamicTemplateData. Escape it (Handlebars{{var}}escapes by default; never use{{{var}}}for model output). - Kenya-targeted projects: email backs up SMS and WhatsApp rather than replacing them. Keep templates light (inline CSS, few images) for 2G/3G, show KES as whole shillings, and send in EAT-friendly hours. If the client is already on Twilio for SMS or WhatsApp, SendGrid consolidates billing.
- DNS: Porkbun or Cloudflare. Use a dedicated sending subdomain per provider so SendGrid and Resend never share SPF, DKIM selectors, or reputation.
Troubleshooting
| Issue | Fix |
|---|---|
401 Unauthorized |
Key missing, mistyped, or revoked. Recreate it |
403 "from address does not match a verified Sender Identity" |
Authenticate the domain (or verify a Single Sender for testing) |
| Sending stopped on an old free account | The free plan was retired in 2025. Upgrade to Essentials or higher |
| Mail lands in spam or shows "via sendgrid.net" | Finish domain authentication and link branding, publish DMARC, check alignment |
550 5.7.515 from Outlook.com |
SPF, DKIM, or DMARC missing or not aligned for a bulk sender |
| Gmail shows no unsubscribe button | Turn on subscription tracking or use an ASM group; check the CDN allows non-browser POSTs to the branded link host |
| Event Webhook stopped delivering | The URL is still HTTP (blocked since 11 Feb 2026), or your endpoint has been non-2xx for 24 hours |
| Signature always invalid | Body was parsed or trimmed before verifying; wrong key for that webhook id (each webhook has its own) |
| Inbound Parse signature fails only with attachments | You used @sendgrid/eventwebhook on a binary body. Switch to the node:crypto verifier |
| Duplicate event processing | Dedupe on sg_event_id |
| Open rates look inflated | Exclude sg_machine_open: true |
| Template renders blank variables | dynamicTemplateData keys must match the Handlebars {{vars}} |
| Recipients see each other | Use personalizations or isMultiple, not a bare to: [] |
| Mail to one address never arrives | It's suppressed. Check /v3/suppression/* and /v3/asm/suppressions/global/{email} |
429 on Email Activity API |
Limited to 6 requests/minute since Dec 2025. Use the Event Webhook |
| Inbound Parse never fires | MX for the parse subdomain missing (mx.sendgrid.net, priority 10) |
Official docs:
- https://www.twilio.com/docs/sendgrid
- https://www.twilio.com/docs/sendgrid/api-reference/mail-send/mail-send
- https://www.twilio.com/docs/sendgrid/ui/sending-email/how-to-send-an-email-with-dynamic-templates
- https://www.twilio.com/docs/sendgrid/for-developers/tracking-events/event
- https://www.twilio.com/docs/sendgrid/for-developers/tracking-events/getting-started-event-webhook-security-features
- https://www.twilio.com/docs/sendgrid/for-developers/parsing-email/securing-your-parse-webhooks
- https://www.twilio.com/docs/sendgrid/ui/account-and-settings/how-to-set-up-domain-authentication
- https://www.twilio.com/en-us/products/email-api/pricing