| name | sendgrid-webhooks |
| description | Receive and verify SendGrid webhooks. Use when setting up SendGrid webhook handlers, debugging signature verification, or handling email delivery events.
|
| license | MIT |
| metadata | {"author":"hookdeck","version":"0.1.0","repository":"https://github.com/hookdeck/webhook-skills"} |
SendGrid Webhooks
When to Use This Skill
- Setting up SendGrid webhook handlers for email delivery tracking
- Debugging ECDSA signature verification failures
- Processing email events (bounce, delivered, open, click, spam report)
- Implementing email engagement analytics
Essential Code
Signature Verification (Manual)
SendGrid uses ECDSA (Elliptic Curve Digital Signature Algorithm) with public key verification.
const crypto = require('crypto');
function verifySignature(publicKey, payload, signature, timestamp) {
const decodedSignature = Buffer.from(signature, );
signedContent = timestamp + payload;
verifier = crypto.();
verifier.(signedContent);
pemKey = publicKey;
(!pemKey.()) {
pemKey = ;
}
verifier.(pemKey, decodedSignature);
}
app.(, express.({ : }), {
signature = req.();
timestamp = req.();
(!signature || !timestamp) {
res.().();
}
publicKey = process..;
payload = req..();
(!(publicKey, payload, signature, timestamp)) {
res.().();
}
events = .(payload);
.();
res.();
});