Goal
Accept only genuine, recent webhooks from StackShift.Prerequisites
- A destination and its signing secret (whsec_…), shown once when you add it.
Workflow
1
Store the signing secret as an environment variable, for example STACKSHIFT_WEBHOOK_SECRET.
2
Read the request body as raw bytes, before any JSON parsing.
3
Call the SDK verify function with the raw body, the StackShift-Signature header and the secret.
4
Answer 2xx quickly, and drop events whose id you have already handled.
Headers
- StackShift-Signature: t=<unix seconds>,v1=<hex>, where v1 is HMAC-SHA256 with your secret over “<t>.” followed by the raw body.
- StackShift-Timestamp, StackShift-Event-Id, StackShift-Event-Type and StackShift-Delivery-Id.
- The SDKs refuse signatures more than 300 seconds from now. Errors carry a code: missing_signature, invalid_signature, expired or invalid_body.
- Rotate a secret with Make a new secret on the destination. Mail webhooks keep their existing body and signature, so receivers built for Mail keep working.
Verify with an SDK
Each verify call returns the parsed event when the signature is valid and throws or returns an error otherwise.Error types
- JavaScript: EventSignatureError with code. Python: EventSignatureError with code. Go: *stackshift.EventSignatureError with Code. Ruby: StackShift::EventSignatureError with code. PHP: StackShift\EventSignatureError with errorCode.
- Every SDK takes an optional tolerance: toleranceSeconds in JavaScript, tolerance_seconds in Python, Tolerance in Go, tolerance in Ruby and the fourth argument in PHP.
Expected result
Your endpoint rejects forged, altered or replayed requests and processes each event once.
Common failures
Related guides
Retries, replay and the dead-letter list
Failed deliveries retry 8 times over about 2 days. After the eighth failure the delivery goes to the dead-letter list, the destination or rule is turned off, and the owner gets an email.
Targets
Send a matched event to a webhook, a Function, a durable queue or waiting job, a hosted agent or Stackie, Slack, email or the dashboard, or an automation.