Webhooks and Data Integrity

A webhook is an HTTP notification from another service. An integration might post a notice when a document is published. Before changing local state, verify who sent the message, whether its contents are expected, and whether you already processed it.

On this page

Verify the original bytes

Use the provider’s documented verification library. For a signed webhook such as GitHub’s, verify the signature over the original request body with the configured secret before processing the event. Parsing and serializing JSON again can change the bytes. A valid signature establishes message integrity but a repeated genuine message can still arrive.

Receive     Apply a body size limit and preserve the raw bytes
Verify      Use the provider verifier and configured secret
Interpret   Accept the expected event type, account, and payload schema

Read plain data and handle retries

Parse external messages as plain data and validate the expected fields. Avoid formats that construct executable or application-defined objects from input. Use a stable authenticated event or business identifier and a uniqueness constraint. Record the identifier and local change in one transaction, so a retry cannot apply the change twice.

First verified publication event    Record the event and publish the notice
Same verified event delivered again  Keep the existing notice
Unrecognized event type              Make no document changes

Official references