Immutable solution version
SendGrid Event Webhook signature verification failures
Complete solution
Shows how to fix sendGrid Event Webhook signature verification failures. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Enable signing first: Settings > Mail Settings > Event Settings > Signed Event Webhook Requests > Generate Verification Key. This is the number-one failure: parsing the JSON and re-stringifying it changes bytes and invalidates the signature.
Steps
- Symptom: your ECDSA check rejects genuine SendGrid events, or you cannot get verification working at all.
- Enable signing first: Settings > Mail Settings > Event Settings > Signed Event Webhook Requests > Generate Verification Key. No key, no signature headers.
- Read the two headers: X-Twilio-Email-Event-Webhook-Signature and X-Twilio-Email-Event-Webhook-Timestamp.
- Hash sha256 over the timestamp bytes followed by the RAW payload bytes. This is the number-one failure: parsing the JSON and re-stringifying it changes bytes and invalidates the signature.
- Base64-decode the signature, ASN.1 unmarshal into the {r, s} pair, and ECDSA-verify against the public key.
- Prefer the SDK helper (each official library ships an EventWebhook helper, e.g. the eventwebhook package) over hand-rolled crypto.
- If verification keeps failing, log the raw bytes you hashed and compare lengths with what arrived. A framework that parses the body before your handler runs is the usual culprit.
When to use
You are seeing this: Symptom: your ECDSA check rejects genuine SendGrid events, or you cannot get verification working at all. Use this skill when you run into "SendGrid Event Webhook signature verification failures".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Why this happens
The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
Evidence
The official Event Webhook security doc: Twilio signs with an ECDSA key pair; the signature arrives in X-Twilio-Email-Event-Webhook-Signature and the timestamp in X-Twilio-Email-Event-Webhook-Timestamp. Verification: base64-decode the signature, ASN.1 unmarshal to {r, s}, sha256 over timestamp + raw payload bytes, then ECDSA verify. The payload must stay in raw bytes; converting to a JSON string can break the signature. SDKs ship EventWebhook helpers. Sources: https://github.com/sendgrid/docs/blob/develop/content/docs/for-developers/tracking-events/getting-started-event-webhook-security-features.md
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_kDIkZRD6yfmvivZhacietw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">SendGrid Event Webhook signature verification failures <span>— Vectle</span></a>