← Spec Hub | Category: Payments & Billing

SendGrid ➔ Stripe Webhook Pipeline Specification Webhook Integration Spec

Technical Integration Summary

Comprehensive specification for handling incoming SendGrid ➔ Stripe Webhook Pipeline Specification webhook events. This reference covers cryptographic payload verification, request headers, and retry protocols.

Supported Events: charge.succeeded payment_intent.created invoice.payment_failed customer.subscription.deleted

Authentication & Request Headers

Security validation specs for SendGrid ➔ Stripe Webhook Pipeline Specification endpoints:

Authorization: Bearer sec_live_abb67e61aac97857

Signature Verification Implementations

Node.js (Express)

const crypto = require('crypto');
const expected = crypto.createHmac('sha256', secret).update(rawBody).digest('hex');
const isValid = crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(signature));

Python (Flask / FastAPI)

import hmac, hashlib
expected = hmac.new(secret.encode(), raw_body, hashlib.sha256).hexdigest()
is_valid = hmac.compare_digest(expected, incoming_sig)

Sample Event Payload (charge.succeeded)

{
  "id": "evt_sendgrid-to-stripe.html_53776",
  "event": "charge.succeeded",
  "created_at": 1789764056,
  "data": {
    "resource_id": "res_183",
    "status": "active"
  }
}

cURL Request Simulation

curl -X POST https://your-domain.com/webhook/sendgrid-to-stripe.html \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sec_live_abb67e61aac97857" \
  -d '{"id": "evt_sendgrid-to-stripe.html_53776", "event": "charge.succeeded", "created_at": 1789764056, "data": {"resource_id": "res_183", "status": "active"}}'

HTTP Response Rules

Status CodeStatus MeaningIntegration Action
200 OKSuccessEvent payload validated and queued.
400 Bad RequestMalformed PayloadCheck payload structure and JSON formatting.
401 UnauthorizedSignature MismatchVerify secret key and digest computation.
500 ErrorServer ErrorTriggers provider automated retry backoff.

Security Best Practices for SendGrid ➔ Stripe Webhook Pipeline Specification

Always process incoming events asynchronously using a message queue. Never perform long-running DB queries or external API calls synchronously within the HTTP response handler.

Frequently Asked Questions

How to handle duplicate SendGrid ➔ Stripe Webhook Pipeline Specification webhooks?

Store processed event IDs in an atomic storage like Redis with a set expiration. If an incoming ID exists, acknowledge with 200 OK immediately without re-triggering logic.

How does SendGrid ➔ Stripe Webhook Pipeline Specification handle automatic delivery retries?

Failed deliveries (non-2xx responses) trigger an exponential backoff retry schedule over a period ranging from 24 to 72 hours.

What is the response timeout for SendGrid ➔ Stripe Webhook Pipeline Specification webhooks?

Your endpoint must return an HTTP 2xx response within 2000ms. Offload heavy processing (email, DB writes) to an asynchronous task queue.