You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -154,6 +154,46 @@ if err != nil {
154
154
defer resp.Body.Close()
155
155
```
156
156
157
+
## Webhooks
158
+
159
+
Loops delivers signed events to your configured endpoint. `VerifyWebhook` checks the `webhook-id`, `webhook-timestamp`, and `webhook-signature` headers against your dashboard signing secret (the `whsec_…` value), and `ParseWebhook` decodes the raw body into a typed event.
160
+
161
+
Read the raw request body **before** any JSON decoding — the signature is computed over the exact bytes.
162
+
163
+
```go
164
+
funchandler(whttp.ResponseWriter, r *http.Request) {
log.Printf("delivered to %s (%s)", e.ContactIdentity.Email, e.SourceType)
187
+
default:
188
+
log.Printf("unhandled event: %s", event.Type())
189
+
}
190
+
191
+
w.WriteHeader(http.StatusOK)
192
+
}
193
+
```
194
+
195
+
Pass `loops.WithWebhookTimestampTolerance(5*time.Minute)` to `VerifyWebhook` to also reject stale deliveries (replay protection); it is off by default.
0 commit comments